Beispiel #1
0
        public ActionResult Create(int?id)
        {
            if (UserViewModel == null)
            {
                return(new HttpStatusCodeResult(401));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var lot = _lotService.GetLotEntity(id.Value);

            if (lot.CreatedByUserId == UserViewModel.Id)
            {
                TempData["error"] = "You cannot bid on you own lots!";
                return(RedirectToAction("Details", "Lot", new { id = lot.Id }));
            }
            var vm = new BidViewModel
            {
                LotId = lot.Id,
                Lot   = lot.ToLotViewModel()
            };

            return(View(vm));
        }
        public ActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var lot = _lotService.GetLotEntity(id.Value);

            if (lot == null)
            {
                return(HttpNotFound());
            }
            var lotVM = lot.ToLotViewModel();

            ViewBag.IsAdminOrModerator = false;
            ViewBag.SamePerson         = false;
            if ((UserViewModel == null) || (UserViewModel.Banned))
            {
                ViewBag.AutorizedAndNotBanned = false;
            }
            else
            {
                ViewBag.AutorizedAndNotBanned = true;
                if (lotVM.CreatedByUserId == UserViewModel.Id)
                {
                    ViewBag.SamePerson = true;
                }
                ViewBag.IsAdminOrModerator = _customAuthentication.CheckUserInRoles(UserViewModel.ToUserEntity(),
                                                                                    "Admin,Moderator");
            }

            lotVM.LatestBids = _bidService.GetLatestBidsForLot(id.Value).Select(x => x.ToBidViewModel());
            ViewBag.TopBid   = 0;
            if (lotVM.LatestBids.Any())
            {
                ViewBag.TopBid = lotVM.LatestBids.First().Amount;
            }
            return(View(lotVM));
        }
        public ActionResult EditLot(int id)
        {
            var lot       = _lotService.GetLotEntity(id);
            var sectionId = _categoryService.GetCategoryEntity(lot.CategoryRefId).SectionRefId;
            var sections  = LoadSections();
            var section   =
                _sectionService.GetSectionEntity(_categoryService.GetCategoryEntity(lot.CategoryRefId).SectionRefId);
            var lotViewModel = new LotCreateViewModel()
            {
                Sections           = sections,
                Categories         = LoadCategories(section.SectionName),
                Id                 = lot.Id,
                Name               = lot.LotName,
                SettedSectionName  = _sectionService.GetSectionEntity(sectionId).SectionName,
                Discription        = lot.Discription,
                EndDate            = lot.EndDate,
                SettedCategoryName = lot.CategoryName,
                StartingBid        = lot.StartingBid
            };

            return(View(lotViewModel));
        }
        public ActionResult ManageLotStatus(LotDetailsViewModel viewModel)
        {
            var lot = _lotService.GetLotEntity(viewModel.Id);

            if (!viewModel.IsConfirm)
            {
                lot.IsConfirm = true;
            }
            if (viewModel.IsBlocked)
            {
                lot.IsBlocked   = true;
                lot.BlockReason = viewModel.BlockReason;
            }
            else
            {
                lot.IsBlocked = false;
            }
            _lotService.UpdateLot(lot);

            return(RedirectToAction("LotDetails", "Lot", new { id = lot.Id }));
        }
Beispiel #5
0
        public ViewResult LotDetails(int id)
        {
            LotViewModel model = _lotService.GetLotEntity(id).ToMvcLot();

            return(View(model));
        }