Exemplo n.º 1
0
        public ActionResult AddUser()
        {
            try
            {
                string userType = Convert.ToString(Session["UserTypeID"]);

                string UserCenterType = Convert.ToString(Session["UserCenterType"]);
                if (string.IsNullOrEmpty(userType))
                {
                    return(RedirectToAction("MainIndex", "Login"));
                }

                var ResultData = Common.GetUserRights(userType, "/" + Request.RequestContext.RouteData.Values["Controller"].ToString() + "/" + Request.RequestContext.RouteData.Values["Action"].ToString());
                if (ResultData.Count != 0)
                {
                    List <SpGetRoles_Result> Roles = _loginBuss.GetRoles().ToList();
                    Roles.Insert(0, new SpGetRoles_Result {
                        RoleCode = "0", RoleName = "--Select Role--"
                    });
                    ViewBag.Roles = Roles.Select(m => new SelectListItem()
                    {
                        Text = m.RoleName.ToString(), Value = m.RoleCode.ToString()
                    });

                    List <SpGetStates_Result> States = _loginBuss.GetStates().ToList();
                    States.Insert(0, new SpGetStates_Result {
                        StateCode = "0", StateName = "--Select State--"
                    });
                    ViewBag.States = States.Select(m => new SelectListItem()
                    {
                        Text = m.StateName.ToString(), Value = m.StateCode.ToString()
                    });

                    //Get Center Types
                    List <SPGetCentersType_Result> CenterTypes = _loginBuss.GetCenterTypes(UserCenterType).ToList();
                    ViewBag.CenterType = CenterTypes.Select(m => new SelectListItem()
                    {
                        Text = m.CenterType.ToString(), Value = m.CenterTypeID.ToString()
                    });

                    return(View());
                }
                else
                {
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    return(Content(ex.Message.ToString()));
                }
                else
                {
                    return(Content(ex.InnerException.Message.ToString()));
                }
            }
        }