Пример #1
0
        public ActionResult Create(short Id = 0, int consult = 0)
        {
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 150);

            ViewBag.Permission = permission;
            var varSpartan_BR_Status = new Spartan_BR_StatusModel();



            if (Convert.ToString(Id) != "0" && Convert.ToString(Id) != "-1")
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_StatusApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_BR_StatusData = _ISpartan_BR_StatusApiConsumer.GetByKeyComplete(Id).Resource.Spartan_BR_Statuss[0];
                if (Spartan_BR_StatusData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_BR_Status = new Spartan_BR_StatusModel
                {
                    StatusId      = Spartan_BR_StatusData.StatusId
                    , Description = Spartan_BR_StatusData.Description
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            return(View(varSpartan_BR_Status));
        }
Пример #2
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, 35398);

            ViewBag.Permission = permission;
            var varSpartan_BR_History = new Spartan_BR_HistoryModel();

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

                varSpartan_BR_History = new Spartan_BR_HistoryModel
                {
                    Key_History              = (int)Spartan_BR_HistoryData.Key_History
                    , User_logged            = Spartan_BR_HistoryData.User_logged
                    , User_loggedName        = (string)Spartan_BR_HistoryData.User_logged_Spartan_User.Name
                    , Status                 = Spartan_BR_HistoryData.Status
                    , StatusDescription      = (string)Spartan_BR_HistoryData.Status_Spartan_BR_Status.Description
                    , Change_Date            = (Spartan_BR_HistoryData.Change_Date == null ? string.Empty : Convert.ToDateTime(Spartan_BR_HistoryData.Change_Date).ToString(ConfigurationProperty.DateFormat))
                    , Hour_Date              = Spartan_BR_HistoryData.Hour_Date
                    , Time_elapsed           = Spartan_BR_HistoryData.Time_elapsed
                    , Change_Type            = Spartan_BR_HistoryData.Change_Type
                    , Change_TypeDescription = (string)Spartan_BR_HistoryData.Change_Type_Spartan_BR_Type_History.Description
                    , Conditions             = Spartan_BR_HistoryData.Conditions
                    , Actions_True           = Spartan_BR_HistoryData.Actions_True
                    , Actions_False          = Spartan_BR_HistoryData.Actions_False
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_UserApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Users_User_logged = _ISpartan_UserApiConsumer.SelAll(true);

            if (Spartan_Users_User_logged != null && Spartan_Users_User_logged.Resource != null)
            {
                ViewBag.Spartan_Users_User_logged = Spartan_Users_User_logged.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.Id_User)
                }).ToList();
            }
            _ISpartan_BR_StatusApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_BR_Statuss_Status = _ISpartan_BR_StatusApiConsumer.SelAll(true);

            if (Spartan_BR_Statuss_Status != null && Spartan_BR_Statuss_Status.Resource != null)
            {
                ViewBag.Spartan_BR_Statuss_Status = Spartan_BR_Statuss_Status.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.StatusId)
                }).ToList();
            }
            _ISpartan_BR_Type_HistoryApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_BR_Type_Historys_Change_Type = _ISpartan_BR_Type_HistoryApiConsumer.SelAll(true);

            if (Spartan_BR_Type_Historys_Change_Type != null && Spartan_BR_Type_Historys_Change_Type.Resource != null)
            {
                ViewBag.Spartan_BR_Type_Historys_Change_Type = Spartan_BR_Type_Historys_Change_Type.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.Key_Type_History)
                }).ToList();
            }


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