private void SeedAnnouncement_Category(AnnContext context) { for (int i = 1; i < 10; i++) { var acat = new Announcement_Category() { Id = i, AnnouncementId = i / 2 + 1, CategoryId = i / 2 + 2, }; context.Set <Announcement_Category>().AddOrUpdate(acat); } context.SaveChanges(); }
private void SeedCategory(AnnContext context) { for (int i = 1; i < 10; i++) { var cat = new Category() { Id = i, Name = "Nazwa kategorii " + i.ToString(), Content = "Tresc ogloszenia " + i.ToString(), MetaTitle = "Tytul kategorii " + i.ToString(), MetaDescription = "Opis kategorii " + i.ToString(), MetaWords = "Slowa kluczowe do kategorii " + i.ToString(), ParentId = i }; context.Set <Category>().AddOrUpdate(cat); } context.SaveChanges(); }
private void SeedAnnouncement(AnnContext context) { var userId = context.Set <User>().Where(u => u.UserName == "Admin").FirstOrDefault().Id; for (int i = 1; i < 10; i++) { var ann = new Announcement() { Id = i, UserId = userId, Content = "Tresc ogloszenia " + i.ToString(), Title = "Tytul ogloszenia " + i.ToString(), DateAdded = DateTime.Now.AddDays(-i) }; context.Set <Announcement>().AddOrUpdate(ann); } context.SaveChanges(); }