Пример #1
0
        public HttpResponseMessage Post(Detalle_Suscripciones_Paciente varDetalle_Suscripciones_Paciente)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varDetalle_Suscripciones_Paciente));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Пример #2
0
        public HttpResponseMessage Delete(int id)
        {
            Detalle_Suscripciones_Paciente varDetalle_Suscripciones_Paciente = this.service.GetByKey(id, false);
            bool result = false;

            if (varDetalle_Suscripciones_Paciente == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Пример #3
0
        public HttpResponseMessage PutTunnel(Detalle_Suscripciones_Paciente emp, string user, string password)
        {
            var client = new System.Net.WebClient();

            client.Headers = TokenManager.GetAuthenticationHeader(user, password);
            client.Headers["Content-Type"] = "application/json";
            var dataString = new JavaScriptSerializer().Serialize(emp);

            var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Folio), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Пример #4
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Detalle_Suscripciones_Paciente entity = this.service.ListaSelAll(1, 1, "Detalle_Suscripciones_Paciente.Folio='" + id.ToString() + "'", "").Detalle_Suscripciones_Pacientes.First();
            Detalle_Suscripciones_Paciente result = new Detalle_Suscripciones_Paciente();

            result.Folio       = entity.Folio;
            result.Suscripcion = entity.Suscripcion;
            result.Suscripcion_Planes_de_Suscripcion = entity.Suscripcion_Planes_de_Suscripcion;
            result.Fecha_de_inicio          = entity.Fecha_de_inicio;
            result.Fecha_fin                = entity.Fecha_fin;
            result.Nombre_de_la_Suscripcion = entity.Nombre_de_la_Suscripcion;
            result.Frecuencia_de_Pago       = entity.Frecuencia_de_Pago;
            result.Frecuencia_de_Pago_Frecuencia_de_pago_Pacientes = entity.Frecuencia_de_Pago_Frecuencia_de_pago_Pacientes;
            result.Costo   = entity.Costo;
            result.Estatus = entity.Estatus;
            result.Estatus_Estatus_de_Suscripcion = entity.Estatus_Estatus_de_Suscripcion;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Пример #5
0
        public HttpResponseMessage Put_Datos_Generales(Detalle_Suscripciones_Paciente varDetalle_Suscripciones_Paciente_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varDetalle_Suscripciones_Paciente_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Suscripciones_Paciente_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Suscripciones_Paciente_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Suscripciones_Paciente", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente_Datos_Generales), false, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Пример #6
0
        public HttpResponseMessage Detalle_Suscripciones_PacienteGenerateID()
        {
            Detalle_Suscripciones_Paciente varDetalle_Suscripciones_Paciente = new Detalle_Suscripciones_Paciente();
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varDetalle_Suscripciones_Paciente));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_Detalle_Suscripciones_PacienteGenerateID", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_Detalle_Suscripciones_PacienteGenerateID", new JavaScriptSerializer().Serialize(varDetalle_Suscripciones_Paciente), true);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public ActionResult Post(bool IsNew, Detalle_Suscripciones_PacienteModel varDetalle_Suscripciones_Paciente)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Suscripciones_PacienteApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Suscripciones_PacienteInfo = new Detalle_Suscripciones_Paciente
                    {
                        Folio                      = varDetalle_Suscripciones_Paciente.Folio
                        , Suscripcion              = varDetalle_Suscripciones_Paciente.Suscripcion
                        , Fecha_de_inicio          = (!String.IsNullOrEmpty(varDetalle_Suscripciones_Paciente.Fecha_de_inicio)) ? DateTime.ParseExact(varDetalle_Suscripciones_Paciente.Fecha_de_inicio, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null
                        , Fecha_fin                = (!String.IsNullOrEmpty(varDetalle_Suscripciones_Paciente.Fecha_fin)) ? DateTime.ParseExact(varDetalle_Suscripciones_Paciente.Fecha_fin, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null
                        , Nombre_de_la_Suscripcion = varDetalle_Suscripciones_Paciente.Nombre_de_la_Suscripcion
                        , Frecuencia_de_Pago       = varDetalle_Suscripciones_Paciente.Frecuencia_de_Pago
                        , Costo                    = varDetalle_Suscripciones_Paciente.Costo
                        , Estatus                  = varDetalle_Suscripciones_Paciente.Estatus
                    };

                    result = !IsNew?
                             _IDetalle_Suscripciones_PacienteApiConsumer.Update(Detalle_Suscripciones_PacienteInfo, null, null).Resource.ToString() :
                                 _IDetalle_Suscripciones_PacienteApiConsumer.Insert(Detalle_Suscripciones_PacienteInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_Suscripciones_PacienteApiConsumer.SetAuthHeader(_tokenManager.Token);

                Detalle_Suscripciones_Paciente varDetalle_Suscripciones_Paciente = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _IDetalle_Suscripciones_PacienteApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }