public async Task <IEnumerable <DiscountDTO> > GetUserSavedDiscountsAsync(LocationModel locationModel, User user) { var location = _userRepository.GetLocation(user.Office.Latitude, user.Office.Longitude, locationModel.Latitude, locationModel.Longitude); var savedDiscounts = await _userRepository.GetSavedDiscountsAsync(user.Id, locationModel.Skip, locationModel.Take); var savedDiscountDTOs = _mapper.Map <DiscountDTO[]>(savedDiscounts); for (int i = 0; i < savedDiscountDTOs.Length; i++) { await _discountService.AddCompositePropertiesToDiscountDTOAsync(user.Id, savedDiscountDTOs[i], location); } return(savedDiscountDTOs); }
public async Task <IEnumerable <DiscountDTO> > GetVendorDiscountsAsync(int id, SortModel sortModel, User user) { var location = _vendorRepository.GetLocation(user.Office.Latitude, user.Office.Longitude, sortModel.Latitude, sortModel.Longitude); var sortBy = _discountRepository.GetSortType(sortModel.SortBy); var discounts = _vendorRepository.GetVendorDiscounts(id); var sortedDiscounts = _discountRepository.SortDiscounts(discounts, sortBy, location); var specifiedAmountDiscounts = await _discountRepository.GetSpecifiedAmountAsync(sortedDiscounts, sortModel.Skip, sortModel.Take); var discountDTOs = _mapper.Map <DiscountDTO[]>(specifiedAmountDiscounts); for (int i = 0; i < discountDTOs.Length; i++) { await _discountSevice.AddCompositePropertiesToDiscountDTOAsync(user.Id, discountDTOs[i], location); } return(discountDTOs); }