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)); }
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)); }
public void LoadRolesDropdownList(AgentRoles model) { model.RolesList = ApplicationUtilities.SetDDLValue(LoadDropdownList("userRole"), model.RoleId, "--Select Role--"); }