コード例 #1
0
 public IActionResult Create(RuntagViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         _dbContext.Runtags.Add(viewModel.Model);
         _dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(viewModel));
 }
コード例 #2
0
        public IActionResult Edit(int id)
        {
            var model = _dbContext.Runtags.FirstOrDefault(x => x.Id.Equals(id));

            if (model == null)
            {
                NotFound();
            }
            var viewModel = new RuntagViewModel(model);

            return(View(viewModel));
        }
コード例 #3
0
        public IActionResult Edit(int id, RuntagViewModel viewModel)
        {
            var model = _dbContext.Runtags.FirstOrDefault(x => x.Id.Equals(id));

            if (model != null)
            {
                model.Address      = viewModel.Address;
                model.CustomerName = viewModel.CustomerName;
                model.Description  = viewModel.Description;
                model.DueTime      = viewModel.DueTime;
                model.Title        = viewModel.Title;

                _dbContext.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(viewModel));
        }
コード例 #4
0
        public IActionResult Create()
        {
            var viewModel = new RuntagViewModel();

            return(View(viewModel));
        }