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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
示例#3
0
        public ActionResult Post(bool IsNew, Detalle_Preferencia_BebidasModel varDetalle_Preferencia_Bebidas)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Preferencia_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Preferencia_BebidasInfo = new Detalle_Preferencia_Bebidas
                    {
                        Folio      = varDetalle_Preferencia_Bebidas.Folio
                        , Bebida   = varDetalle_Preferencia_Bebidas.Bebida
                        , Cantidad = varDetalle_Preferencia_Bebidas.Cantidad
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public HttpResponseMessage PutTunnel(Detalle_Preferencia_Bebidas 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 Get_Datos_Generales(int id)
        {
            Detalle_Preferencia_Bebidas entity = this.service.ListaSelAll(1, 1, "Detalle_Preferencia_Bebidas.Folio='" + id.ToString() + "'", "").Detalle_Preferencia_Bebidass.First();
            Detalle_Preferencia_Bebidas result = new Detalle_Preferencia_Bebidas();

            result.Folio          = entity.Folio;
            result.Bebida         = entity.Bebida;
            result.Bebida_Bebidas = entity.Bebida_Bebidas;
            result.Cantidad       = entity.Cantidad;
            result.Cantidad_Rango_Consumo_Bebidas = entity.Cantidad_Rango_Consumo_Bebidas;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
示例#6
0
        public HttpResponseMessage Put_Datos_Generales(Detalle_Preferencia_Bebidas varDetalle_Preferencia_Bebidas_Datos_Generales)
        {
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
示例#7
0
        public HttpResponseMessage Detalle_Preferencia_BebidasGenerateID()
        {
            Detalle_Preferencia_Bebidas varDetalle_Preferencia_Bebidas = new Detalle_Preferencia_Bebidas();
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
示例#8
0
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_Preferencia_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token);

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