public LostPetVM GetLostPetVM(string username, int id) { LostPet lostPet = this.Context.LostPets.FirstOrDefault(p => p.Id == id); LostPetVM vm = Mapper.Map <LostPet, LostPetVM>(lostPet); vm.IsLostPet = true; vm.Comments = vm.Comments.OrderByDescending(comment => comment.DatePosted); vm.AssociatedUsername = username; return(vm); }
public ActionResult ConfirmDelete(int id) { string username = User.Identity.Name; if (this.service.PetBelongsToUser(username, id) || User.IsInRole("Admin")) { LostPetVM vm = this.service.GetLostPetVM(username, id); return(View(vm)); } return(RedirectToAction("index", "home")); }