public async Task <ActionResult <LotModel> > Get(int id) { var lot = await _lotService.GetLotById(id); var result = _mapper.Map <LotModel>(lot); return(Ok(result)); }
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; } }
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)); } }
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")); }