Ejemplo n.º 1
0
        public async Task <Unit> Handle(DeactivateAvailableLocationCommand request, CancellationToken cancellationToken)
        {
            var merchantLocation = await _merchantAddressRepository.GetAsync(request.MerchantCode, request.MerchantAddressCode);

            merchantLocation = merchantLocation.DeactiveAvailableLocations(request.Locations);
            await _merchantAddressRepository.UpdateAsync(merchantLocation);

            return(Unit.Task.Result);
        }
        public async Task <MerchantAddressDto> Handle(UpdateMerchantAddressCommand request, CancellationToken cancellationToken)
        {
            var merchant = await _merchantRepository.GetAsync(request.MerchantCode);

            if (merchant is null)
            {
                throw new MerchantNotFoundException();
            }

            var merchantLocation = await _merchantAddressRepository.GetAsync(request.MerchantCode, request.MerchantAddressCode);

            if (merchantLocation is null)
            {
                throw new ActiveMerchantLocationNotFoundException();
            }

            merchantLocation.Update(request.Name, request.Address, request.City, request.Town, request.District,
                                    request.Location, request.WorkingHours, request.ExtraInfo);
            await _merchantAddressRepository.UpdateAsync(merchantLocation);

            return(_mapper.Map <MerchantAddressDto>(merchantLocation));
        }