Exemplo n.º 1
0
        public HttpResponseMessage Destroy(int p_patientprofile_oid)
        {
            // CAD, CEN
            PatientProfileRESTCAD patientProfileRESTCAD = null;
            PatientProfileCEN     patientProfileCEN     = null;

            try
            {
                SessionInitializeTransaction();


                patientProfileRESTCAD = new PatientProfileRESTCAD(session);
                patientProfileCEN     = new PatientProfileCEN(patientProfileRESTCAD);

                patientProfileCEN.Destroy(p_patientprofile_oid);
                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 204 - No Content
            return(this.Request.CreateResponse(HttpStatusCode.NoContent));
        }