Exemplo n.º 1
0
        public async Task <IActionResult> DeleteEmailAccountId(int id)
        {
            var Response = new SingleResponse <EmailAccount>();

            try
            {
                if (!_IEmailAccountRepository.DoesEmailAccountExist(id))
                {
                    Response.DidError = true;
                    Response.Message  = $"The EmailAccount with the id: {id} was not found in the database.";
                    _Logger.LogError(ControllerContext, Response.Message);
                }
                else
                {
                    EmailAccount EmailAccountToDelete = await _IEmailAccountRepository.GetEmailAccountByIdDefaultAsync(id);

                    await _IEmailAccountRepository.DeleteEmailAccountAsync(EmailAccountToDelete);

                    Response.Message = $"{EmailAccountToDelete.EmailAccountId}";
                    Response.Model   = EmailAccountToDelete;
                    _Logger.LogInfo(ControllerContext, $"EmailAccount with the id: {EmailAccountToDelete.EmailAccountId} has been deleted.");
                }
            }
            catch (Exception ex)
            {
                Response.DidError = true;
                Response.Message  = "Internal Server Error.";
                _Logger.LogError(ControllerContext, $"Error Message: {ex.Message}");
            }
            return(Response.ToHttpResponse());
        }