コード例 #1
0
        public ActionResult New(NewItemForm form)
        {
            if (!ModelState.IsValid)
            {
                return View(form);
            }

            _context.Items.Add(new Item
            {
                ItemName = form.ItemName,
                ItemCode = form.ItemCode,
                Price = form.Price,
            });

            _context.SaveChanges();

            return RedirectToAction<ItemController>(c => c.Index())
                .WithSuccess("Item created!");
        }
コード例 #2
0
 public ActionResult New()
 {
     var form = new NewItemForm();
     return View(form);
 }