public ActionResult _StatusList(bool showOnlyLoggedInUsers, string sortOrder = "") { var list = _physician.GetPhysicianStatusDashboard(sortOrder); if (showOnlyLoggedInUsers) { list = list.Where(m => OnlineUserIds.Contains(m.physician.Id)); } var statusList = list.Where(m => m.physician.physician_status != null).Select(m => m.physician.physician_status).Distinct(); ViewBag.OnlineUsers = OnlineUserIds; ViewBag.statusList = statusList.ToList(); ViewBag.defaultStatus = _physicianStatusService.GetDefault(); return(PartialView(list.ToList())); }
private async Task AddUserToRole(MyUserRole model) { var user = await UserManager.FindByIdAsync(model.UserId); model.UserRoleId = Guid.NewGuid().ToString(); //check if same role exists already var prevRoleExists = user.Roles.Where(x => x.UserId == model.UserId && x.RoleId == model.RoleId ).Any(); #region Adding entry in physician table in case of role is physician var role = await RoleManager.FindByNameAsync(UserRoles.Physician.ToDescription()); var physician = _physicianService.GetDetail(model.UserId); // if the user role has been changed from physician to some different role if (role.Id != model.RoleId && physician != null) { user.status_key = null; user.status_change_date = DateTime.Now.ToEST(); user.status_change_date_forAll = DateTime.Now.ToEST(); user.status_change_cas_key = null; UserManager.Update(user); } else if (role.Id == model.RoleId && physician != null) { if (!user.status_key.HasValue) { var defaultStatus = _physicianStatus.GetDefault(); user.status_key = defaultStatus.phs_move_status_key; user.status_change_date = DateTime.Now.ToEST(); user.status_change_date_forAll = DateTime.Now.ToEST(); user.status_change_cas_key = null; UserManager.Update(user); } } #endregion //if not only then add that role if (!prevRoleExists) { user.Roles.Add(model); IdentityResult identityResult = await UserManager.UpdateAsync(user); } }