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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Пример #3
0
        public HttpResponseMessage PutTunnel(MR_Detalle_Platillo 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)
        {
            MR_Detalle_Platillo entity = this.service.ListaSelAll(1, 1, "MR_Detalle_Platillo.Folio='" + id.ToString() + "'", "").MR_Detalle_Platillos.First();
            MR_Detalle_Platillo result = new MR_Detalle_Platillo();

            result.Folio       = entity.Folio;
            result.Ingrediente = entity.Ingrediente;
            result.Ingrediente_Ingredientes = entity.Ingrediente_Ingredientes;
            result.Cantidad             = entity.Cantidad;
            result.Cantidad_en_Fraccion = entity.Cantidad_en_Fraccion;
            result.Unidad = entity.Unidad;
            result.Unidad_Unidades_de_Medida = entity.Unidad_Unidades_de_Medida;
            result.Cantidad_a_mostrar        = entity.Cantidad_a_mostrar;
            result.Ingrediente_a_mostrar     = entity.Ingrediente_a_mostrar;

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

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varMR_Detalle_Platillo_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMR_Detalle_Platillo_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMR_Detalle_Platillo", new JavaScriptSerializer().Serialize(varMR_Detalle_Platillo_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMR_Detalle_Platillo_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMR_Detalle_Platillo", new JavaScriptSerializer().Serialize(varMR_Detalle_Platillo_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 MR_Detalle_PlatilloGenerateID()
        {
            MR_Detalle_Platillo varMR_Detalle_Platillo = new MR_Detalle_Platillo();
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varMR_Detalle_Platillo));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MR_Detalle_PlatilloGenerateID", new JavaScriptSerializer().Serialize(varMR_Detalle_Platillo), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MR_Detalle_PlatilloGenerateID", new JavaScriptSerializer().Serialize(varMR_Detalle_Platillo), 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, MR_Detalle_PlatilloModel varMR_Detalle_Platillo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMR_Detalle_PlatilloApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MR_Detalle_PlatilloInfo = new MR_Detalle_Platillo
                    {
                        Folio                   = varMR_Detalle_Platillo.Folio
                        , Ingrediente           = varMR_Detalle_Platillo.Ingrediente
                        , Cantidad              = varMR_Detalle_Platillo.Cantidad
                        , Cantidad_en_Fraccion  = varMR_Detalle_Platillo.Cantidad_en_Fraccion
                        , Unidad                = varMR_Detalle_Platillo.Unidad
                        , Cantidad_a_mostrar    = varMR_Detalle_Platillo.Cantidad_a_mostrar
                        , Ingrediente_a_mostrar = varMR_Detalle_Platillo.Ingrediente_a_mostrar
                    };

                    result = !IsNew?
                             _IMR_Detalle_PlatilloApiConsumer.Update(MR_Detalle_PlatilloInfo, null, null).Resource.ToString() :
                                 _IMR_Detalle_PlatilloApiConsumer.Insert(MR_Detalle_PlatilloInfo, 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));
                }
                _IMR_Detalle_PlatilloApiConsumer.SetAuthHeader(_tokenManager.Token);

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