Пример #1
0
        public async Task <ActionResult <LotModel> > Get(int id)
        {
            var lot = await _lotService.GetLotById(id);

            var result = _mapper.Map <LotModel>(lot);

            return(Ok(result));
        }
Пример #2
0
        protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, EditLotRequirement requirement, int lotId)
        {
            var p = await _lotService.GetLotById(lotId);

            var category = await _categoryService.GetCategoryById(p.CategoryId);

            var auctionId   = category.ParentAuction.Id;
            var canModerate = ModeratorOfAuctionHelper.CanModerateAuction(context.User, auctionId);

            if (canModerate)
            {
                context.Succeed(requirement);
                return;
            }

            var userId = context.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var user   = await _userService.FindByIdAsync(userId);

            var lots = user.Lots.Where(p => p.LotId == lotId).Count();

            if (lots > 0)
            {
                context.Succeed(requirement);
                return;
            }
        }
Пример #3
0
        public ActionResult Details(int id)
        {
            var lot = lotService.GetLotById(id);

            ViewBag.CurrentUserId = HttpContext.User.Identity.GetUserId();

            if (lot.Biddings.Count > 0)
            {
                ViewBag.LastBidderName = userService.GetUserById(lot.Biddings.Last().UserId).Name;
            }

            LotModel lotModel = Mapper.Map <LotModel>(lot);

            if (lot == null)
            {
                return(View("~/Views/Lot/NotFound.cshtml"));
            }
            else
            {
                return(View(lotModel));
            }
        }
Пример #4
0
        public ActionResult Bid(int id)
        {
            var bid = new BidDTO
            {
                Sum    = lotService.GetLotById(id).BidRate,
                UserId = HttpContext.User.Identity.GetUserId(),
                LotId  = id,
                Date   = DateTime.Now
            };

            bidService.MakeBid(bid);

            return(View("AcceptedBid"));
        }