public IActionResult Create(RuntagViewModel viewModel) { if (ModelState.IsValid) { _dbContext.Runtags.Add(viewModel.Model); _dbContext.SaveChanges(); return(RedirectToAction("Index")); } return(View(viewModel)); }
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)); }
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)); }
public IActionResult Create() { var viewModel = new RuntagViewModel(); return(View(viewModel)); }