public void Seed(DiagnoseMeDbContext context) { if(!context.Partners.Any()) { var ministryOfEducation = new PartnerSeedModel() { Name = "МИНИСТЕРСТВО НА ОБРАЗОВАНИЕТО И НАУКАТА", Description = "Министерство на образованието и науката на Република България.", Website = "http://www.mon.bg/", Logo = "http://www.mon.bg/pics/big/coat_of_arms.png", JoinedOn = DateTime.UtcNow, PartnershipLevel = PartnershipLevelType.Gold }; var ministryOfHealth = new PartnerSeedModel() { Name = "Министерство на Здравеопазването", Description = "Министерство на Здравеопазването на Република България", Website = "http://www.mh.government.bg/bg/", Logo = "http://www.mh.government.bg/static/images/Ministry_of_Health-logo.1da2a1b6684e.svg", JoinedOn = DateTime.UtcNow, PartnershipLevel = PartnershipLevelType.Diamond }; this.SeedPartner(ministryOfEducation, context); this.SeedPartner(ministryOfHealth, context); } }
public void SeedPartner(PartnerSeedModel model, DiagnoseMeDbContext context) { var partner = new Partner() { Name = model.Name, Description = model.Description, JoinedOn = model.JoinedOn, Website = model.Website, Logo = model.Logo, PartnershipLevel = model.PartnershipLevel }; context.Partners.AddOrUpdate(partner); context.SaveChanges(); }