コード例 #1
0
        public ActionResult Create()
        {
            LotCreateModel lotModel = new LotCreateModel()
            {
                Description = "asf", MainPicturePath = "asf", Name = "asf", Price = 12
            };

            lotModel.Datas.AddRange(new List <SelectListItem> {
                new SelectListItem()
                {
                    Text = "3 days", Value = "3"
                },
                new SelectListItem()
                {
                    Text = "7 days", Value = "7"
                },
                new SelectListItem()
                {
                    Text = "14 days", Value = "14"
                },
                new SelectListItem()
                {
                    Text = "31 days", Value = "31"
                }
            }
                                    );
            return(View(lotModel));
        }
コード例 #2
0
        public ActionResult CreateLot(LotCreateModel newLot)
        {
            if (ModelState.IsValid == false)
            {
                return(View());
            }

            if (newLot.DateOfAuction < DateTime.Now)
            {
                ModelState.AddModelError("", "Date Of auction should be in future");
                return(View());
            }

            if (newLot.YearOfCreation > DateTime.Now.Year || newLot.YearOfCreation < 0)
            {
                ModelState.AddModelError("", "Year of creation is not correct");
                return(View());
            }

            var user = _crudUserService.GetUserByEmail(User.Identity.Name);

            var createdLot = BuildBllLot(newLot, user.Id);

            _crudLotService.CreateLot(createdLot);
            return(RedirectToAction("Index", "LotManager"));
        }
コード例 #3
0
 public ActionResult Create(LotCreateModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             LotDTO lot = Mapper.Map <LotDTO>(model);
             lotService.Create(User.Identity.GetUserId(), Mapper.Map <LotDTO>(model));
             ModelState.Clear();
         }
         catch (ItemNotExistInDbException)
         {
             return(new HttpStatusCodeResult(400, "Account was removed"));
         }
     }
     return(View(model));
 }
コード例 #4
0
        private BLLLot BuildBllLot(LotCreateModel newLot, int userId)
        {
            var bllLot = new BLLLot
            {
                ArtworkName     = newLot.ArtworkName,
                Author          = newLot.Author,
                Photos          = newLot.Photos,
                ArtworkFormat   = newLot.ArtworkFormat,
                Description     = newLot.Description,
                YearOfCreation  = newLot.YearOfCreation,
                StartingPrice   = newLot.StartingPrice,
                MinimalStepRate = newLot.MinimalStepRate,
                DateOfAuction   = newLot.DateOfAuction,
                CurrentPrice    = newLot.StartingPrice,
                UserOwnerId     = userId
            };

            return(bllLot);
        }