public ActionResult LotDetails(int id) { var lot = _lotService.GetLotEntity(id).ToLotDetailsViewModel(); lot.Photos = _lotImageService.GetAllLotImageEntities().Where(t => t.LotRefId == id).Select(t => t.Content); var bids = _bidService.GetAllBidEntities().Where(b => b.LotRefId == lot.Id).Select(b => b.ToBidViewModel()).ToList(); if (bids.Count != 0) { lot.Bids = bids; lot.CurrentBid = bids.Max(b => b.BidAmount); } else { lot.CurrentBid = lot.StartingBid; } var sectionId = _categoryService.GetCategoryEntity(lot.CategoryRefId).SectionRefId; var entity = _sectionService.GetAllSectionEntities() .FirstOrDefault(s => s.Id == sectionId); if (entity != null) { lot.ModeratorLogin = entity.ModeratorLogin; } return(View(lot)); }
public ActionResult GetBidsList(string state, int?userId, bool isPartial = false) { IEnumerable <BidViewModel> model; if (User.IsInRole("User")) { userId = _userService.GetUserByEmail(User.Identity.Name).Id; } switch (state) { case ("Current"): model = _bidService.GetAllBidEntitiesForSaleLots().Where(b => b.UserId == userId).Select(b => b.ToMvcBid()); break; case ("All"): default: model = _bidService.GetAllBidEntities().Where(b => b.UserId == userId).Select(b => b.ToMvcBid()); break; } ViewBag.State = state; if (isPartial) { return(PartialView("_GetBidsList", model)); } return(View(model)); }