improve code async 
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Validation;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tax1402.Application.Interfaces.DataBaseIdentityContexts;
using Tax1402.Common.Dto;
using Tax1402.Domain.Entities;

namespace Tax1402.Application.Services.TaxApiKey.Commands.RemoveTaxApiKeyService
{
    public class RemoveTaxApiKeyService : IRemoveTaxApiKeyService
    {
        private readonly IDataBaseIdentityContext _context;
        private static readonly NLog.Logger nlog = NLog.LogManager.GetCurrentClassLogger();

        public RemoveTaxApiKeyService(IDataBaseIdentityContext context)
        {
            _context = context;
        }
        public async Task<ResultDto<ResulRemoveTaxApiKeyServiceDto>> ExecuteAsync(RequestDeleteTaxApiKeyServiceDto request)
        {
            try
            {

                var resultTaxApiKey = _context.TaxApiKeys
                    .Where(p => p.CustomerId == request.CustomerId)
                .Where(p => p.Id == request.TaxApiKeyId)
                .FirstOrDefault();
                resultTaxApiKey.IsActive = false;
                resultTaxApiKey.DeleteAt = DateTime.Now;

                _context.TaxApiKeys.Update(resultTaxApiKey);

                var result = await _context.SaveChangesAsync();
                if (result >= 1)
                {
                    return new ResultDto<ResulRemoveTaxApiKeyServiceDto>()
                    {
                        Data = new ResulRemoveTaxApiKeyServiceDto() { Id = resultTaxApiKey.Id },
                        IsSuccess = true,
                        Message = " کلید یکتای مالیاتی با موفقیت حذف شد"
                    };
                }
                else
                {
                    nlog.Warn("حذف کلید یکتای مالیاتی با خطا مواجه شد");
                    return new ResultDto<ResulRemoveTaxApiKeyServiceDto>()
                    {
                        IsSuccess = false,
                        Message = "حذف کلید یکتای مالیاتی با خطا مواجه شد"
                    };
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        nlog.Error(message, ex);
                    }
                }
                return new ResultDto<ResulRemoveTaxApiKeyServiceDto>()
                {
                    IsSuccess = false,
                    Message = "حذف کلید یکتای مالیاتی با خطا مواجه شد"
                };
            }

        }
    }
    public interface IRemoveTaxApiKeyService
    {
        Task<ResultDto<ResulRemoveTaxApiKeyServiceDto>> ExecuteAsync(RequestDeleteTaxApiKeyServiceDto requestRemoveTaxApiKeyServiceDto);
    }


    public class RequestDeleteTaxApiKeyServiceDto
    {
        public int TaxApiKeyId { get; set; }
        public string CustomerId { get; set; }


    }

    public class ResulRemoveTaxApiKeyServiceDto
    {
        public int Id { get; set; }
    }
}