public void AddAnimal(Animal animal) { using (var data = new AnimalEntities()) { data.Animal.Add(animal); data.SaveChanges(); } }
public void AddAnimalType(AnimalTypes type) { using (var data = new AnimalEntities()) { data.AnimalTypes.Add(type); data.SaveChanges(); } }
public void DeleteAnimal(int id) { using (var data = new AnimalEntities()) { Animal type = (Animal)data.Animal.Where(x => x.Id == id).First(); data.Animal.Remove(type); data.SaveChanges(); } }
public void UpdateAnimalType(AnimalTypes type) { using (var data = new AnimalEntities()) { data.AnimalTypes.Attach(type); var entry = data.Entry(type); entry.State = System.Data.Entity.EntityState.Modified; data.SaveChanges(); } }