public async Task<ActionResult> ManageNewUsers(NewUsersListViewModel model) { if (!ModelState.IsValid) { return View(model); } var message = new SetUserApprovals( model.Users .Where(u => u.Action.HasValue) .Select(u => new UserApproval(u.UserData.Id, u.Action.Value, u.AssignedRole)) .ToList()); await mediator.SendAsync(message); return RedirectToAction("Index", "Home"); }
public async Task RequestTargetsMissingUser_ReturnsFalseAndDoesNotSave() { userContext.ReturnsId = InternalUserCollection.ThisUserAdminApprovedUserId; var message = new SetUserApprovals(new[] { new UserApproval(Guid.Empty, ApprovalAction.Approve, UserRole.Administrator), new UserApproval(InternalUserCollection.AdminPendingId, ApprovalAction.Approve, UserRole.Administrator) }); var result = await handler.HandleAsync(message); Assert.False(result); Assert.Equal(InternalUserStatus.Pending, getUserStatusFromContext(InternalUserCollection.AdminPendingUserId, context)); }
public async Task <ActionResult> ManageNewUsers(NewUsersListViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var message = new SetUserApprovals( model.Users .Where(u => u.Action.HasValue) .Select(u => new UserApproval(u.UserData.Id, u.Action.Value, u.AssignedRole)) .ToList()); await mediator.SendAsync(message); return(RedirectToAction("Index", "Home")); }
public SetUserApprovalsHandlerTests() { userContext = new TestUserContext(Guid.Empty); context = new TestIwsContext(userContext); context.InternalUsers.AddRange(new InternalUserCollection().Users); var userManager = A.Fake <UserManager <ApplicationUser> >(); handler = new SetUserApprovalsHandler(context, userContext, userManager); approvePendingAdminMessage = new SetUserApprovals(new[] { new UserApproval(InternalUserCollection.AdminPendingId, ApprovalAction.Approve, UserRole.Administrator) }); getUserStatusFromContext = (id, ctxt) => { return(ctxt.InternalUsers.Single(u => u.UserId == id.ToString()).Status); }; }
public SetUserApprovalsHandlerTests() { userContext = new TestUserContext(Guid.Empty); context = new TestIwsContext(userContext); context.InternalUsers.AddRange(new InternalUserCollection().Users); var userManager = A.Fake<UserManager<ApplicationUser>>(); handler = new SetUserApprovalsHandler(context, userContext, userManager); approvePendingAdminMessage = new SetUserApprovals(new[] { new UserApproval(InternalUserCollection.AdminPendingId, ApprovalAction.Approve, UserRole.Administrator) }); getUserStatusFromContext = (id, ctxt) => { return ctxt.InternalUsers.Single(u => u.UserId == id.ToString()).Status; }; }