public ActionResult Pets_Destroy([DataSourceRequest]DataSourceRequest request, PetAdminInputViewModel pet) { var entity = this.pets.GetById(pet.Id); this.pets.MarkAsDeleted(entity); this.pets.SaveChanges(); return Json(new[] { pet }.ToDataSourceResult(request, ModelState)); }
public ActionResult Pets_Update([DataSourceRequest]DataSourceRequest request, PetAdminInputViewModel pet) { if (ModelState.IsValid) { var entity = this.pets.GetById(pet.Id); entity.Name = pet.Name; entity.BirthPlace = pet.BirthPlace; entity.Gender = pet.Gender; entity.Species = pet.Species; this.pets.Update(entity); this.pets.SaveChanges(); } var petToDisplay = this.pets.All() .ProjectTo<PetAdminViewModel>() .FirstOrDefault(x => x.Id == pet.Id); return Json(new[] { petToDisplay }.ToDataSourceResult(request, ModelState)); }