public void IfInvalidRequest() { var command = new AcceptInvitationCommand(); var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
public async Task HandleAsync(AcceptInvitationCommand message) { var invitation = await this.domainRepository.GetByKeyAsync <Guid, Invitation>(message.InvitationId); var user = await this.domainRepository.GetByKeyAsync <Guid, User>(message.UserId); user.ApproveInvitation(invitation); await this.domainRepository.SaveAsync <Guid, User>(user); }
public async Task Initialize() { IsBusy = true; BandInvitations.ReplaceRange(await App.Database.GetUserBandInvitations(DependencyService .Resolve <IAuthenticationService>() .GetCurrentUserId())); IsBusy = false; AcceptInvitationCommand.RaiseCanExecuteChanged(); DenyInvitationCommand.RaiseCanExecuteChanged(); }
private async Task DenyInvitation(Invitation arg) { IsBusy = true; AcceptInvitationCommand.RaiseCanExecuteChanged(); DenyInvitationCommand.RaiseCanExecuteChanged(); await App.Database.RemoveInvitation(arg); await Shell.Current.CurrentPage.DisplayToastAsync("Pozvánka odmítnuta!"); await Initialize(); }
public IHttpActionResult AcceptInvitation([FromBody] dynamic model) { var currentUserId = (string)model.CurrentUserId; var invitationId = (string)model.InvitationId; var command = new AcceptInvitationCommand { InvitationId = Guid.Parse(invitationId), UserId = Guid.Parse(currentUserId) }; this.CommandSender.Publish(command); return(Ok()); }
public void IfUserEmailNotFound() { _invitationRepository.Setup(x => x.Get(_invitation.Id)).ReturnsAsync(_invitation); _userAccountRepository.Setup(x => x.Get(_invitation.Email)).ReturnsAsync(null); var command = new AcceptInvitationCommand { Id = _invitation.Id }; var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
public void IfHasExpired() { _invitation.ExpiryDate = DateTimeProvider.Current.UtcNow.AddDays(-2); _invitationRepository.Setup(x => x.Get(_invitation.Id)).ReturnsAsync(_invitation); var command = new AcceptInvitationCommand { Id = _invitation.Id }; var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
public void IfStatusIsNotPending() { _invitation.Status = InvitationStatus.Accepted; _invitationRepository.Setup(x => x.Get(_invitation.Id)).ReturnsAsync(_invitation); var command = new AcceptInvitationCommand { Id = _invitation.Id }; var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
public void IfNotExists() { const long invitationId = 1; _invitationRepository.Setup(x => x.Get(invitationId)).ReturnsAsync(null); var command = new AcceptInvitationCommand { Id = _invitation.Id }; var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
public void IfAlreadyAMember() { _invitationRepository.Setup(x => x.Get(_invitation.Id)).ReturnsAsync(_invitation); _userAccountRepository.Setup(x => x.Get(_invitation.Email)).ReturnsAsync(new User()); _membershipRepository.Setup(x => x.GetCaller(It.IsAny <long>(), It.IsAny <string>())).ReturnsAsync(new MembershipView()); var command = new AcceptInvitationCommand { Id = _invitation.Id }; var exception = Assert.ThrowsAsync <InvalidRequestException>(() => _handler.Handle(command)); Assert.That(exception.ErrorMessages.Count, Is.EqualTo(1)); }
private async Task AcceptInvitation(Invitation arg) { IsBusy = true; AcceptInvitationCommand.RaiseCanExecuteChanged(); DenyInvitationCommand.RaiseCanExecuteChanged(); var bandMusician = new BandMusicians { BandId = arg.ToBandId, MusicianId = DependencyService.Resolve <IAuthenticationService>().GetCurrentUserId(), TimeStamp = DateTime.Now }; await App.Database.AddBandMember(bandMusician); await App.Database.RemoveInvitation(arg); await Shell.Current.CurrentPage.DisplayToastAsync("Pozvánka úspěšně přijata!"); await Initialize(); }