public ActionResult AddDetalle_Platillos(int rowIndex = 0, int functionMode = 0, int id = 0)
        {
            int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;

            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44553);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IDetalle_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);
            Detalle_PlatillosModel varDetalle_Platillos = new Detalle_PlatillosModel();


            if (id.ToString() != "0")
            {
                var Detalle_PlatillossData = _IDetalle_PlatillosApiConsumer.ListaSelAll(0, 1000, "Detalle_Platillos.Folio=" + id, "").Resource.Detalle_Platilloss;

                if (Detalle_PlatillossData != null && Detalle_PlatillossData.Count > 0)
                {
                    var Detalle_PlatillosData = Detalle_PlatillossData.First();
                    varDetalle_Platillos = new Detalle_PlatillosModel
                    {
                        Folio         = Detalle_PlatillosData.Folio
                        , Cantidad    = Detalle_PlatillosData.Cantidad
                        , Unidad      = Detalle_PlatillosData.Unidad
                        , Ingrediente = Detalle_PlatillosData.Ingrediente
                        , IngredienteNombre_Ingrediente = CultureHelper.GetTraduction(Convert.ToString(Detalle_PlatillosData.Ingrediente), "Ingredientes") ?? (string)Detalle_PlatillosData.Ingrediente_Ingredientes.Nombre_Ingrediente
                        , Unidad_SMAE        = Detalle_PlatillosData.Unidad_SMAE
                        , Porciones          = Detalle_PlatillosData.Porciones
                        , Texto_para_mostrar = Detalle_PlatillosData.Texto_para_mostrar
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IIngredientesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Ingredientess_Ingrediente = _IIngredientesApiConsumer.SelAll(true);

            if (Ingredientess_Ingrediente != null && Ingredientess_Ingrediente.Resource != null)
            {
                ViewBag.Ingredientess_Ingrediente = Ingredientess_Ingrediente.Resource.Where(m => m.Nombre_Ingrediente != null).OrderBy(m => m.Nombre_Ingrediente).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Ingredientes", "Nombre_Ingrediente") ?? m.Nombre_Ingrediente.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }


            return(PartialView("AddDetalle_Platillos", varDetalle_Platillos));
        }
示例#2
0
        public ActionResult Post(bool IsNew, Detalle_PlatillosModel varDetalle_Platillos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_PlatillosInfo = new Detalle_Platillos
                    {
                        Folio = varDetalle_Platillos.Folio
                        , Lleva_fracciones        = varDetalle_Platillos.Lleva_fracciones
                        , Cantidad                = varDetalle_Platillos.Cantidad
                        , Cantidad_fraccion       = varDetalle_Platillos.Cantidad_fraccion
                        , Unidad                  = varDetalle_Platillos.Unidad
                        , Ingrediente             = varDetalle_Platillos.Ingrediente
                        , Caracteristica          = varDetalle_Platillos.Caracteristica
                        , Unidad_SMAE             = varDetalle_Platillos.Unidad_SMAE
                        , Equivalente_Unidad_SMAE = varDetalle_Platillos.Equivalente_Unidad_SMAE
                        , Porciones               = varDetalle_Platillos.Porciones
                        , Detalle                 = varDetalle_Platillos.Detalle
                        , Detalle_Super           = varDetalle_Platillos.Detalle_Super
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44553);

            ViewBag.Permission = permission;
            var varDetalle_Platillos = new Detalle_PlatillosModel();

            ViewBag.ObjectId  = "44553";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_PlatillosData = _IDetalle_PlatillosApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Platilloss[0];
                if (Detalle_PlatillosData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_Platillos = new Detalle_PlatillosModel
                {
                    Folio = (int)Detalle_PlatillosData.Folio
                    , Lleva_fracciones          = Detalle_PlatillosData.Lleva_fracciones.GetValueOrDefault()
                    , Cantidad                  = Detalle_PlatillosData.Cantidad
                    , Cantidad_fraccion         = Detalle_PlatillosData.Cantidad_fraccion
                    , Cantidad_fraccionCantidad = CultureHelper.GetTraduction(Convert.ToString(Detalle_PlatillosData.Cantidad_fraccion), "Cantidad_fraccion_platillos") ?? (string)Detalle_PlatillosData.Cantidad_fraccion_Cantidad_fraccion_platillos.Cantidad
                    , Unidad      = Detalle_PlatillosData.Unidad
                    , Ingrediente = Detalle_PlatillosData.Ingrediente
                    , IngredienteNombre_Ingrediente = CultureHelper.GetTraduction(Convert.ToString(Detalle_PlatillosData.Ingrediente), "Ingredientes") ?? (string)Detalle_PlatillosData.Ingrediente_Ingredientes.Nombre_Ingrediente
                    , Caracteristica          = Detalle_PlatillosData.Caracteristica
                    , Unidad_SMAE             = Detalle_PlatillosData.Unidad_SMAE
                    , Equivalente_Unidad_SMAE = Detalle_PlatillosData.Equivalente_Unidad_SMAE
                    , Porciones     = Detalle_PlatillosData.Porciones
                    , Detalle       = Detalle_PlatillosData.Detalle
                    , Detalle_Super = Detalle_PlatillosData.Detalle_Super
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ICantidad_fraccion_platillosApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Cantidad_fraccion_platilloss_Cantidad_fraccion = _ICantidad_fraccion_platillosApiConsumer.SelAll(true);

            if (Cantidad_fraccion_platilloss_Cantidad_fraccion != null && Cantidad_fraccion_platilloss_Cantidad_fraccion.Resource != null)
            {
                ViewBag.Cantidad_fraccion_platilloss_Cantidad_fraccion = Cantidad_fraccion_platilloss_Cantidad_fraccion.Resource.Where(m => m.Cantidad != null).OrderBy(m => m.Cantidad).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Folio), "Cantidad_fraccion_platillos", "Cantidad") ?? m.Cantidad.ToString(), Value = Convert.ToString(m.Folio)
                }).ToList();
            }
            _IIngredientesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Ingredientess_Ingrediente = _IIngredientesApiConsumer.SelAll(true);

            if (Ingredientess_Ingrediente != null && Ingredientess_Ingrediente.Resource != null)
            {
                ViewBag.Ingredientess_Ingrediente = Ingredientess_Ingrediente.Resource.Where(m => m.Nombre_Ingrediente != null).OrderBy(m => m.Nombre_Ingrediente).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Ingredientes", "Nombre_Ingrediente") ?? m.Nombre_Ingrediente.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_Platillos));
        }