// Modify default (Update all attributes of the class) public void ModifyDefault(PatientAccessEN patientAccess) { try { SessionInitializeTransaction(); PatientAccessEN patientAccessEN = (PatientAccessEN)session.Load(typeof(PatientAccessEN), patientAccess.Id); session.Update(patientAccessEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in PatientAccessCAD.", ex); } finally { SessionClose(); } }
public int New_(string p_name, int p_scenario, string p_description, int p_accessMode) { PatientAccessEN patientAccessEN = null; int oid; //Initialized PatientAccessEN patientAccessEN = new PatientAccessEN(); patientAccessEN.Name = p_name; if (p_scenario != -1) { // El argumento p_scenario -> Property scenario es oid = false // Lista de oids id patientAccessEN.Scenario = new MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN(); patientAccessEN.Scenario.Id = p_scenario; } patientAccessEN.Description = p_description; if (p_accessMode != -1) { // El argumento p_accessMode -> Property accessMode es oid = false // Lista de oids id patientAccessEN.AccessMode = new MoSIoTGenNHibernate.EN.MosIoT.AccessModeEN(); patientAccessEN.AccessMode.Id = p_accessMode; } //Call to PatientAccessCAD oid = _IPatientAccessCAD.New_(patientAccessEN); return(oid); }
public PatientAccessEN ReadOIDDefault(int id ) { PatientAccessEN patientAccessEN = null; try { SessionInitializeTransaction(); patientAccessEN = (PatientAccessEN)session.Get(typeof(PatientAccessEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in PatientAccessCAD.", ex); } finally { SessionClose(); } return(patientAccessEN); }
public PatientAccessEN ReadOID(int id ) { PatientAccessEN patientAccessEN = null; patientAccessEN = _IPatientAccessCAD.ReadOID(id); return(patientAccessEN); }
public void Modify(int p_PatientAccess_OID, string p_name, string p_description) { PatientAccessEN patientAccessEN = null; //Initialized PatientAccessEN patientAccessEN = new PatientAccessEN(); patientAccessEN.Id = p_PatientAccess_OID; patientAccessEN.Name = p_name; patientAccessEN.Description = p_description; //Call to PatientAccessCAD _IPatientAccessCAD.Modify(patientAccessEN); }
public static PatientAccessDTOA Convert (EntityEN en, NHibernate.ISession session = null) { PatientAccessDTOA dto = null; PatientAccessRESTCAD patientAccessRESTCAD = null; PatientAccessCEN patientAccessCEN = null; PatientAccessCP patientAccessCP = null; if (en != null) { dto = new PatientAccessDTOA (); patientAccessRESTCAD = new PatientAccessRESTCAD (session); patientAccessCEN = new PatientAccessCEN (patientAccessRESTCAD); patientAccessCP = new PatientAccessCP (session); PatientAccessEN enHijo = patientAccessRESTCAD.ReadOIDDefault (en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: PatientAccess o--> AccessMode */ dto.AccessMode = AccessModeAssembler.Convert ((AccessModeEN)enHijo.AccessMode, session); // // Service } return dto; }
public int New_(PatientAccessEN patientAccess) { try { SessionInitializeTransaction(); if (patientAccess.Scenario != null) { // Argumento OID y no colección. patientAccess.Scenario = (MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN), patientAccess.Scenario.Id); patientAccess.Scenario.Entity .Add(patientAccess); } if (patientAccess.AccessMode != null) { // Argumento OID y no colección. patientAccess.AccessMode = (MoSIoTGenNHibernate.EN.MosIoT.AccessModeEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.AccessModeEN), patientAccess.AccessMode.Id); } session.Save(patientAccess); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in PatientAccessCAD.", ex); } finally { SessionClose(); } return(patientAccess.Id); }
public static PatientAccessEN Convert(PatientAccessDTO dto) { PatientAccessEN newinstance = null; try { if (dto != null) { newinstance = new PatientAccessEN(); if (dto.AccessMode_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IAccessModeCAD accessModeCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AccessModeCAD(); newinstance.AccessMode = accessModeCAD.ReadOIDDefault(dto.AccessMode_oid); } newinstance.Id = dto.Id; newinstance.Name = dto.Name; if (dto.OriginAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.OriginAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.OriginAssociation_oid) { newinstance.OriginAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.TargetAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.TargetAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.TargetAssociation_oid) { newinstance.TargetAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.Scenario_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IIoTScenarioCAD ioTScenarioCAD = new MoSIoTGenNHibernate.CAD.MosIoT.IoTScenarioCAD(); newinstance.Scenario = ioTScenarioCAD.ReadOIDDefault(dto.Scenario_oid); } newinstance.Description = dto.Description; if (dto.Operations != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityOperationCAD entityOperationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityOperationCAD(); newinstance.Operations = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityOperationEN>(); foreach (EntityOperationDTO entry in dto.Operations) { newinstance.Operations.Add(EntityOperationAssemblerDTO.Convert(entry)); } } if (dto.Attributes != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityAttributesCAD entityAttributesCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityAttributesCAD(); newinstance.Attributes = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityAttributesEN>(); foreach (EntityAttributesDTO entry in dto.Attributes) { newinstance.Attributes.Add(EntityAttributesAssemblerDTO.Convert(entry)); } } if (dto.States != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityStateCAD entityStateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityStateCAD(); newinstance.States = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityStateEN>(); foreach (EntityStateDTO entry in dto.States) { newinstance.States.Add(EntityStateAssemblerDTO.Convert(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }
public HttpResponseMessage ReadOID(int idPatientAccess) { // CAD, CEN, EN, returnValue PatientAccessRESTCAD patientAccessRESTCAD = null; PatientAccessCEN patientAccessCEN = null; PatientAccessEN patientAccessEN = null; PatientAccessDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); patientAccessRESTCAD = new PatientAccessRESTCAD(session); patientAccessCEN = new PatientAccessCEN(patientAccessRESTCAD); // Data patientAccessEN = patientAccessCEN.ReadOID(idPatientAccess); // Convert return if (patientAccessEN != null) { returnValue = PatientAccessAssembler.Convert(patientAccessEN, 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)); } }