public async Task Init() { OfferList.Clear(); var id = int.Parse(JWTService.DecodeJWT()); var search = new Model.Requests.OfferSearchRequest { UserId = id }; var offerList = await _offerService.GetAll <List <Offer> >(search); OfferList.Clear(); foreach (var item in offerList) { var request = await _requestService.GetById <Request>(item.RequestId); var address = await _addressService.GetById <Address>(request.DeliveryAddress); var status = await _offerStatusService.GetById <Model.OfferStatus>(item.OfferStatusId); var offer = new MyOffers { Address = address.City, IsActive = item.OfferStatusId == (int)Models.OfferStatus.Active, IsRejected = item.OfferStatusId == (int)Models.OfferStatus.Rejected, IsAccepted = item.OfferStatusId == (int)Models.OfferStatus.Accepted, IsFinished = item.OfferStatusId == (int)Models.OfferStatus.Finished, OfferId = item.OfferId, Price = request.Price, RequestId = item.RequestId, OfferStatus = status.Name }; OfferList.Add(offer); } }
/// <summary> /// Converts a collection of Trades to the corresponding collection of view models. /// </summary> /// <param name="trades">The trades.</param> /// <param name="currentUserId">The current user identifier.</param> /// <returns>A collection of <see cref="TradeGalleryViewModel"/></returns> private IEnumerable <TradeGalleryViewModel> ToTradeGalleryViewModels( IEnumerable <Trade> trades, string currentUserId) { return(trades.Select( t => new TradeGalleryViewModel(t, currentUserId, MyOffers.Contains(t))).ToList()); }