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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
示例#3
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Interpretacion_Calorias entity = this.service.ListaSelAll(1, 1, "Interpretacion_Calorias.Folio='" + id.ToString() + "'", "").Interpretacion_Caloriass.First();
            Interpretacion_Calorias result = new Interpretacion_Calorias();

            result.Folio       = entity.Folio;
            result.Descripcion = entity.Descripcion;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
示例#4
0
        public HttpResponseMessage PutTunnel(Interpretacion_Calorias 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));
        }
示例#5
0
        public HttpResponseMessage Put_Datos_Generales(Interpretacion_Calorias varInterpretacion_Calorias_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varInterpretacion_Calorias_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varInterpretacion_Calorias_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdInterpretacion_Calorias", new JavaScriptSerializer().Serialize(varInterpretacion_Calorias_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varInterpretacion_Calorias_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdInterpretacion_Calorias", new JavaScriptSerializer().Serialize(varInterpretacion_Calorias_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 Interpretacion_CaloriasGenerateID()
        {
            Interpretacion_Calorias varInterpretacion_Calorias = new Interpretacion_Calorias();
            var data = "-1";

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

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