public ActionResult Post(bool IsNew, MS_PadecimientosModel varMS_Padecimientos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_PadecimientosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_PadecimientosInfo = new MS_Padecimientos
                    {
                        Folio       = varMS_Padecimientos.Folio
                        , Categoria = varMS_Padecimientos.Categoria
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AddMS_Padecimientos(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, 44730);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IMS_PadecimientosApiConsumer.SetAuthHeader(_tokenManager.Token);
            MS_PadecimientosModel varMS_Padecimientos = new MS_PadecimientosModel();


            if (id.ToString() != "0")
            {
                var MS_PadecimientossData = _IMS_PadecimientosApiConsumer.ListaSelAll(0, 1000, "MS_Padecimientos.Folio=" + id, "").Resource.MS_Padecimientoss;

                if (MS_PadecimientossData != null && MS_PadecimientossData.Count > 0)
                {
                    var MS_PadecimientosData = MS_PadecimientossData.First();
                    varMS_Padecimientos = new MS_PadecimientosModel
                    {
                        Folio                = MS_PadecimientosData.Folio
                        , Categoria          = MS_PadecimientosData.Categoria
                        , CategoriaCategoria = CultureHelper.GetTraduction(Convert.ToString(MS_PadecimientosData.Categoria), "Categorias_de_platillos") ?? (string)MS_PadecimientosData.Categoria_Categorias_de_platillos.Categoria
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ICategorias_de_platillosApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Categorias_de_platilloss_Categoria = _ICategorias_de_platillosApiConsumer.SelAll(true);

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


            return(PartialView("AddMS_Padecimientos", varMS_Padecimientos));
        }
        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, 44730);

            ViewBag.Permission = permission;
            var varMS_Padecimientos = new MS_PadecimientosModel();

            ViewBag.ObjectId  = "44730";
            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));
                }
                _IMS_PadecimientosApiConsumer.SetAuthHeader(_tokenManager.Token);
                var MS_PadecimientosData = _IMS_PadecimientosApiConsumer.GetByKeyComplete(Id).Resource.MS_Padecimientoss[0];
                if (MS_PadecimientosData == null)
                {
                    return(HttpNotFound());
                }

                varMS_Padecimientos = new MS_PadecimientosModel
                {
                    Folio                = (int)MS_PadecimientosData.Folio
                    , Categoria          = MS_PadecimientosData.Categoria
                    , CategoriaCategoria = CultureHelper.GetTraduction(Convert.ToString(MS_PadecimientosData.Categoria), "Categorias_de_platillos") ?? (string)MS_PadecimientosData.Categoria_Categorias_de_platillos.Categoria
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ICategorias_de_platillosApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Categorias_de_platilloss_Categoria = _ICategorias_de_platillosApiConsumer.SelAll(true);

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


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