public ActionResult AssignRoles(int UserType, string Allow, Guid?[] RoleId, string[] Description, int Count) { try { //bool result = false; string strMessage = ""; for (int i = 0; i < Count; i++) { SMIM_UserTypeAccess_ST tb_access = new SMIM_UserTypeAccess_ST(); if (Allow == "Y") { tb_access.Allow = "Y"; tb_access.UserTypeId = UserType; tb_access.UserTypeIdSpecified = true; tb_access.AccessType = "U"; tb_access.Description = Description[i]; tb_access.RoleId = RoleId[i].ToString(); dbUser.InsertUserTypeAccess(tb_access); } else { tb_access = dbUser.getAccessByUserTypeAndRoleId(UserType, RoleId[i].Value).FirstOrDefault(); if (tb_access != null) { dbUser.DeleteUserTypeAccess(tb_access); } } } strMessage = "Roles succesfully assigned."; //result = true; return(Json(new { success = true, response = strMessage })); } catch (Exception ex) { return(Json(new { success = false, response = ex.Message.ToString() })); } }