public ActionResult Details(JhroCaseViewModel vm) { if (vm != null) { JhroCase jc = null; if (vm.Id > 0) { jc = this.sourceTasks.GetJhroCase(vm.Id); } else if (!string.IsNullOrEmpty(vm.CaseNumber)) { jc = this.sourceTasks.GetJhroCase(vm.CaseNumber); } if (jc != null) { ViewBag.JhroCase = jc; HrdbCase hrdbCase = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized); return(View(hrdbCase)); } } return(new HttpNotFoundResult()); }
public JsonNetResult FindMatchingEventCandidates(int id) { JhroCase jc = this.sourceTasks.GetJhroCase(id); if (jc != null) { // if not already linked to an Event... if (!jc.Events.Any()) { HrdbCase hrdbCase = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized); // ...find potential matching Events to link to this case return(JsonNet(new { Events = this.eventMatchingTasks.FindMatchingEventCandidates(jc, hrdbCase) })); } else { Response.StatusCode = (int)HttpStatusCode.InternalServerError; Response.StatusDescription = "That case already has an event linked."; return(JsonNet(Response.StatusDescription)); } } else { Response.StatusCode = (int)HttpStatusCode.NotFound; Response.StatusDescription = "That case doesn't exist."; return(JsonNet(Response.StatusDescription)); } }
public HrdbCaseViewModel(JhroCase jc) { if (jc != null) { this.Id = jc.Id; if (jc.Events != null && jc.Events.Any()) { // currently assuming one Event (but data model can take multiple) this.EventId = jc.Events[0].Id; } HrdbCase hc = (HrdbCase)StreamUtil.Deserialize(jc.HrdbContentsSerialized); if (hc != null) { this.HrdbCase = hc; this.HrdbPerpetrators = hc.Perpetrators.Select(x => new HrdbPerpetratorViewModel(x)).ToList(); // pre-populate new Event fields this.Event = new EventViewModel(); this.Event.PopulateDropDowns(ServiceLocator.Current.GetInstance <IEventTasks>().GetAllEventVerifiedStatuses()); this.Event.ViolationIds = string.Join(",", this.HrdbPerpetrators.Select(x => x.GetViolationIds()).Aggregate(new List <int>(), (x, y) => x.Concat(y).ToList())); this.Event.NarrativeEn = string.Join("\n\n", new string[] { "Summary", hc.Summary, "Analysis", hc.AnalysisDesc, "Facts", hc.FactAnalysis, "Legal", hc.LegalAnalysis, "Methodology", hc.Methodology }); if (hc.StartDate.HasValue) { this.Event.YearOfStart = hc.StartDate.Value.Year; this.Event.MonthOfStart = hc.StartDate.Value.Month; this.Event.DayOfStart = hc.StartDate.Value.Day; } if (hc.EndDate.HasValue) { this.Event.YearOfEnd = hc.EndDate.Value.Year; this.Event.MonthOfEnd = hc.EndDate.Value.Month; this.Event.DayOfEnd = hc.EndDate.Value.Day; } // location Location loc = ServiceLocator.Current.GetInstance <ILocationTasks>().GetOrCreateLocation(hc.IncidentAddr, hc.TownVillage, hc.Subregion, hc.Region, hc.GetLatitude(), hc.GetLongitude()); if (loc != null) { this.Event.LocationId = loc.Id; } // notes this.Event.EventVerifiedStatusId = ServiceLocator.Current.GetInstance <IEventTasks>().GetEventVerifiedStatus( hc.IsComplaintCode() ? EventVerifiedStatus.ALLEGATION : EventVerifiedStatus.JHRO_VERIFIED).Id; this.Event.JhroCaseIds = jc.Id.ToString(); } } this.OrganizationResponsibilityTypes = ServiceLocator.Current.GetInstance <IResponsibilityTasks>().GetOrgResponsibilityTypes() .Select(x => new SelectListItem() { Text = x.OrganizationResponsibilityTypeName, Value = x.Id.ToString() }) .ToList(); this.PersonResponsibilityTypes = ServiceLocator.Current.GetInstance <IResponsibilityTasks>().GetPersonResponsibilityTypes() .Select(x => new SelectListItem() { Text = x.PersonResponsibilityTypeName, Value = x.Id.ToString() }) .ToList(); }