Пример #1
0
 public ActionResult UpdateAnimal(AnimalVM model)
 {
     if (ModelState.IsValid)
     {
         var result = db.Animal.FirstOrDefault(x => x.ID == model.ID);
         result.Name        = model.Name;
         result.Description = model.Description;
         result.Color       = model.Color;
         result.Location    = model.Location;
         result.Age         = model.Age;
         result.ID          = model.ID;
         result.GenusId     = AnimalRepo.AnimalGenus(model.GenusName);
         result.CategoryId  = AnimalRepo.AnimalCategory(model.CategoryName);
         ViewBag.islemDurum = 1;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.islemDurum = 2;
         return(View());
     }
 }