public PetsRepository(SimpleAppContext context) { _context = context; if (_context.Pets.Count() == 0) { _context.Pets.AddRange( new Pet { Name = "Opie", Breed = "Shih Tzu", PetType = PetType.Dog }, new Pet { Name = "Reggie", Breed = "Beagle", PetType = PetType.Dog }, new Pet { Name = "Diesel", Breed = "Bombay", PetType = PetType.Cat }, new Pet { Name = "Lucy", Breed = "Maine Coon", PetType = PetType.Cat }); _context.SaveChanges(); } }
public List <PersonDto> GetAllPersons() { using (var context = new SimpleAppContext()) { return(context.Persons.ToList()); } }
public void DeletePerson(int id) { using (var context = new SimpleAppContext()){ var personToDelete = context.Persons.Find(id); if (personToDelete != null) { context.Persons.Remove(personToDelete); } } }
public void AddNewPerson(string name, string nickName, string tel) { using (var context = new SimpleAppContext()){ var newPerson = new PersonDto() { Name = name, NickName = nickName, TelephoneNumber = tel, }; context.Persons.Add(newPerson); context.SaveChanges(); } }
public ProductsRepository(SimpleAppContext context) { _context = context; if (_context.Products.Count() == 0) { _context.Products.AddRange( new Product { IsDiscontinued = true, Name = "Learning ASP.NET Core", Description = "A best-selling book covering the fundamentals of ASP.NET Core" }, new Product { Name = "Learning EF Core", Description = "A best-selling book covering the fundamentals of Entity Framework Core" }); _context.SaveChanges(); } }
public EApplicationRepository(SimpleAppContext context) { _context = context; }