public virtual void AddOrganizationResponsibility(OrganizationResponsibility or) { if (this.OrganizationResponsibilities.Contains(or)) { return; } this.OrganizationResponsibilities.Add(or); }
public ActionResult Edit(int id) { OrganizationResponsibility or = responsibilityTasks.GetOrganizationResponsibility(id); if (or != null) { OrgResponsibilityViewModel vm = new OrgResponsibilityViewModel(or); vm.PopulateDropDowns(this.responsibilityTasks.GetOrgResponsibilityTypes()); return(View(vm)); } return(new HttpNotFoundResult()); }
public JsonNetResult Delete(int id) { OrganizationResponsibility or = responsibilityTasks.GetOrganizationResponsibility(id); if (or != null) { this.responsibilityTasks.DeleteOrganizationResponsibility(or); Response.StatusCode = (int)HttpStatusCode.OK; return(JsonNet("Organization and/or unit's responsibility for event successfully removed.")); } Response.StatusCode = (int)HttpStatusCode.NotFound; return(JsonNet("Organization responsibility not found.")); }
public EntityUnitDateDTO(OrganizationResponsibility or) { if (or != null && or.Unit != null) { this.Unit = or.Unit; this.DayOfStart = or.Event.DayOfStart; this.MonthOfStart = or.Event.MonthOfStart; this.YearOfStart = or.Event.YearOfStart; this.DayOfEnd = or.Event.DayOfEnd; this.MonthOfEnd = or.Event.MonthOfEnd; this.YearOfEnd = or.Event.YearOfEnd; this.SourceTypeName = typeof(OrganizationResponsibility).Name; } }
public IList <OrganizationResponsibility> GetOrganizationResponsibilitiesLinkedByUnit(Person p) { OrganizationResponsibility or = null; Unit u = null; Career c = null; return(Session.QueryOver <OrganizationResponsibility>(() => or) .JoinAlias(() => or.Unit, () => u, JoinType.InnerJoin) .JoinAlias(() => u.Careers, () => c, JoinType.InnerJoin) .Where(() => c.Person == p) .And(() => !c.Archive) .And(() => !u.Archive) .And(() => !or.Archive) .TransformUsing(Transformers.DistinctRootEntity) .List()); }
public void DeleteOrganizationResponsibility(OrganizationResponsibility or) { if (or.Event != null) { or.Event.RemoveOrganizationResponsibility(or); } if (or.Organization != null) { or.Organization.RemoveOrganizationResponsibility(or); } if (or.Unit != null) { or.Unit.RemoveOrganizationResponsibility(or); } this.orgResponsibilityRepo.Delete(or); }
public OrgResponsibilityViewModel(OrganizationResponsibility or) { this.Id = or.Id; this.OrganizationId = or.Organization.Id; this.OrganizationName = or.Organization.ToString(); if (or.Unit != null) { this.UnitId = or.Unit.Id; this.UnitName = or.Unit.UnitName; } this.EventId = or.Event.Id; this.EventHeadline = or.Event.Headline; this.OrganizationResponsibilityTypeId = or.OrganizationResponsibilityType.Id; this.Commentary = or.Commentary; this.Archive = or.Archive; this.Notes = or.Notes; }
public OrganizationResponsibility SaveOrganizationResponsibility(OrganizationResponsibility or) { if (or != null) { if (or.Event != null) { or.Event.AddOrganizationResponsibility(or); } if (or.Organization != null) { or.Organization.AddOrganizationResponsibility(or); } if (or.Unit != null) { or.Unit.AddOrganizationResponsibility(or); } return(this.orgResponsibilityRepo.SaveOrUpdate(or)); } return(or); }
public virtual bool AddOrganizationResponsibility(OrganizationResponsibility or) { foreach (OrganizationResponsibility o in this.OrganizationResponsibilities) { if (o.Organization.Id == or.Organization.Id) { if (o.Unit == null && or.Unit == null) { return(false); } else if (o.Unit != null && or.Unit != null && o.Unit.Id == or.Unit.Id) { return(false); } } } this.OrganizationResponsibilities.Add(or); or.Organization.AddOrganizationResponsibility(or); return(true); }
public JsonNetResult Add(OrgResponsibilityViewModel vm) { if (ModelState.IsValid) { Event e = this.eventTasks.GetEvent(vm.EventId); Organization o = this.organizationTasks.GetOrganization(vm.OrganizationId.Value); if (e != null && o != null) { OrganizationResponsibility or = new OrganizationResponsibility(); or.Event = e; or.Organization = o; or.Unit = vm.UnitId.HasValue ? this.organizationTasks.GetUnit(vm.UnitId.Value) : null; or.OrganizationResponsibilityType = this.responsibilityTasks.GetOrgResponsibilityType(vm.OrganizationResponsibilityTypeId); or.Commentary = vm.Commentary; or.Notes = vm.Notes; or.Archive = false; if (e.AddOrganizationResponsibility(or)) { e = this.eventTasks.SaveEvent(e); return(JsonNet(string.Empty)); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(JsonNet("Organization/unit responsibility already exists.")); } } else { Response.StatusCode = (int)HttpStatusCode.NotFound; return(JsonNet("Event or organization does not exist.")); } } else { return(JsonNet(this.GetErrorsForJson())); } }
public JsonNetResult Edit(OrgResponsibilityViewModel vm) { if (ModelState.IsValid) { OrganizationResponsibility or = responsibilityTasks.GetOrganizationResponsibility(vm.Id); if (or != null) { // assuming event, org are the same or.Unit = vm.UnitId.HasValue ? this.organizationTasks.GetUnit(vm.UnitId.Value) : null; or.OrganizationResponsibilityType = this.responsibilityTasks.GetOrgResponsibilityType(vm.OrganizationResponsibilityTypeId); or.Commentary = vm.Commentary; or.Notes = vm.Notes; or = this.responsibilityTasks.SaveOrganizationResponsibility(or); return(JsonNet(string.Empty)); } Response.StatusCode = (int)HttpStatusCode.NotFound; return(JsonNet("Organization responsibility does not exist.")); } else { return(JsonNet(this.GetErrorsForJson())); } }
public ActionResult Import(HrdbCaseViewModel vm) { JhroCase jc = this.sourceTasks.GetJhroCase(vm.Id); // if an existing Event is selected, ignore validation errors to do with new event if (vm.EventId.HasValue) { // TODO brittle ModelState.Remove("Event.ViolationIds"); ModelState.Remove("Event.LocationId"); } if (ModelState.IsValid) { Event e = null; if (vm.EventId.HasValue) { e = this.eventTasks.GetEvent(vm.EventId.Value); e.AddJhroCase(jc); } else { // create new event - TODO duplicates code in other EventsController e = new Event(); Mapper.Map <EventViewModel, Event>(vm.Event, e); if (!string.IsNullOrEmpty(vm.Event.ViolationIds)) { string[] ids = vm.Event.ViolationIds.Split(','); foreach (string id in ids) { int result; if (int.TryParse(id, out result)) { Violation v = this.eventTasks.GetViolation(result); if (v != null) { e.Violations.Add(v); } } } } e.Location = this.locationTasks.GetLocation(vm.Event.LocationId.Value); e.EventVerifiedStatus = vm.Event.EventVerifiedStatusId.HasValue ? this.eventTasks.GetEventVerifiedStatus(vm.Event.EventVerifiedStatusId.Value) : null; if (!string.IsNullOrEmpty(vm.Event.TagIds)) { string[] ids = vm.Event.TagIds.Split(','); foreach (string id in ids) { int result; if (int.TryParse(id, out result)) { Tag t = this.eventTasks.GetTag(result); if (t != null) { e.Tags.Add(t); } } } } if (!string.IsNullOrEmpty(vm.Event.JhroCaseIds)) { string[] ids = vm.Event.JhroCaseIds.Split(','); foreach (string id in ids) { int result; if (int.TryParse(id, out result)) { JhroCase jhroCase = this.sourceTasks.GetJhroCase(result); if (jhroCase != null) { e.AddJhroCase(jhroCase); } } } } } // create responsibilities if (e != null && vm.HrdbPerpetrators != null) { foreach (HrdbPerpetratorViewModel pvm in vm.HrdbPerpetrators) { if (pvm.PersonId.HasValue) { Person p = this.personTasks.GetPerson(pvm.PersonId.Value); if (p != null) { if (pvm.PersonResponsibilityTypeId.HasValue) { PersonResponsibilityType prt = this.responsibilityTasks.GetPersonResponsibilityType(pvm.PersonResponsibilityTypeId.Value); if (prt != null) { PersonResponsibility pr = new PersonResponsibility() { Event = e, Person = p, PersonResponsibilityType = prt, Violations = pvm.GetViolationIds().Select(x => this.eventTasks.GetViolation(x)).ToList() }; e.AddPersonResponsibility(pr); } } } } else if (pvm.OrganizationId.HasValue) { Organization o = this.orgTasks.GetOrganization(pvm.OrganizationId.Value); if (o != null) { if (pvm.OrganizationResponsibilityTypeId.HasValue) { OrganizationResponsibilityType ort = this.responsibilityTasks.GetOrgResponsibilityType(pvm.OrganizationResponsibilityTypeId.Value); if (ort != null) { OrganizationResponsibility or = new OrganizationResponsibility() { Event = e, Organization = o, OrganizationResponsibilityType = ort }; e.AddOrganizationResponsibility(or); } } } } } } e = this.eventTasks.SaveEvent(e); return(RedirectToAction("Details", "Cases", new { id = jc.Id })); } return(Import(new JhroCaseViewModel(jc))); }
public virtual void RemoveOrganizationResponsibility(OrganizationResponsibility or) { this.OrganizationResponsibilities.Remove(or); }