public async Task <IActionResult> Subscribe([FromBody] SubscribeRequest request) { try { var model = new Subscriber(); model.EmailAddress = request.EmailAddress; if (string.IsNullOrEmpty(request.EmailAddress)) { return(new JsonResult("Email Address must have a value")); } if (!request.EmailAddress.Contains("@")) { return(new JsonResult("Invalid email address")); } await _mongoRepository.CreateSubscriberAsync(request.EmailAddress); return(new JsonResult(true)); } catch (Exception ex) { return(new JsonResult(new PicturesReponse(false) { Message = $"An unknown error occurred while subscribing\r\n{ex}" })); } }