public void DeletePrisoner(int id) { var prisoner = prisonerProvider.GetPrisonerById(id); if (!string.IsNullOrEmpty(prisoner.Photo)) { RemovePhotos(prisoner.Photo); } prisonerDataService.DeletePrisoner(id); var cacheKey = $"prisoner_{id}"; HttpRuntime.Cache.Remove(cacheKey); }
public ActionResult EditPrisoner(int?id) { if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var prisoner = prisonerProvider.GetPrisonerById(id.Value); if (prisoner != null) { var model = Mapper.Map <Prisoner, CreateOrUpdatePrisonerViewModel>(prisoner); ViewBag.RelShipStatus = Enum.Parse(typeof(RelationshipStatus), prisoner.RelationshipStatus); return(View(model)); } return(HttpNotFound()); }
public ActionResult DetailsOfPrisoner(int?id, int?page, int?totalCountDetentions) { const int pageSize = 4; if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var prisoner = prisonerProvider.GetPrisonerById(id.Value); if (prisoner == null) { return(HttpNotFound()); } var pageNum = page ?? 1; var skip = (pageNum - 1) * pageSize; var _currentTotal = totalCountDetentions ?? default(int); var model = Mapper.Map <Prisoner, DetailsPrisonerViewModel>(prisoner); var listOfDetentions = prisonerProvider .GetDetentionsByPrisonerIdForPagedList(prisoner.PrisonerId, skip, pageSize, ref _currentTotal); if (listOfDetentions != null) { var listOfDetentionsModel = Mapper .Map <IReadOnlyList <DetentionPagedList>, IReadOnlyList <DetentionPagedListViewModel> >(listOfDetentions); ViewBag.prisonerId = model.PrisonerId; ViewBag.currentPage = pageNum; ViewBag.Guarded = listOfDetentions.Last().DateOfRelease != null ? false : true; ViewBag.totalCountDetentions = _currentTotal; var pagedListDetention = new StaticPagedList <DetentionPagedListViewModel>(listOfDetentionsModel, pageNum, pageSize, _currentTotal); model.DetentionPagedList = pagedListDetention; } else { ViewBag.Guarded = false; } return(View(model)); }