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, 44578);

            ViewBag.Permission = permission;
            var varMS_Musculos = new MS_MusculosModel();

            ViewBag.ObjectId  = "44578";
            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_MusculosApiConsumer.SetAuthHeader(_tokenManager.Token);
                var MS_MusculosData = _IMS_MusculosApiConsumer.GetByKeyComplete(Id).Resource.MS_Musculoss[0];
                if (MS_MusculosData == null)
                {
                    return(HttpNotFound());
                }

                varMS_Musculos = new MS_MusculosModel
                {
                    Folio                = (int)MS_MusculosData.Folio
                    , Musculo            = MS_MusculosData.Musculo
                    , MusculoDescripcion = CultureHelper.GetTraduction(Convert.ToString(MS_MusculosData.Musculo), "Musculos") ?? (string)MS_MusculosData.Musculo_Musculos.Descripcion
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IMusculosApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Musculoss_Musculo = _IMusculosApiConsumer.SelAll(true);

            if (Musculoss_Musculo != null && Musculoss_Musculo.Resource != null)
            {
                ViewBag.Musculoss_Musculo = Musculoss_Musculo.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Folio), "Musculos", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Folio)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varMS_Musculos));
        }
Exemple #2
0
        public ActionResult Create(int Id = 0, int consult = 0, int ModuleId = 0)
        {
            if (ModuleId == 0)
            {
                ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            }
            else
            {
                Session["CurrentModuleId"] = ModuleId;
            }
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44576, ModuleId);

            if ((!permission.New && Id.ToString() == "0") || (!permission.Edit && Id.ToString() != "0" && (!permission.Consult && consult == 1)))
            {
                Response.Redirect("~/");
            }
            ViewBag.Permission = permission;
            var varMusculos = new MusculosModel();

            varMusculos.Folio = Id;

            ViewBag.ObjectId  = "44576";
            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";

                _tokenManager.GenerateToken();
                _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                _IMusculosApiConsumer.SetAuthHeader(_tokenManager.Token);
                var MusculossData = _IMusculosApiConsumer.ListaSelAll(0, 1000, "Musculos.Folio=" + Id, "").Resource.Musculoss;

                if (MusculossData != null && MusculossData.Count > 0)
                {
                    var MusculosData = MusculossData.First();
                    varMusculos = new MusculosModel
                    {
                        Folio         = MusculosData.Folio
                        , Descripcion = MusculosData.Descripcion
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



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

            var isPartial     = false;
            var isMR          = false;
            var nameMR        = string.Empty;
            var nameAttribute = string.Empty;

            if (Request.QueryString["isPartial"] != null)
            {
                isPartial = Convert.ToBoolean(Request.QueryString["isPartial"]);
            }

            if (Request.QueryString["isMR"] != null)
            {
                isMR = Convert.ToBoolean(Request.QueryString["isMR"]);
            }

            if (Request.QueryString["nameMR"] != null)
            {
                nameMR = Request.QueryString["nameMR"].ToString();
            }

            if (Request.QueryString["nameAttribute"] != null)
            {
                nameAttribute = Request.QueryString["nameAttribute"].ToString();
            }

            ViewBag.isPartial     = isPartial;
            ViewBag.isMR          = isMR;
            ViewBag.nameMR        = nameMR;
            ViewBag.nameAttribute = nameAttribute;


            return(View(varMusculos));
        }