// Modify default (Update all attributes of the class) public void ModifyDefault(IMAppointmentEN iMAppointment) { try { SessionInitializeTransaction(); IMAppointmentEN iMAppointmentEN = (IMAppointmentEN)session.Load(typeof(IMAppointmentEN), iMAppointment.Id); iMAppointmentEN.Date = iMAppointment.Date; session.Update(iMAppointmentEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMAppointmentCAD.", ex); } finally { SessionClose(); } }
public IMAppointmentEN ReadOIDDefault(int id ) { IMAppointmentEN iMAppointmentEN = null; try { SessionInitializeTransaction(); iMAppointmentEN = (IMAppointmentEN)session.Get(typeof(IMAppointmentEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMAppointmentCAD.", ex); } finally { SessionClose(); } return(iMAppointmentEN); }
public IMAppointmentEN ReadOID(int id ) { IMAppointmentEN iMAppointmentEN = null; iMAppointmentEN = _IIMAppointmentCAD.ReadOID(id); return(iMAppointmentEN); }
public void Modify(int p_IMAppointment_OID, string p_name, string p_description, Nullable <DateTime> p_date) { IMAppointmentEN iMAppointmentEN = null; //Initialized IMAppointmentEN iMAppointmentEN = new IMAppointmentEN(); iMAppointmentEN.Id = p_IMAppointment_OID; iMAppointmentEN.Name = p_name; iMAppointmentEN.Description = p_description; iMAppointmentEN.Date = p_date; //Call to IMAppointmentCAD _IIMAppointmentCAD.Modify(iMAppointmentEN); }
public static IMAppointmentDTOA Convert(EntityEN en, NHibernate.ISession session = null) { IMAppointmentDTOA dto = null; IMAppointmentRESTCAD iMAppointmentRESTCAD = null; IMAppointmentCEN iMAppointmentCEN = null; IMAppointmentCP iMAppointmentCP = null; if (en != null) { dto = new IMAppointmentDTOA(); iMAppointmentRESTCAD = new IMAppointmentRESTCAD(session); iMAppointmentCEN = new IMAppointmentCEN(iMAppointmentRESTCAD); iMAppointmentCP = new IMAppointmentCP(session); IMAppointmentEN enHijo = iMAppointmentRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; if (enHijo != null) { dto.Date = enHijo.Date; } dto.Description = en.Description; // // TravesalLink /* Rol: IMAppointment o--> Appointment */ dto.ValueAppointment = AppointmentAssembler.Convert((AppointmentEN)enHijo.Appointment, session); // // Service } return(dto); }
public int New_(IMAppointmentEN iMAppointment) { try { SessionInitializeTransaction(); if (iMAppointment.Scenario != null) { // Argumento OID y no colección. iMAppointment.Scenario = (MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN), iMAppointment.Scenario.Id); iMAppointment.Scenario.Entity .Add(iMAppointment); } if (iMAppointment.Appointment != null) { // Argumento OID y no colección. iMAppointment.Appointment = (MoSIoTGenNHibernate.EN.MosIoT.AppointmentEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.AppointmentEN), iMAppointment.Appointment.Id); } session.Save(iMAppointment); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMAppointmentCAD.", ex); } finally { SessionClose(); } return(iMAppointment.Id); }
public int New_(string p_name, int p_scenario, string p_description, Nullable <DateTime> p_date, int p_appointment) { IMAppointmentEN iMAppointmentEN = null; int oid; //Initialized IMAppointmentEN iMAppointmentEN = new IMAppointmentEN(); iMAppointmentEN.Name = p_name; if (p_scenario != -1) { // El argumento p_scenario -> Property scenario es oid = false // Lista de oids id iMAppointmentEN.Scenario = new MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN(); iMAppointmentEN.Scenario.Id = p_scenario; } iMAppointmentEN.Description = p_description; iMAppointmentEN.Date = p_date; if (p_appointment != -1) { // El argumento p_appointment -> Property appointment es oid = false // Lista de oids id iMAppointmentEN.Appointment = new MoSIoTGenNHibernate.EN.MosIoT.AppointmentEN(); iMAppointmentEN.Appointment.Id = p_appointment; } //Call to IMAppointmentCAD oid = _IIMAppointmentCAD.New_(iMAppointmentEN); return(oid); }
public static IMAppointmentEN Convert(IMAppointmentDTO dto) { IMAppointmentEN newinstance = null; try { if (dto != null) { newinstance = new IMAppointmentEN(); newinstance.Date = dto.Date; if (dto.Appointment_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IAppointmentCAD appointmentCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AppointmentCAD(); newinstance.Appointment = appointmentCAD.ReadOIDDefault(dto.Appointment_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 idIMAppointment) { // CAD, CEN, EN, returnValue IMAppointmentRESTCAD iMAppointmentRESTCAD = null; IMAppointmentCEN iMAppointmentCEN = null; IMAppointmentEN iMAppointmentEN = null; IMAppointmentDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); iMAppointmentRESTCAD = new IMAppointmentRESTCAD(session); iMAppointmentCEN = new IMAppointmentCEN(iMAppointmentRESTCAD); // Data iMAppointmentEN = iMAppointmentCEN.ReadOID(idIMAppointment); // Convert return if (iMAppointmentEN != null) { returnValue = IMAppointmentAssembler.Convert(iMAppointmentEN, 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)); } }