예제 #1
0
        public async Task <IActionResult> UpdateEmailAccount([FromBody] EmailAccount UpdateEmailAccount)
        {
            var Response = new SingleResponse <EmailAccount>();

            try
            {
                int result = await _IEmailAccountRepository.UpdateEmailAccountAsync(UpdateEmailAccount);

                if (result == 0)
                {
                    Response.DidError = true;
                    Response.Message  = $"The Account with the id: {UpdateEmailAccount.EmailAccountId} was not found in the database.";
                    _Logger.LogError(ControllerContext, Response.Message);
                }
                else
                {
                    Response.Message = $"{UpdateEmailAccount.EmailAccountId}";
                    Response.Model   = UpdateEmailAccount;
                    _Logger.LogInfo(ControllerContext, $"EmailAccount with the id: {UpdateEmailAccount.EmailAccountId} has been updated.");
                }
            }
            catch (Exception ex)
            {
                Response.DidError = true;
                Response.Message  = "Internal Server Error.";
                _Logger.LogError(ControllerContext, $"Error Message: {ex.Message}");
            }
            return(Response.ToHttpResponse());
        }