public async void RegisterParticipantAsync_WhenCodeIsInvalid_ReturnsError() { // TODO: nu merge cu expresii exacte (x => x.SecretCode == "code") _eventRepositoryMock.Setup(x => x.GetAsync(It.IsAny <Expression <Func <Event, bool> > >(), It.IsAny <Expression <Func <Event, object> > >())) .ReturnsAsync(() => new List <Event>()); var result = await _participantsService.RegisterParticipantAsync("code", ""); result.Type.ShouldBe(ResultStatusType.AlreadyExists); }
public async Task <IActionResult> Join(JoinEventViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await _participantsService.RegisterParticipantAsync(model.Code, User.GetNameIdentifier()); if (result.Type != ResultStatusType.Ok) { AddModelErrors(result); return(View(model)); } return(RedirectToAction(nameof(EventsController.Details), "Events", new { Id = result.Object })); }