public async Task <Response <int> > Handle(CreateMasterCommand request, CancellationToken cancellationToken)
        {
            if (_masterRepository.IsExistMasterAsync(request.TypeMasters, request.Key).Result)
            {
                throw new ApiException($"Master is allready exist.");
            }
            var master = _mapper.Map <Master>(request);
            await _masterRepository.AddAsync(master);

            var masterUnit = new MasterUnit
            {
                MasterId = master.Id,
                UnitCode = master.UnitCode
            };
            await _masterUnitRepository.AddAsync(masterUnit);

            return(new Response <int>(master.Id));
        }
 private async Task <bool> IsExistMasterAsync(int TypeMaster, string Key, CancellationToken cancellationToken)
 {
     return(await masterRepository.IsExistMasterAsync(TypeMaster, Key));
 }