public async Task <IActionResult> AddEmailAccount([FromBody] EmailAccount NewEmailAccount) { var Response = new SingleResponse <EmailAccount>(); try { await _IEmailAccountRepository.CreateEmailAccountAsync(NewEmailAccount); if (NewEmailAccount.EmailAccountId == 0) { Response.DidError = true; Response.Message = $"The EmailAccount you are trying to add was already found in the database."; _Logger.LogError(ControllerContext, Response.Message); } else { Response.Message = $"{NewEmailAccount.EmailAccountId}"; Response.Model = NewEmailAccount; _Logger.LogInfo(ControllerContext, $"The EmailAccount with the id: {NewEmailAccount.EmailAccountId} was added to the database."); } } catch (Exception ex) { Response.DidError = true; Response.Message = $"Internal Server Error. Error Message: {ex.Message}"; _Logger.LogError(ControllerContext, Response.Message); } return(Response.ToHttpResponse()); }