public ActionResult ContactDetails(long rootKey, long contactedCasePersonId, bool getFromSession = true) { HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null); ViewBag.CanUpdate = humanCaseAccessor.CanUpdate; ViewBag.RootKey = rootKey; if (getFromSession) { var contactedCasePerson = (ContactedCasePerson)ModelStorage.Get(Session.SessionID, contactedCasePersonId, null); return(View(contactedCasePerson)); } var humanCase = (HumanCase)ModelStorage.GetRoot(Session.SessionID, rootKey, null); EditableList <ContactedCasePerson> list = humanCase.ContactedPerson; var root = (long)((HumanCase)ModelStorage.GetRoot(Session.SessionID, rootKey, null)).Key; ContactedCasePerson item; if (contactedCasePersonId == 0) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { var accessor = ContactedCasePerson.Accessor.Instance(null); item = accessor.Create(manager, humanCase, rootKey); item.NewObject = true; ModelStorage.Put(Session.SessionID, root, item.idfContactedCasePerson, null, item); return(View(item)); } } item = list.SingleOrDefault(c => c.idfContactedCasePerson == contactedCasePersonId); ModelStorage.Put(Session.SessionID, root, item.idfContactedCasePerson, null, item); return(View(item)); }
public ActionResult SetSelectedFarm(string root, string selectedId) { long key = long.Parse(root); long rootKey = (long)((IObject)ModelStorage.GetRoot(Session.SessionID, key, null)).Key; var vetCase = ModelStorage.Get(Session.SessionID, rootKey, null) as VetCase; using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance)) { var cloneVetCase = (VetCase)vetCase.CloneWithSetup(manager, true); long idfFarm = string.IsNullOrEmpty(selectedId) ? 0 : long.Parse(selectedId); if (idfFarm == 0) { var accessor = FarmPanel.Accessor.Instance(null); vetCase.Farm = accessor.CreateByCase(manager, vetCase, vetCase); } else { vetCase.Farm.idfRootFarm = idfFarm; } CompareModel data = vetCase.Compare(cloneVetCase); return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data }); } }
public ActionResult RemoveContactedCasePerson(long rootKey, long contactedCasePersonId) { var humanCase = (HumanCase)ModelStorage.GetRoot(Session.SessionID, rootKey, null); EditableList <ContactedCasePerson> list = humanCase.ContactedPerson; ContactedCasePerson item = list.Where(c => c.idfContactedCasePerson == contactedCasePersonId).SingleOrDefault(); list.Remove(item); return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = null }); }
public ActionResult SetSelectedPatient(string root, string selectedId) { long idfHumanActual = long.Parse(selectedId); long key = long.Parse(root); long rootKey = (long)((IObject)ModelStorage.GetRoot(Session.SessionID, key, null)).Key; var rootHumanCase = ModelStorage.Get(Session.SessionID, rootKey, null) as HumanCase; var data = new CompareModel(); using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance)) { var patientAccessor = Patient.Accessor.Instance(null); Patient patient = patientAccessor.SelectByKey(manager, idfHumanActual); var contactedPersonAccessor = ContactedCasePerson.Accessor.Instance(null); ContactedCasePerson contactedPerson = contactedPersonAccessor.Create(manager, rootHumanCase, rootKey); contactedPerson.Person = contactedPerson.Person.CopyFrom(manager, patient); long idfPatientRootHuman = patient.idfRootHuman.HasValue ? patient.idfRootHuman.Value : patient.idfHuman; int contactedPersonCount = rootHumanCase.ContactedPerson.Where(x => x.Person.idfRootHuman.Value == idfPatientRootHuman).Count(); if (contactedPersonCount > 0) { string errorMessage = EidssMessages.Get("errContactedPersonDuplicates"); data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false); } else if (rootHumanCase.Patient.idfRootHuman == idfPatientRootHuman) { string errorMessage = EidssMessages.Get("errContactedPersonDuplicateRootHuman"); data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false); } else { //rootHumanCase.ContactedPerson.Add(contactedPerson); //TODO: remove previous contact contactedPerson.NewObject = true; ModelStorage.Put(Session.SessionID, key, contactedPerson.idfContactedCasePerson, null, contactedPerson); data.Add("idfContactedCasePerson", "", "", contactedPerson.idfContactedCasePerson.ToString(), false, false, false); } } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data }); }