public ActionResult AssignRole(DistributorRoles dcommon) { var distributor_id = dcommon.AgentId.DecryptParameter(); var user_id = dcommon.UserId.DecryptParameter(); if (string.IsNullOrEmpty(distributor_id)) { return(RedirectToAction("Index")); } if (!string.IsNullOrEmpty(dcommon.UserId)) { if (string.IsNullOrEmpty(user_id)) { return(RedirectToAction("ViewDistributorUser", new { DistId = distributor_id.EncryptParameter() })); } } if (ModelState.IsValid) { var isPrimary = "n"; if (dcommon.IsPrimary == "on") { isPrimary = "y"; } CommonDbResponse dbresp = buss.AssignDistributorRole(distributor_id, user_id, dcommon.RoleId, isPrimary); if (dbresp.Code == 0) { this.ShowPopup(0, "Role Assigned Successfully."); return(RedirectToAction("ViewDistributorUser", new { DistId = distributor_id.EncryptParameter() })); } } this.ShowPopup(1, "Failed to assign role to user!"); return(View(dcommon)); }
public ActionResult AssignRole(string distid, string UserId = "") { DistributorRoles distributormodel = new DistributorRoles(); var distributor_id = distid.DecryptParameter(); var user_id = UserId.DecryptParameter(); if (string.IsNullOrEmpty(distributor_id)) { return(RedirectToAction("Index")); } if (!string.IsNullOrEmpty(UserId)) { if (string.IsNullOrEmpty(user_id)) { return(RedirectToAction("ViewDistributorUser", new { DistId = distributor_id.EncryptParameter() })); } } var dist = _distributor.getDistributorRoleAssigned(distributor_id, user_id); LoadRolesDropdownList(distributormodel); distributormodel.AgentId = distributor_id.EncryptParameter(); distributormodel.UserId = user_id.EncryptParameter(); distributormodel.RoleId = dist.Extra2; distributormodel.IsPrimary = dist.Extra1; return(View(distributormodel)); }
public void LoadRolesDropdownList(DistributorRoles model) { model.RolesList = ApplicationUtilities.SetDDLValue(LoadDropdownList("userRole"), model.RoleId, "--Select Role--"); }