public ActionResult Create(Department department)
 {
     if (ModelState.IsValid)
     {
         _repositiory.InsertOrUpdate(department);
         _repositiory.Save();
         return RedirectToAction("Index");
     }
     return View();
 }
 public void InsertOrUpdate(Department department)
 {
     if (department.DepartmentID == default(int))
     {
         // New entity
         context.Departments.Add(department);
     }
     else
     {
         // Existing entity
         context.Entry(department).State = System.Data.Entity.EntityState.Modified;
     }
 }