예제 #1
0
        public ActionResult AssignRole(AgentRoles dcommon)
        {
            var Agent_id = dcommon.AgentId.DecryptParameter();
            var user_id  = dcommon.UserId.DecryptParameter();

            LoadRolesDropdownList(dcommon);
            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";
                }
                CommonDbResponse dbresp = _Agent.AssignAgentRole(Agent_id, user_id, dcommon.RoleId, isPrimary);
                if (dbresp.Code == shared.Models.ResponseCode.Success)
                {
                    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));
        }
예제 #2
0
        public ActionResult AssignRole(string AgentId, string UserId = "")
        {
            AgentRoles Agentmodel = new AgentRoles();
            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() }));
                }
            }
            var dist = _Agent.getAgentRoleAssigned(Agent_id, user_id);

            LoadRolesDropdownList(Agentmodel);
            Agentmodel.AgentId   = Agent_id.EncryptParameter();
            Agentmodel.UserId    = user_id.EncryptParameter();
            Agentmodel.RoleId    = dist.Extra2;
            Agentmodel.IsPrimary = dist.Extra1;
            return(View(Agentmodel));
        }
예제 #3
0
 public void LoadRolesDropdownList(AgentRoles model)
 {
     model.RolesList = ApplicationUtilities.SetDDLValue(LoadDropdownList("userRole"), model.RoleId, "--Select Role--");
 }