public async Task <JsonResult> Accept([FromBody] InviteAcceptModel model) { int projectId = model.projectId; int userId = int.Parse(User.Identity.Name); // Проверяем, что есть доступ var linkedProject = _dbContext.GetLinkedProjectForUser(projectId, userId); if (linkedProject == null) { throw new Exception(TextResource.API_YouAreNotInvited); } if (linkedProject.Accepted) { throw new Exception(TextResource.API_InviteAccepted); } linkedProject.Accepted = true; _dbContext.Update(linkedProject); await _dbContext.SaveChangesAsync() .ConfigureAwait(false); return(new JsonResult(new ProjectAcceptResponse { project = linkedProject.Project })); }
public async Task <IActionResult> AcceptInvite(string email, Guid token) { if (email.IsNotEmail() || token.IsEmptyGuid()) { return(RedirectToAccessDenied()); } var request = new UserInviteValidateRequest(token, email); var response = await OrganizationService.ValidateUserInvitation(request); if (response.Status.IsNotSuccess) { return(RedirectToAccessDenied()); } var model = new InviteAcceptModel(); model.FirstName = response.Item.FirstName; model.LastName = response.Item.LastName; model.Token = token; model.Email = email; model.SetInputModelValues(); return(View(model)); }
public async Task AcceptInvite_POST_InvalidModel() { // arrange var model = new InviteAcceptModel(); // act var result = await SystemUnderTest.AcceptInvite(model); // assert AssertInputErrorMessagesOfView(result, model); }
public static InviteAcceptModel GetOrganizationOneUserOneInviteAcceptModel() { var model = new InviteAcceptModel(); model.Token = UidOne; model.Email = OrganizationOneUserOneEmail; model.FirstName = StringOne; model.LastName = StringTwo; model.Password = PasswordTwo; model.ReEnterPassword = PasswordTwo; return(model); }
public async Task <IActionResult> AcceptInvite(InviteAcceptModel model) { if (model.IsNotValid()) { model.SetInputModelValues(); return(View(model)); } var request = new UserAcceptInviteRequest(model.Token, model.Email, model.FirstName, model.LastName, model.Password); var response = await OrganizationService.AcceptInvitation(request); if (response.Status.IsNotSuccess) { model.MapMessages(response); model.SetInputModelValues(); return(View(model)); } return(Redirect("/User/AcceptInviteDone")); }