public ActionResult <StatisticsViewModel <IEnumerable <SellOfferViewModel> > > GetSellOffers(int id) { var statisticsDto = new StatisticsDTO(); var userDto = _userService.GetUserById(id, statisticsDto); if (userDto == null) { return(NotFound(statisticsDto)); } var sellOffersDto = _sellOfferService.GetByUserId(userDto.Id, statisticsDto); var statistics = Mapper.Map <StatisticsViewModel <IEnumerable <SellOfferViewModel> > >(statisticsDto); statistics.Data = sellOffersDto.Select(p => Mapper.Map <SellOfferViewModel>(p)).ToList(); return(statistics); }
public ActionResult <StatisticsViewModel <ContextViewModel> > Get() { var statisticsDto = new StatisticsDTO(); var currentUserName = User.FindFirst(ClaimTypes.Name).Value; var currentUserDto = _userService.GetUserByName(currentUserName, statisticsDto); var currentUserBuyOffersDto = _buyOfferService.GetByUserId(currentUserDto.Id, statisticsDto); var currentUserSellOffersDto = _sellOfferService.GetByUserId(currentUserDto.Id, statisticsDto); var currentUserShares = _shareService.GetByUserId(currentUserDto.Id, statisticsDto); var statistics = Mapper.Map <StatisticsViewModel <ContextViewModel> >(statisticsDto); statistics.Data = new ContextViewModel { User = Mapper.Map <UserViewModel>(currentUserDto), Shares = currentUserShares.Select(p => Mapper.Map <ShareViewModel>(p)).ToList(), BuyOffers = currentUserBuyOffersDto.Select(p => Mapper.Map <BuyOfferViewModel>(p)).ToList(), SellOffers = currentUserSellOffersDto.Select(p => Mapper.Map <SellOfferViewModel>(p)).ToList() }; return(statistics); }