Esempio n. 1
0
        public List <BLLLot> GetLotsByTabName(string tabName, string currentUserEmail)
        {
            List <BLLLot> lots;

            if (tabName == TabNameMyLots)
            {
                lots = _crudLotService.GetAllLotsOfUser(currentUserEmail).ToList();
            }
            else if (tabName == TabNameMyRates)
            {
                var userId = _crudUserService.GetUserByEmail(currentUserEmail).Id;
                lots = _crudLotService.GetAllLots()
                       .Where(l => l.UsersLotsRates.Any(ulr => ulr.UserId == userId) &&
                              l.LotIsFinishedAuction == false).ToList();
            }
            else if (tabName == TabNameMyWinsLots)
            {
                var userId = _crudUserService.GetUserByEmail(currentUserEmail).Id;
                lots = _crudLotService.GetAllLots().Where(l => l.CurrentBuyerId == userId &&
                                                          l.LotIsFinishedAuction).ToList();
            }
            else
            {
                lots = _crudLotService.GetAllLots().Where(l => l.LotIsFinishedAuction == false).ToList();
            }

            return(lots);
        }
Esempio n. 2
0
        public ActionResult UsersEdit(int id)
        {
            var currentUserId        = _crudUserService.GetUserByEmail(User.Identity.Name).Id;
            var user                 = _crudUserService.GetUserById(id);
            var allHisLots           = _crudLotService.GetAllLotsOfUser(id).ToList();
            var countOfLotsSold      = allHisLots.Where(l => l.LotIsFinishedAuction && l.CurrentBuyerId != 0).ToList().Count;
            var countOfLotsWithRates = allHisLots.Where(l => l.LotIsFinishedAuction == false && l.CurrentBuyerId != 0).ToList().Count;

            var isBanned = _crudUserService.GetBannedUsers().Any(r => r.Id == id);
            var userEdit = new UserEditModel
            {
                Id                 = id,
                CurrentUserId      = currentUserId,
                UserName           = user.UserName,
                Email              = user.Email,
                CreationDate       = user.CreationDate,
                Lots               = allHisLots,
                CountLotsSold      = countOfLotsSold,
                CountOfRatesOnLots = countOfLotsWithRates,
                IsBanned           = isBanned
            };

            return(View(userEdit));
        }