public int New_(MoSIoTGenNHibernate.Enumerated.MosIoT.CareStatusEnum p_status, MoSIoTGenNHibernate.Enumerated.MosIoT.CarePlanIntentEnum p_intent, string p_title, Nullable <DateTime> p_modified, int p_durationDays, string p_name, string p_description) { CarePlanTemplateEN carePlanTemplateEN = null; int oid; //Initialized CarePlanTemplateEN carePlanTemplateEN = new CarePlanTemplateEN(); carePlanTemplateEN.Status = p_status; carePlanTemplateEN.Intent = p_intent; carePlanTemplateEN.Title = p_title; carePlanTemplateEN.Modified = p_modified; carePlanTemplateEN.DurationDays = p_durationDays; carePlanTemplateEN.Name = p_name; carePlanTemplateEN.Description = p_description; //Call to CarePlanTemplateCAD oid = _ICarePlanTemplateCAD.New_(carePlanTemplateEN); return(oid); }
//Sin e: ReadOID //Con e: CarePlanTemplateEN public CarePlanTemplateEN ReadOID(int id ) { CarePlanTemplateEN carePlanTemplateEN = null; try { SessionInitializeTransaction(); carePlanTemplateEN = (CarePlanTemplateEN)session.Get(typeof(CarePlanTemplateEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CarePlanTemplateCAD.", ex); } finally { SessionClose(); } return(carePlanTemplateEN); }
public void Destroy(int id ) { try { SessionInitializeTransaction(); CarePlanTemplateEN carePlanTemplateEN = (CarePlanTemplateEN)session.Load(typeof(CarePlanTemplateEN), id); session.Delete(carePlanTemplateEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CarePlanTemplateCAD.", ex); } finally { SessionClose(); } }
public int New_(CarePlanTemplateEN carePlanTemplate) { try { SessionInitializeTransaction(); session.Save(carePlanTemplate); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CarePlanTemplateCAD.", ex); } finally { SessionClose(); } return(carePlanTemplate.Id); }
public CarePlanTemplateEN ReadOID(int id ) { CarePlanTemplateEN carePlanTemplateEN = null; carePlanTemplateEN = _ICarePlanTemplateCAD.ReadOID(id); return(carePlanTemplateEN); }
// Modify default (Update all attributes of the class) public void ModifyDefault(CarePlanTemplateEN carePlanTemplate) { try { SessionInitializeTransaction(); CarePlanTemplateEN carePlanTemplateEN = (CarePlanTemplateEN)session.Load(typeof(CarePlanTemplateEN), carePlanTemplate.Id); carePlanTemplateEN.Status = carePlanTemplate.Status; carePlanTemplateEN.Intent = carePlanTemplate.Intent; carePlanTemplateEN.Title = carePlanTemplate.Title; carePlanTemplateEN.Modified = carePlanTemplate.Modified; carePlanTemplateEN.DurationDays = carePlanTemplate.DurationDays; carePlanTemplateEN.Name = carePlanTemplate.Name; carePlanTemplateEN.Description = carePlanTemplate.Description; session.Update(carePlanTemplateEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CarePlanTemplateCAD.", ex); } finally { SessionClose(); } }
public CarePlanTemplateEN CarePlanTemplate(int id) { CarePlanTemplateEN result = null; try { SessionInitializeTransaction(); String sql = @"select self.Template FROM CarePlanEN self " + "where self.Id = :p_Id"; IQuery query = session.CreateQuery(sql).SetParameter("p_Id", id); result = query.UniqueResult <CarePlanTemplateEN>(); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CarePlanRESTCAD.", ex); } finally { SessionClose(); } return(result); }
public static CarePlanTemplateEN Convert(CarePlanTemplateDTO dto) { CarePlanTemplateEN newinstance = null; try { if (dto != null) { newinstance = new CarePlanTemplateEN(); if (dto.CareActivity != null) { MoSIoTGenNHibernate.CAD.MosIoT.ICareActivityCAD careActivityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CareActivityCAD(); newinstance.CareActivity = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN>(); foreach (CareActivityDTO entry in dto.CareActivity) { newinstance.CareActivity.Add(CareActivityAssemblerDTO.Convert(entry)); } } if (dto.PatientProfile_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IPatientProfileCAD patientProfileCAD = new MoSIoTGenNHibernate.CAD.MosIoT.PatientProfileCAD(); newinstance.PatientProfile = patientProfileCAD.ReadOIDDefault(dto.PatientProfile_oid); } newinstance.Status = dto.Status; newinstance.Intent = dto.Intent; newinstance.Title = dto.Title; newinstance.Modified = dto.Modified; if (dto.Goals != null) { MoSIoTGenNHibernate.CAD.MosIoT.IGoalCAD goalCAD = new MoSIoTGenNHibernate.CAD.MosIoT.GoalCAD(); newinstance.Goals = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.GoalEN>(); foreach (GoalDTO entry in dto.Goals) { newinstance.Goals.Add(GoalAssemblerDTO.Convert(entry)); } } if (dto.AddressConditions_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IConditionCAD conditionCAD = new MoSIoTGenNHibernate.CAD.MosIoT.ConditionCAD(); newinstance.AddressConditions = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.ConditionEN>(); foreach (int entry in dto.AddressConditions_oid) { newinstance.AddressConditions.Add(conditionCAD.ReadOIDDefault(entry)); } } newinstance.Id = dto.Id; newinstance.DurationDays = dto.DurationDays; newinstance.Name = dto.Name; newinstance.Description = dto.Description; if (dto.Comunication != null) { MoSIoTGenNHibernate.CAD.MosIoT.IComunicationCAD comunicationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.ComunicationCAD(); newinstance.Comunication = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.ComunicationEN>(); foreach (ComunicationDTO entry in dto.Comunication) { newinstance.Comunication.Add(ComunicationAssemblerDTO.Convert(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }
public static CarePlanTemplateDTOA Convert(CarePlanTemplateEN en, NHibernate.ISession session = null) { CarePlanTemplateDTOA dto = null; CarePlanTemplateRESTCAD carePlanTemplateRESTCAD = null; CarePlanTemplateCEN carePlanTemplateCEN = null; CarePlanTemplateCP carePlanTemplateCP = null; if (en != null) { dto = new CarePlanTemplateDTOA(); carePlanTemplateRESTCAD = new CarePlanTemplateRESTCAD(session); carePlanTemplateCEN = new CarePlanTemplateCEN(carePlanTemplateRESTCAD); carePlanTemplateCP = new CarePlanTemplateCP(session); // // Attributes dto.Id = en.Id; dto.Status = en.Status; dto.Intent = en.Intent; dto.Title = en.Title; dto.Modified = en.Modified; dto.DurationDays = en.DurationDays; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: CarePlanTemplate o--> CareActivity */ dto.CareActivities = null; List <CareActivityEN> CareActivities = carePlanTemplateRESTCAD.CareActivities(en.Id).ToList(); if (CareActivities != null) { dto.CareActivities = new List <CareActivityDTOA>(); foreach (CareActivityEN entry in CareActivities) { dto.CareActivities.Add(CareActivityAssembler.Convert(entry, session)); } } /* Rol: CarePlanTemplate o--> Goal */ dto.Goals = null; List <GoalEN> Goals = carePlanTemplateRESTCAD.Goals(en.Id).ToList(); if (Goals != null) { dto.Goals = new List <GoalDTOA>(); foreach (GoalEN entry in Goals) { dto.Goals.Add(GoalAssembler.Convert(entry, session)); } } /* Rol: CarePlanTemplate o--> PatientProfileCare */ dto.Patient = PatientProfileCareAssembler.Convert((PatientProfileEN)en.PatientProfile, session); /* Rol: CarePlanTemplate o--> Condition_CarePlan */ dto.AddressConditions = null; List <ConditionEN> AddressConditions = carePlanTemplateRESTCAD.AddressConditions(en.Id).ToList(); if (AddressConditions != null) { dto.AddressConditions = new List <Condition_CarePlanDTOA>(); foreach (ConditionEN entry in AddressConditions) { dto.AddressConditions.Add(Condition_CarePlanAssembler.Convert(entry, session)); } } // // Service } return(dto); }
public HttpResponseMessage ReadOID(int idCarePlanTemplate) { // CAD, CEN, EN, returnValue CarePlanTemplateRESTCAD carePlanTemplateRESTCAD = null; CarePlanTemplateCEN carePlanTemplateCEN = null; CarePlanTemplateEN carePlanTemplateEN = null; CarePlanTemplateDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); carePlanTemplateRESTCAD = new CarePlanTemplateRESTCAD(session); carePlanTemplateCEN = new CarePlanTemplateCEN(carePlanTemplateRESTCAD); // Data carePlanTemplateEN = carePlanTemplateCEN.ReadOID(idCarePlanTemplate); // Convert return if (carePlanTemplateEN != null) { returnValue = CarePlanTemplateAssembler.Convert(carePlanTemplateEN, session); } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }