public ActionResult Create(FormCollection collection) { Department department = new Department(); try { // TODO: Add insert logic here UpdateModel(department, collection); departmentRepository.Add(department); departmentRepository.Save(); return RedirectToAction("Index"); } catch { return View("Error"); } }
public ActionResult Edit(int id, FormCollection collection, Department dep) { Department department = departmentRepository.FindBy(x => x.Id == id).FirstOrDefault(); if (department == null) return HttpNotFound(); try { // TODO: Add update logic here if(ModelState.IsValid) { departmentRepository.Edit(dep, dep.Id); departmentRepository.Save(); return RedirectToAction("Index"); } //UpdateModel(department, collection); return View(dep); } catch(Exception e) { return View("Error"); } }