public static AdaptationTypeRequiredDTOA Convert(AdaptationTypeRequiredEN en, NHibernate.ISession session = null)
        {
            AdaptationTypeRequiredDTOA    dto = null;
            AdaptationTypeRequiredRESTCAD adaptationTypeRequiredRESTCAD = null;
            AdaptationTypeRequiredCEN     adaptationTypeRequiredCEN     = null;
            AdaptationTypeRequiredCP      adaptationTypeRequiredCP      = null;

            if (en != null)
            {
                dto = new AdaptationTypeRequiredDTOA();
                adaptationTypeRequiredRESTCAD = new AdaptationTypeRequiredRESTCAD(session);
                adaptationTypeRequiredCEN     = new AdaptationTypeRequiredCEN(adaptationTypeRequiredRESTCAD);
                adaptationTypeRequiredCP      = new AdaptationTypeRequiredCP(session);



                //
                // Attributes

                dto.Id = en.Id;

                dto.AdaptionRequest = en.AdaptionRequest;


                dto.Description = en.Description;


                //
                // TravesalLink


                //
                // Service
            }

            return(dto);
        }
        public HttpResponseMessage New_([FromBody] AdaptationTypeRequiredDTO dto)
        {
            // CAD, CEN, returnValue, returnOID
            AdaptationTypeRequiredRESTCAD adaptationTypeRequiredRESTCAD = null;
            AdaptationTypeRequiredCEN     adaptationTypeRequiredCEN     = null;
            AdaptationTypeRequiredDTOA    returnValue = null;
            int returnOID = -1;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();


                adaptationTypeRequiredRESTCAD = new AdaptationTypeRequiredRESTCAD(session);
                adaptationTypeRequiredCEN     = new AdaptationTypeRequiredCEN(adaptationTypeRequiredRESTCAD);

                // Create
                returnOID = adaptationTypeRequiredCEN.New_(
                    dto.AdaptionRequest                                                                                  //Atributo Primitivo: p_adaptionRequest
                    , dto.Description                                                                                    //Atributo Primitivo: p_description
                    ,
                    //Atributo OID: p_accessMode
                    // attr.estaRelacionado: true
                    dto.AccessMode_oid                     // association role

                    );
                SessionCommit();

                // Convert return
                returnValue = AdaptationTypeRequiredAssembler.Convert(adaptationTypeRequiredRESTCAD.ReadOIDDefault(returnOID), session);
            }

            catch (Exception e)
            {
                SessionRollBack();

                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 201 - Created
            response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue);

            // Location Header

            /*
             * Dictionary<string, object> routeValues = new Dictionary<string, object>();
             *
             * // TODO: y rolPaths
             * routeValues.Add("id", returnOID);
             *
             * uri = Url.Link("GetOIDAdaptationTypeRequired", routeValues);
             * response.Headers.Location = new Uri(uri);
             */

            return(response);
        }
        public HttpResponseMessage Modify(int idAdaptationTypeRequired, [FromBody] AdaptationTypeRequiredDTO dto)
        {
            // CAD, CEN, returnValue
            AdaptationTypeRequiredRESTCAD adaptationTypeRequiredRESTCAD = null;
            AdaptationTypeRequiredCEN     adaptationTypeRequiredCEN     = null;
            AdaptationTypeRequiredDTOA    returnValue = null;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();


                adaptationTypeRequiredRESTCAD = new AdaptationTypeRequiredRESTCAD(session);
                adaptationTypeRequiredCEN     = new AdaptationTypeRequiredCEN(adaptationTypeRequiredRESTCAD);

                // Modify
                adaptationTypeRequiredCEN.Modify(idAdaptationTypeRequired,
                                                 dto.AdaptionRequest
                                                 ,
                                                 dto.Description
                                                 );

                // Return modified object
                returnValue = AdaptationTypeRequiredAssembler.Convert(adaptationTypeRequiredRESTCAD.ReadOIDDefault(idAdaptationTypeRequired), session);

                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                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
            {
                response = this.Request.CreateResponse(HttpStatusCode.OK, returnValue);

                return(response);
            }
        }
        public HttpResponseMessage ReadOID(int idAdaptationTypeRequired)
        {
            // CAD, CEN, EN, returnValue
            AdaptationTypeRequiredRESTCAD adaptationTypeRequiredRESTCAD = null;
            AdaptationTypeRequiredCEN     adaptationTypeRequiredCEN     = null;
            AdaptationTypeRequiredEN      adaptationTypeRequiredEN      = null;
            AdaptationTypeRequiredDTOA    returnValue = null;

            try
            {
                SessionInitializeWithoutTransaction();


                adaptationTypeRequiredRESTCAD = new AdaptationTypeRequiredRESTCAD(session);
                adaptationTypeRequiredCEN     = new AdaptationTypeRequiredCEN(adaptationTypeRequiredRESTCAD);

                // Data
                adaptationTypeRequiredEN = adaptationTypeRequiredCEN.ReadOID(idAdaptationTypeRequired);

                // Convert return
                if (adaptationTypeRequiredEN != null)
                {
                    returnValue = AdaptationTypeRequiredAssembler.Convert(adaptationTypeRequiredEN, 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));
            }
        }