public void Destroy(int id ) { try { SessionInitializeTransaction(); AppointmentEN appointmentEN = (AppointmentEN)session.Load(typeof(AppointmentEN), id); session.Delete(appointmentEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in AppointmentCAD.", ex); } finally { SessionClose(); } }
public AppointmentEN ReadOIDDefault(int id ) { AppointmentEN appointmentEN = null; try { SessionInitializeTransaction(); appointmentEN = (AppointmentEN)session.Get(typeof(AppointmentEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in AppointmentCAD.", ex); } finally { SessionClose(); } return(appointmentEN); }
public int New_(bool p_isVirtual, string p_description, string p_direction, string p_reasonCode, int p_careActivity) { AppointmentEN appointmentEN = null; int oid; //Initialized AppointmentEN appointmentEN = new AppointmentEN(); appointmentEN.IsVirtual = p_isVirtual; appointmentEN.Description = p_description; appointmentEN.Direction = p_direction; appointmentEN.ReasonCode = p_reasonCode; if (p_careActivity != -1) { // El argumento p_careActivity -> Property careActivity es oid = false // Lista de oids id appointmentEN.CareActivity = new MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN(); appointmentEN.CareActivity.Id = p_careActivity; } //Call to AppointmentCAD oid = _IAppointmentCAD.New_(appointmentEN); return(oid); }
public int New_(AppointmentEN appointment) { try { SessionInitializeTransaction(); if (appointment.CareActivity != null) { // Argumento OID y no colección. appointment.CareActivity = (MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN), appointment.CareActivity.Id); appointment.CareActivity.Appointment .Add(appointment); } session.Save(appointment); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in AppointmentCAD.", ex); } finally { SessionClose(); } return(appointment.Id); }
public static AppointmentEN Convert(AppointmentDTO dto) { AppointmentEN newinstance = null; try { if (dto != null) { newinstance = new AppointmentEN(); newinstance.Id = dto.Id; newinstance.IsVirtual = dto.IsVirtual; newinstance.Description = dto.Description; newinstance.Direction = dto.Direction; newinstance.ReasonCode = dto.ReasonCode; if (dto.CareActivity_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.ICareActivityCAD careActivityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CareActivityCAD(); newinstance.CareActivity = careActivityCAD.ReadOIDDefault(dto.CareActivity_oid); } } } catch (Exception ex) { throw ex; } return(newinstance); }
public AppointmentEN ReadOID(int id ) { AppointmentEN appointmentEN = null; appointmentEN = _IAppointmentCAD.ReadOID(id); return(appointmentEN); }
public void Modify(int p_Appointment_OID, bool p_isVirtual, string p_description, string p_direction, string p_reasonCode) { AppointmentEN appointmentEN = null; //Initialized AppointmentEN appointmentEN = new AppointmentEN(); appointmentEN.Id = p_Appointment_OID; appointmentEN.IsVirtual = p_isVirtual; appointmentEN.Description = p_description; appointmentEN.Direction = p_direction; appointmentEN.ReasonCode = p_reasonCode; //Call to AppointmentCAD _IAppointmentCAD.Modify(appointmentEN); }
public static AppointmentDTOA Convert(AppointmentEN en, NHibernate.ISession session = null) { AppointmentDTOA dto = null; AppointmentRESTCAD appointmentRESTCAD = null; AppointmentCEN appointmentCEN = null; AppointmentCP appointmentCP = null; if (en != null) { dto = new AppointmentDTOA(); appointmentRESTCAD = new AppointmentRESTCAD(session); appointmentCEN = new AppointmentCEN(appointmentRESTCAD); appointmentCP = new AppointmentCP(session); // // Attributes dto.Id = en.Id; dto.IsVirtual = en.IsVirtual; dto.Description = en.Description; dto.Direction = en.Direction; dto.ReasonCode = en.ReasonCode; // // TravesalLink // // Service } return(dto); }
// Modify default (Update all attributes of the class) public void ModifyDefault(AppointmentEN appointment) { try { SessionInitializeTransaction(); AppointmentEN appointmentEN = (AppointmentEN)session.Load(typeof(AppointmentEN), appointment.Id); appointmentEN.IsVirtual = appointment.IsVirtual; appointmentEN.Description = appointment.Description; appointmentEN.Direction = appointment.Direction; appointmentEN.ReasonCode = appointment.ReasonCode; session.Update(appointmentEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in AppointmentCAD.", ex); } finally { SessionClose(); } }
public AppointmentEN ValueAppointment(int id) { AppointmentEN result = null; try { SessionInitializeTransaction(); String sql = @"select self.Appointment FROM IMAppointmentEN self " + "where self.Id = :p_Id"; IQuery query = session.CreateQuery(sql).SetParameter("p_Id", id); result = query.UniqueResult <AppointmentEN>(); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMAppointmentRESTCAD.", ex); } finally { SessionClose(); } return(result); }
public HttpResponseMessage ReadOID(int idAppointment) { // CAD, CEN, EN, returnValue AppointmentRESTCAD appointmentRESTCAD = null; AppointmentCEN appointmentCEN = null; AppointmentEN appointmentEN = null; AppointmentDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); appointmentRESTCAD = new AppointmentRESTCAD(session); appointmentCEN = new AppointmentCEN(appointmentRESTCAD); // Data appointmentEN = appointmentCEN.ReadOID(idAppointment); // Convert return if (appointmentEN != null) { returnValue = AppointmentAssembler.Convert(appointmentEN, 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)); } }