public ActionResult Create(DepartmentModel departmentmodel)
        {
            //departments must be unique
            var query = from a in db.DepartmentModel
                        where departmentmodel.Name.Equals(a.Name)
                        select a;

            if (ModelState.IsValid)
            {
                if (query.Count() != 0)
                {
                    ModelState.AddModelError(string.Empty, "Department name already exists!");
                }
                else
                {
                    db.DepartmentModel.Add(departmentmodel);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            return View(departmentmodel);
        }
 public ActionResult Edit(DepartmentModel departmentmodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departmentmodel).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(departmentmodel);
 }