コード例 #1
0
 public async Task <IActionResult> Add(Cinema model)
 {
     if (ModelState.IsValid)
     {
         await _cinemaService.AddAsync(model);
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: zlim530/CodeReview
 public async Task <IActionResult> Add(Cinema model)
 {
     if (ModelState.IsValid)
     {
         await _cinemaService.AddAsync(model);
     }
     // 跳转回本 controller 下面的 action,即 Index action
     return(RedirectToAction("Index"));
 }
コード例 #3
0
        public async Task <IActionResult> Add(Cinema model)
        {
            if (ModelState.IsValid)//检查model的有效性
            {
                await _cinemaService.AddAsync(model);
            }

            return(RedirectToAction("Index"));//添加完成后跳转到电影院列表页面
        }
コード例 #4
0
 [HttpPost]//添加,不然默认是[HttpGet](查询),上面得到就是
 public async Task <IActionResult> add(Cinema model)
 {
     //model的验证
     if (ModelState.IsValid)
     {
         await _cinemaService.AddAsync(model);
     }
     //跳转回HomeController下面的Action
     return(RedirectToAction("Index"));
 }
コード例 #5
0
 //添加电影院信息
 public IActionResult add()
 {
     ViewBag.Title = "添加电影院";
     return(View(_cinemaService.AddAsync(new Cinema())));
 }