Esempio n. 1
0
        public ActionResult Create(int id) //auto ID
        {
            User user = UserService.GetUserByEmail(User.Identity.Name);
            Auto auto = user?.Autoes.FirstOrDefault(a => a.ID == id && a.StatusID == 2);

            if (auto == null)
            {
                return(HttpNotFound());
            }

            Auction auction = new Auction()
            {
                AutoID         = auto.ID,
                DateCreated    = DateTime.Now,
                StartPrice     = 0,
                CurrentPrice   = 0,
                PriceUSDSearch = 0,
                PriceUAHSearch = 0,
                CurrencyID     = 1,
                StatusID       = 1, //draft
                Deadline       = DateTime.Now
            };

            AuctionService.Create(auction);
            //string jobID = HangfireService.CreateJobForAuctionDeletion(auction);
            //auction.DeletionJobID = jobID;
            //AuctionService.Edit(auction);

            ViewBag.currencies       = CurrencyService.GetAllAsSelectList();
            ViewBag.recommendedPrice = AuctionService.GetRecommendedPrice(auto.PriceUSD, auto.PriceUAH);

            AuctionCreateVM auctionCreateVM = auction;

            AutoDetailsVM      autoVM        = auto;
            List <AutoPhotoVM> orderedPhotos = autoVM.AutoPhotoes.OrderByDescending(p => p.IsMain).ToList();
            AutoPhotoVM        mainPhoto     = orderedPhotos[0];

            ViewBag.mainPhoto = mainPhoto;

            ViewBag.autoVM = autoVM;

            breadcrumbs.Add("#", Resource.AuctionCreate);
            ViewBag.breadcrumbs = breadcrumbs;

            int limit = 2000;

            int.TryParse(XCarsConfiguration.AutoDescriptionMaxLength, out limit);
            ViewBag.autoDescriptionMaxLength = limit;

            return(View(auctionCreateVM));
        }
Esempio n. 2
0
 public ActionResult <Auction> Create(Auction auction)
 {
     _auctionService.Create(auction);
     return(auction);
 }