public HttpResponseMessage Post(Rangos_Pediatria_por_Platillos varRangos_Pediatria_por_Platillos)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varRangos_Pediatria_por_Platillos));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsRangos_Pediatria_por_Platillos", new JavaScriptSerializer().Serialize(varRangos_Pediatria_por_Platillos), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsRangos_Pediatria_por_Platillos", new JavaScriptSerializer().Serialize(varRangos_Pediatria_por_Platillos), 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_InsRangos_Pediatria_por_Platillos", new JavaScriptSerializer().Serialize(varRangos_Pediatria_por_Platillos), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            Rangos_Pediatria_por_Platillos varRangos_Pediatria_por_Platillos = this.service.GetByKey(id, false);
            bool result = false;

            if (varRangos_Pediatria_por_Platillos == 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_DelRangos_Pediatria_por_Platillos", new JavaScriptSerializer().Serialize(varRangos_Pediatria_por_Platillos), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelRangos_Pediatria_por_Platillos", new JavaScriptSerializer().Serialize(varRangos_Pediatria_por_Platillos), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public HttpResponseMessage PutTunnel(Rangos_Pediatria_por_Platillos 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));
        }
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Rangos_Pediatria_por_Platillos entity = this.service.ListaSelAll(1, 1, "Rangos_Pediatria_por_Platillos.Folio='" + id.ToString() + "'", "").Rangos_Pediatria_por_Platilloss.First();
            Rangos_Pediatria_por_Platillos result = new Rangos_Pediatria_por_Platillos();

            result.Folio               = entity.Folio;
            result.Nombre_de_rango     = entity.Nombre_de_rango;
            result.Edad_minima         = entity.Edad_minima;
            result.Edad_maxima         = entity.Edad_maxima;
            result.Tiene_padecimientos = entity.Tiene_padecimientos;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage Put_Datos_Generales(Rangos_Pediatria_por_Platillos varRangos_Pediatria_por_Platillos_Datos_Generales)
        {
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage Rangos_Pediatria_por_PlatillosGenerateID()
        {
            Rangos_Pediatria_por_Platillos varRangos_Pediatria_por_Platillos = new Rangos_Pediatria_por_Platillos();
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }