public virtual ActionResult Create() { ValidateIsAdmin(); var viewModel = new BrandModel { Active = true }; return View(viewModel); }
public virtual ActionResult Create(BrandModel viewModel) { ValidateIsAdmin(); using (var context = new TTTEntities()) { var newRecord = new refbrand { Active = viewModel.Active, Name = viewModel.Name, CreateDT = DateTime.Now, CategoryID = viewModel.CategoryID }; context.refbrands.Add(newRecord); context.SaveChanges(); } return RedirectToAction(MVC.Admin.Brand.Index()); }
public virtual ActionResult Edit(BrandModel viewModel) { ValidateIsAdmin(); using (var context = new TTTEntities()) { var record = context.refbrands.Single(a => a.ID == viewModel.ID); record.Name = viewModel.Name; record.Active = viewModel.Active; record.CategoryID = viewModel.CategoryID; context.SaveChanges(); } return RedirectToAction(MVC.Admin.Brand.Index()); }
public virtual ActionResult Edit(int id) { ValidateIsAdmin(); using (var context = new TTTEntities()) { var record = context.refbrands.Single(a => a.ID == id); var viewModel = new BrandModel { Active = record.Active, ID = record.ID, Name = record.Name, CategoryID = record.CategoryID }; return View(viewModel); } }