public string ChangeAnimal(ModelsF.Animal animal) { ModelsF.Animal a = _context.Animal.First(an => an.IdAnimal == animal.IdAnimal); a.IdAnimal = animal.IdAnimal; a.Name = animal.Name; a.Type = animal.Type; a.AdmissionDate = animal.AdmissionDate; a.IdOwner = animal.IdOwner; _context.SaveChanges(); return("Koniec procedury"); }
public string AddPet(Pet pet) { var db = new s19562Context(); var rasa = pet.IdBreedType; var exist = db.BreedType.Any(i => i.IdBreedType == rasa); if (!exist) { var maxId = db.BreedType.Max(a => a.IdBreedType); var BreedType = new BreedType { IdBreedType = maxId + 1 }; db.BreedType.Add(BreedType); } db.Pet.Add(pet); db.SaveChanges(); return("zwierze dodane --> sprawdz"); }