public ActionResult Add() { var viewmodel = new SuppliersBaseViewModel(); viewmodel.Init(_suppliersRepository); return(View(viewmodel)); }
public ActionResult Edit(SuppliersBaseViewModel viewModel) { if (ModelState.IsValid) { var supplier = viewModel.Supplier; _suppliersRepository.Update(supplier); TempData["Message"] = "Le fournisseur a été modifié correctement."; return(RedirectToAction("Index")); } viewModel.Init(_suppliersRepository); return(View(viewModel)); }
public ActionResult Add(SuppliersBaseViewModel viewModel) { if (ModelState.IsValid) { var supplier = viewModel.Supplier; _suppliersRepository.Add(supplier); TempData["Message"] = "Le fournisseur a été ajouté a la liste."; return(RedirectToAction("Index")); } viewModel.Init(_suppliersRepository); return(View(viewModel)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var supplier = _suppliersRepository.GetById((int)id); if (supplier == null) { return(HttpNotFound()); } var viewModel = new SuppliersBaseViewModel() { Supplier = supplier }; viewModel.Init(_suppliersRepository); return(View(viewModel)); }