public IMMedicationEN ReadOIDDefault(int id ) { IMMedicationEN iMMedicationEN = null; try { SessionInitializeTransaction(); iMMedicationEN = (IMMedicationEN)session.Get(typeof(IMMedicationEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMMedicationCAD.", ex); } finally { SessionClose(); } return(iMMedicationEN); }
// Modify default (Update all attributes of the class) public void ModifyDefault(IMMedicationEN iMMedication) { try { SessionInitializeTransaction(); IMMedicationEN iMMedicationEN = (IMMedicationEN)session.Load(typeof(IMMedicationEN), iMMedication.Id); session.Update(iMMedicationEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMMedicationCAD.", ex); } finally { SessionClose(); } }
public IMMedicationEN ReadOID(int id ) { IMMedicationEN iMMedicationEN = null; iMMedicationEN = _IIMMedicationCAD.ReadOID(id); return(iMMedicationEN); }
public void Modify(int p_IMMedication_OID, string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, bool p_isOID, bool p_isWritable, string p_description, string p_value) { IMMedicationEN iMMedicationEN = null; //Initialized IMMedicationEN iMMedicationEN = new IMMedicationEN(); iMMedicationEN.Id = p_IMMedication_OID; iMMedicationEN.Name = p_name; iMMedicationEN.Type = p_type; iMMedicationEN.IsOID = p_isOID; iMMedicationEN.IsWritable = p_isWritable; iMMedicationEN.Description = p_description; iMMedicationEN.Value = p_value; //Call to IMMedicationCAD _IIMMedicationCAD.Modify(iMMedicationEN); }
public void Modify(IMMedicationEN iMMedication) { try { SessionInitializeTransaction(); IMMedicationEN iMMedicationEN = (IMMedicationEN)session.Load(typeof(IMMedicationEN), iMMedication.Id); iMMedicationEN.Name = iMMedication.Name; iMMedicationEN.Type = iMMedication.Type; iMMedicationEN.IsOID = iMMedication.IsOID; iMMedicationEN.IsWritable = iMMedication.IsWritable; iMMedicationEN.Description = iMMedication.Description; iMMedicationEN.Value = iMMedication.Value; session.Update(iMMedicationEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMMedicationCAD.", ex); } finally { SessionClose(); } }
public static IMMedicationDTOA Convert(EntityAttributesEN en, NHibernate.ISession session = null) { IMMedicationDTOA dto = null; IMMedicationRESTCAD iMMedicationRESTCAD = null; IMMedicationCEN iMMedicationCEN = null; IMMedicationCP iMMedicationCP = null; if (en != null) { dto = new IMMedicationDTOA(); iMMedicationRESTCAD = new IMMedicationRESTCAD(session); iMMedicationCEN = new IMMedicationCEN(iMMedicationRESTCAD); iMMedicationCP = new IMMedicationCP(session); IMMedicationEN enHijo = iMMedicationRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: IMMedication o--> Medication */ dto.ValueMedication = MedicationAssembler.Convert((MedicationEN)enHijo.Medication, session); // // Service } return(dto); }
public int New_(string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, bool p_isOID, bool p_isWritable, string p_description, int p_entity, string p_value, int p_medication) { IMMedicationEN iMMedicationEN = null; int oid; //Initialized IMMedicationEN iMMedicationEN = new IMMedicationEN(); iMMedicationEN.Name = p_name; iMMedicationEN.Type = p_type; iMMedicationEN.IsOID = p_isOID; iMMedicationEN.IsWritable = p_isWritable; iMMedicationEN.Description = p_description; if (p_entity != -1) { // El argumento p_entity -> Property entity es oid = false // Lista de oids id iMMedicationEN.Entity = new MoSIoTGenNHibernate.EN.MosIoT.EntityEN(); iMMedicationEN.Entity.Id = p_entity; } iMMedicationEN.Value = p_value; if (p_medication != -1) { // El argumento p_medication -> Property medication es oid = false // Lista de oids id iMMedicationEN.Medication = new MoSIoTGenNHibernate.EN.MosIoT.MedicationEN(); iMMedicationEN.Medication.ProductReference = p_medication; } //Call to IMMedicationCAD oid = _IIMMedicationCAD.New_(iMMedicationEN); return(oid); }
public int New_(IMMedicationEN iMMedication) { try { SessionInitializeTransaction(); if (iMMedication.Entity != null) { // Argumento OID y no colección. iMMedication.Entity = (MoSIoTGenNHibernate.EN.MosIoT.EntityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.EntityEN), iMMedication.Entity.Id); iMMedication.Entity.Attributes .Add(iMMedication); } if (iMMedication.Medication != null) { // Argumento OID y no colección. iMMedication.Medication = (MoSIoTGenNHibernate.EN.MosIoT.MedicationEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.MedicationEN), iMMedication.Medication.ProductReference); } session.Save(iMMedication); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMMedicationCAD.", ex); } finally { SessionClose(); } return(iMMedication.Id); }
public static IMMedicationEN Convert(IMMedicationDTO dto) { IMMedicationEN newinstance = null; try { if (dto != null) { newinstance = new IMMedicationEN(); if (dto.Medication_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IMedicationCAD medicationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.MedicationCAD(); newinstance.Medication = medicationCAD.ReadOIDDefault(dto.Medication_oid); } newinstance.Id = dto.Id; newinstance.Name = dto.Name; newinstance.Type = dto.Type; newinstance.IsOID = dto.IsOID; 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.OriginAsociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.OriginAsociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.OriginAsociation_oid) { newinstance.OriginAsociation.Add(associationCAD.ReadOIDDefault(entry)); } } newinstance.AssociationType = dto.AssociationType; newinstance.IsWritable = dto.IsWritable; newinstance.Description = dto.Description; if (dto.Entity_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityCAD entityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityCAD(); newinstance.Entity = entityCAD.ReadOIDDefault(dto.Entity_oid); } if (dto.Trigger_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IRecipeTriggerCAD recipeTriggerCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeTriggerCAD(); newinstance.Trigger = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RecipeTriggerEN>(); foreach (int entry in dto.Trigger_oid) { newinstance.Trigger.Add(recipeTriggerCAD.ReadOIDDefault(entry)); } } if (dto.Register_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IRegisterCAD registerCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RegisterCAD(); newinstance.Register = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RegisterEN>(); foreach (int entry in dto.Register_oid) { newinstance.Register.Add(registerCAD.ReadOIDDefault(entry)); } } newinstance.Value = dto.Value; } } catch (Exception ex) { throw ex; } return(newinstance); }
public HttpResponseMessage ReadOID(int idIMMedication) { // CAD, CEN, EN, returnValue IMMedicationRESTCAD iMMedicationRESTCAD = null; IMMedicationCEN iMMedicationCEN = null; IMMedicationEN iMMedicationEN = null; IMMedicationDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); iMMedicationRESTCAD = new IMMedicationRESTCAD(session); iMMedicationCEN = new IMMedicationCEN(iMMedicationRESTCAD); // Data iMMedicationEN = iMMedicationCEN.ReadOID(idIMMedication); // Convert return if (iMMedicationEN != null) { returnValue = IMMedicationAssembler.Convert(iMMedicationEN, 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)); } }