public static Auction ToAuction(AuctionAddViewModel viewModel, string sellerId)
        {
            Contract.Requires(viewModel != null);

            return new Auction
            {
                Title        = viewModel.Title,
                Description  = viewModel.Description,
                CreationDate = DateTime.Now,
                EndDate      = DateTime.Now.AddDays(viewModel.DaysToEnd),
                CategoryId   = viewModel.CategoryId,
                MinimumPrice = viewModel.IsBiddingEnabled ? viewModel.MinimumBiddingPrice.ToMoney() : null,
                BuyoutPrice  = viewModel.IsBuyoutEnabled  ? viewModel.BuyoutPrice.ToMoney()         : null,
                PhotoCount   = viewModel.Photos.Count(),
                SellerId     = sellerId
            };
        }
示例#2
0
		public async Task<ActionResult> Add(AuctionAddViewModel input)
		{
			if(!ModelState.IsValid)
			{
				input.AvailableCategories                     = await GetAvailableCategoryList();
				input.MinimumBiddingPrice.AvailableCurrencies = await GetAvailableCurrencyList(input.MinimumBiddingPrice.Currency.Symbol);
				input.BuyoutPrice.AvailableCurrencies         = input.MinimumBiddingPrice.AvailableCurrencies;
				input.MinimumBiddingPrice.Currency            = null; // Prevents the ignoring of Selected property in AvailableCurrencies
				input.BuyoutPrice.Currency                    = null;
				return View(input);
			}

			var newAuction = AuctionAddViewModelMapper.ToAuction(input, sellerId: User.Identity.GetUserId());

			await mAuctionService.AddAuction(newAuction, input.Photos.Select(x => x.InputStream));

			return RedirectToAction("Show", new { id = newAuction.Id });
		}
示例#3
0
		public async Task<ActionResult> Add()
		{
			var viewModel = new AuctionAddViewModel
			{
				AvailableCategories = await GetAvailableCategoryList()
			};

			var currentCultureCurrencySymbol                  = Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol;
			viewModel.MinimumBiddingPrice.AvailableCurrencies = await GetAvailableCurrencyList(currentCultureCurrencySymbol);
			viewModel.BuyoutPrice.AvailableCurrencies         = viewModel.MinimumBiddingPrice.AvailableCurrencies;

			return View(viewModel);
		}