コード例 #1
0
        public ActionResult AssignRole(string AgentId, string UserId = "")
        {
            AgentManagementCommon amc = new AgentManagementCommon();
            var agent_id = AgentId.DecryptParameter();
            var user_id  = UserId.DecryptParameter();

            if (string.IsNullOrEmpty(agent_id))
            {
                return(RedirectToAction("Index"));
            }
            if (!string.IsNullOrEmpty(UserId))
            {
                if (string.IsNullOrEmpty(user_id))
                {
                    return(RedirectToAction("ViewAgentUser", new { AgentId = agent_id.EncryptParameter() }));
                }
            }

            amc.ActionUser = Session["UserName"].ToString();
            amc.UserID     = user_id;
            amc.AgentID    = agent_id;

            var arole = buss.getAgentUserRO(amc);

            if (arole != null)
            {
                AgentUserRole aur = new AgentUserRole();
                aur.AgentID   = arole.AgentID.EncryptParameter();
                aur.UserID    = arole.UserID.EncryptParameter();
                aur.RoleId    = arole.RoleId;
                aur.IsPrimary = arole.IsPrimary;
                return(View(aur));
            }
            return(RedirectToAction("ViewAgentUser", new { AgentId = agent_id.EncryptParameter() }));
        }
コード例 #2
0
        public ActionResult AssignRole(AgentUserRole dcommon)
        {
            var agent_id = dcommon.AgentID.DecryptParameter();
            var user_id  = dcommon.UserID.DecryptParameter();

            if (string.IsNullOrEmpty(agent_id))
            {
                return(RedirectToAction("Index"));
            }
            if (!string.IsNullOrEmpty(dcommon.UserID))
            {
                if (string.IsNullOrEmpty(user_id))
                {
                    return(RedirectToAction("ViewAgentUser", new { AgentId = agent_id.EncryptParameter() }));
                }
            }
            if (ModelState.IsValid)
            {
                var isPrimary = "n";
                if (dcommon.IsPrimary == "on")
                {
                    isPrimary = "y";
                }
                AgentManagementCommon amc = new AgentManagementCommon();
                amc.UserName  = Session["UserName"].ToString();
                amc.UserID    = user_id;
                amc.AgentID   = agent_id;
                amc.IsPrimary = isPrimary;
                amc.RoleId    = dcommon.RoleId;
                CommonDbResponse dbresp = buss.AssignAgentUserRole(amc);
                if (dbresp.Code == 0)
                {
                    this.ShowPopup(0, "Role Assigned Successfully.");
                    return(RedirectToAction("ViewAgentUser", new { AgentId = agent_id.EncryptParameter() }));
                }
            }
            this.ShowPopup(1, "Failed to assign role to user!");
            return(View(dcommon));
        }