Exemple #1
0
        public async Task <ActionResult> AddAuction(AddEditAuctionViewModel model)
        {
            await auctionService.PopulateNewAuction(model.Auction);

            model.LoggedInUser = await auctionService.GetCurrentUser();

            model.FullNavList = CreateAuctionAdminNavList();

            if (ModelState.IsValid)
            {
                auctionService.AddAuction(model.Auction);
                TimeSpan offset = model.Auction.EndTime - DateTime.Now.AddSeconds(-1);

                Hangfire.BackgroundJob.Schedule(() => App_Start.TaskRegister.RegisterAuction(model.Auction.AuctionID), offset);
            }
            else
            {
                return(View(model));
            }
            //model.Auction = auctionService.GetAuctionByID(model.Auction.AuctionID);

            return(View("EditAuction", model));
        }
Exemple #2
0
        public ActionResult Add(AuctionViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Add", viewModel));
            }

            var auction = TypeAdapter.Adapt <AuctionViewModel, Auction>(viewModel);

            auction.LastPriceChangeDate = auction.StartDate;
            auction.UserId = User.Identity.GetUserId();

            try
            {
                _auctionService.AddAuction(auction);
                return(Json(new { success = true }));
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(Json(new { success = false }));
            }
        }