private async Task <MailingListModel> GetEmailContentFromEmailURLAsync(MailingListModel model, HttpClient client, string clientId) { _logger.ForContext("Source", typeof(MRContentService).FullName) .ForContext("MethodName", GetActualAsyncMethodName()) .ForContext("UserEmail", model.Email) .ForContext("ClientId", clientId) .Debug("Getting email content for {User}", model.Email); try { var response = await client.GetStringAsync(model.EmailURL).ConfigureAwait(false); model.EmailBody = response; _logger.Information("Request completed for {Url}. {ContentLength}", model.EmailURL, response?.Length); _logger.Verbose("Request completed for {Url} {Content}.", model.EmailURL, response); } catch (Exception ex) { _logger.ForContext("Source", typeof(MRContentService).FullName) .ForContext("MethodName", GetActualAsyncMethodName()) .ForContext("UserEmail", model.Email) .ForContext("ClientId", clientId) .Error(ex, "An exception occured when getting email content for user."); throw; } return(model); }
public IActionResult AddMailingList(MailingListModel mailingListModel) { try { return(Ok(logic.AddNewMailingList(mailingListModel))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }