protected ActionResult ResponsePutPatch() { if (IsValidOperation()) { return(NoContent()); } return(BadRequest(new ValidationProblemDetails(_notifications.GetNotificationsByKey()))); }
public async Task Should_Not_Add_Another_Client_With_Same_ClientId() { var command = ClientViewModelFaker.GenerateSaveClient().Generate(); var firstCall = await _clientAppService.Save(command); var result = await _clientAppService.Save(command); firstCall.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey()); result.Should().BeFalse(becauseArgs: _notifications.GetNotificationsByKey()); }
public async Task <ActionResult <RegisterUserViewModel> > Register([FromBody] RegisterUserViewModel model) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(ModelStateErrorResponseError()); } if (await _reCaptchaService.IsCaptchaEnabled()) { var captchaSucces = await _reCaptchaService.IsCaptchaPassed(); if (!captchaSucces) { await _mediator.RaiseEvent(new DomainNotification("Recatcha", "ReCaptcha failed")); return(BadRequest(new ValidationProblemDetails(_notifications.GetNotificationsByKey()))); } } if (model.ContainsFederationGateway()) { await _userAppService.RegisterWithProvider(model); } else { await _userAppService.Register(model); } model.ClearSensitiveData(); return(ResponsePost("UserData", "Account", null, model)); }
public async Task Should_Save_Email() { var command = EmailFaker.GenerateEmailViewModel().Generate(); var result = await _emailAppService.SaveEmail(command); result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey()); _database.Emails.FirstOrDefault(f => f.Type == command.Type).Should().NotBeNull(); }
protected new IActionResult Response(object result = null) { if (IsValidOperation()) { return(Ok(new { success = true, data = result })); } // https://tools.ietf.org/html/rfc7807 return(BadRequest(new ValidationProblemDetails(_notifications.GetNotificationsByKey()))); }