コード例 #1
0
 public ActionResult NewStorageLot(NewStorageLotModel model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new BGS_DBContext()) {
             string userIdentityId = User.Identity.GetUserId();
             var    seller         = db.Users.Single(u => u.Id == userIdentityId);
             for (int i = 0; i < model.LotCount; i++)
             {
                 StorageModel newStorageModel = GameUtilCreater.StorageModelFromModel(model);
                 db.StorageModels.Add(newStorageModel);
                 db.SaveChanges();
                 var lot = new LotModel()
                 {
                     Seller   = seller,
                     ItemId   = newStorageModel.Id,
                     Price    = model.Price,
                     SellerId = seller.GameId,
                     Status   = LotStatus.Available,
                     Type     = LotType.Storage
                 };
                 db.LotModels.Add(lot);
                 db.SaveChanges();
                 newStorageModel.LotId = lot.Id;
             }
             db.SaveChanges();
             return(RedirectToAction("Index", "Market"));
         }
     }
     ModelState.AddModelError("", "Что то не правильно");
     return(View(model));
 }
コード例 #2
0
        public ActionResult NewStorageLot()
        {
            var model = new NewStorageLotModel();

            return(View(model));
        }