コード例 #1
0
        public async Task <DiscountExtendedDto> GetByIdAsync(Guid id)
        {
            var discount = await _discountRepository.GetByIdAsync(id);

            var vendor = await _vendorRepository.GetByIdAsync(discount.VendorId);

            var discountDto = _mapper.Map <DiscountExtendedDto>(discount);

            discountDto.IsFavorite = await _favoritesService.DiscountIsInFavorites(discountDto.Id);

            discountDto.Links        = _mapper.Map <IEnumerable <LinkDto> >(vendor.Links);
            discountDto.WorkingHours = vendor.WorkingHours;

            discountDto.Phones = _mapper.Map <IEnumerable <PhoneDto> >(vendor.Phones.Join(
                                                                           discount.PhonesIds,
                                                                           p => p.Id,
                                                                           i => i,
                                                                           (p, i) => p));

            return(discountDto);
        }