15d911c86b
modified: Core.Tests/Core.Tests.csproj modified: Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs new file: Core.Tests/Remote/PiscalSshClientTests.cs modified: Core/Core.csproj modified: Core/DAL/LeafWebContext.cs modified: Core/DAL/LeafWebInitializer.cs modified: Core/Models/LeafInput.cs new file: Core/Models/PhotosynthesisType.cs new file: Core/Remote/IPiscalClient.cs Get Piscal
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System.Data.Entity;
|
|
using System.Linq;
|
|
using LeafWeb.Core.Models;
|
|
using LeafWeb.Core.Parsers;
|
|
using LeafWeb.Core.Utility;
|
|
|
|
namespace LeafWeb.Core.DAL
|
|
{
|
|
public class LeafWebInitializer : DropCreateDatabaseIfModelChanges<LeafWebContext>
|
|
{
|
|
private const string ContentDirectory = @"DAL\InitialData\";
|
|
|
|
protected override void Seed(LeafWebContext context)
|
|
{
|
|
// get fluxnet sites from file
|
|
var fileInfo = FileUtility.GetContentFile(ContentDirectory, "fluxnet_site_list_all_October2015_with_joins_corrected.csv", true);
|
|
var fluxnetSiteCsvParser = new FluxnetSiteCsvParser(fileInfo);
|
|
var fluxnetSites = fluxnetSiteCsvParser.Parse().ToList();
|
|
|
|
// add to context
|
|
fluxnetSites.ForEach(s => context.FluxnetSites.Add(s));
|
|
|
|
var photosynthesisTypes = new []
|
|
{
|
|
new PhotosynthesisType {Id = "C3_photosynthesis_leafweb", Name = "C3 Photosynthesis"},
|
|
new PhotosynthesisType {Id = "C4_photosynthesis_leafweb", Name = "C4 Photosynthesis"},
|
|
new PhotosynthesisType {Id = "CAM_photosynthesis_leafweb", Name = "CAM Photosynthesis"}
|
|
};
|
|
|
|
context.PhotosynthesisTypes.AddRange(photosynthesisTypes);
|
|
|
|
context.SaveChanges();
|
|
|
|
base.Seed(context);
|
|
}
|
|
}
|
|
} |