Esempio n. 1
0
        public ActionResult <StatisticsViewModel <IEnumerable <BuyOfferViewModel> > > GetBuyOffers(int id)
        {
            var statisticsDto = new StatisticsDTO();
            var userDto       = _userService.GetUserById(id, statisticsDto);

            if (userDto == null)
            {
                return(NotFound(statisticsDto));
            }

            var buyOffersDto = _buyOfferService.GetByUserId(userDto.Id, statisticsDto);
            var statistics   = Mapper.Map <StatisticsViewModel <IEnumerable <BuyOfferViewModel> > >(statisticsDto);

            statistics.Data = buyOffersDto.Select(p => Mapper.Map <BuyOfferViewModel>(p)).ToList();

            return(statistics);
        }
Esempio n. 2
0
        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);
        }