public static void Seed(PhysicianLookupDbContext context) { var json = StaticFileLocator.GetAsString("physicians.json"); var jArray = JsonConvert.DeserializeObject <JObject>(json)["physicians"]; var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326); foreach (var token in jArray) { var physician = (JObject)token; _ = context.Physicians.Add(new () { Title = (string)physician["title"], Firstname = (string)physician["firstname"], Lastname = (string)physician["lastname"], Address = new Address( (string)physician["street"], (string)physician["city"], (string)physician["province"], (string)physician["postalCode"], (double)physician["longitude"], (double)physician["latitude"], geometryFactory.CreatePoint(new Coordinate((double)physician["longitude"], (double)physician["latitude"]))), EmailAddress = (string)physician["emailAddress"], Website = (string)physician["website"], }); } context.SaveChanges(); }
public static void Seed(AppDbContext context) { if (context.HtmlContents.SingleOrDefault(x => x.Name == "TermsAndConditions.html") == null) { context.HtmlContents.Add(new HtmlContent { Name = "TermsAndConditions.html", Value = StaticFileLocator.GetAsString("TermsAndConditions.html") }); } if (context.HtmlContents.SingleOrDefault(x => x.Name == "About.html") == null) { context.HtmlContents.Add(new HtmlContent { Name = "About.html", Value = StaticFileLocator.GetAsString("About.html") }); } context.SaveChanges(); }
public static void Seed(AppDbContext context) { if (context.EmailTemplates.SingleOrDefault(x => x.Name == nameof(EmailTemplateName.BookingConfirmation)) == null) { context.EmailTemplates.Add(new EmailTemplate { Name = nameof(EmailTemplateName.BookingConfirmation), Value = StaticFileLocator.GetAsString("BookingConfirmationEmail.html") }); } if (context.EmailTemplates.SingleOrDefault(x => x.Name == nameof(EmailTemplateName.NewCustomer)) == null) { context.EmailTemplates.Add(new EmailTemplate { Name = nameof(EmailTemplateName.NewCustomer), Value = StaticFileLocator.GetAsString("NewCustomerEmail.html") }); } context.SaveChanges(); }
private static ICollection <ProductImage> Get(string[] fileNames) { var productImages = new List <ProductImage>(); foreach (var fileName in fileNames) { var provider = new FileExtensionContentTypeProvider(); provider.TryGetContentType(fileName, out string contentType); productImages.Add(new ProductImage { DigitalAsset = new DigitalAsset() { Name = fileName, ContentType = contentType, Bytes = StaticFileLocator.Get(fileName) } }); } return(productImages); }
public static void Seed(AppDbContext context) { if (context.DigitalAssets.SingleOrDefault(x => x.Name == "Logo.png") == null) { var provider = new FileExtensionContentTypeProvider(); provider.TryGetContentType("KidsToyHiveLogo.png", out string contentType); context.DigitalAssets.Add(new DigitalAsset { Name = "Logo.png", Bytes = StaticFileLocator.Get("KidsToyHiveLogo.png"), ContentType = contentType }); context.SaveChanges(); } if (context.DigitalAssets.SingleOrDefault(x => x.Name == "Hero1.jpg") == null) { var provider = new FileExtensionContentTypeProvider(); provider.TryGetContentType("Hero1.jpg", out string contentType); context.DigitalAssets.Add(new DigitalAsset { Name = "Hero1.jpg", Bytes = StaticFileLocator.Get("Hero1.jpg"), ContentType = contentType }); context.SaveChanges(); } if (context.DigitalAssets.SingleOrDefault(x => x.Name == "Hero2.jpg") == null) { var provider = new FileExtensionContentTypeProvider(); provider.TryGetContentType("Hero2.jpg", out string contentType); context.DigitalAssets.Add(new DigitalAsset { Name = "Hero2.jpg", Bytes = StaticFileLocator.Get("Hero2.jpg"), ContentType = contentType }); context.SaveChanges(); } if (context.DigitalAssets.SingleOrDefault(x => x.Name == "Hero3.jpg") == null) { var provider = new FileExtensionContentTypeProvider(); provider.TryGetContentType("Hero3.jpg", out string contentType); context.DigitalAssets.Add(new DigitalAsset { Name = "Hero3.jpg", Bytes = StaticFileLocator.Get("Hero3.jpg"), ContentType = contentType }); context.SaveChanges(); } }