public ActionResult Create(DepartmentFormModel model) {

			if (ModelState.IsValid) {
                var item = Mapper.Map<DepartmentFormModel, Department>(model);

				GetSession.Save(item);

				return RedirectToAction("Index");
			}

			return View(model);
		}
		public ActionResult Edit(DepartmentFormModel model) {
			var item = GetSession.Get<Department>(model.Id);
            
			if (ModelState.IsValid) {
				Mapper.Map<DepartmentFormModel, Department>(model, item);

				GetSession.Update(item);

				return RedirectToAction("Index");
			}

			return View(model);
		}
		public ActionResult Create() {
            var model = new DepartmentFormModel();
			return View(model);
		}
        public void UpdateDepartments()
        {

            var excel = new ExcelQueryFactory();
            string[] ex_names = MvcApplication.Config("excel_name").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            for (int ex_name = 0; ex_name < ex_names.Length; ex_name++)
            {
                excel.FileName = ex_names[ex_name];

                var result_employees = from c
                                in excel.WorksheetNoHeader(0)
                                       select c;


                List<Department> existing_deps = (List<Department>)GetSession.QueryOver<Department>().List();
                List<string> existing_dep_list = new List<string>();

                foreach (var dep in existing_deps)
                {
                    if (!existing_dep_list.Contains(dep.Name))
                    {
                        existing_dep_list.Add(dep.Name);

                    }
                }


                foreach (var new_dep in result_employees)
                {
                    if (!string.IsNullOrEmpty(new_dep[4].ToString().Trim()) && !existing_dep_list.Contains(new_dep[4].ToString().Trim()))
                    {
                        DepartmentFormModel model = new DepartmentFormModel()
                        {
                            Name = new_dep[4].ToString().Trim()
                        };

                        var item = Mapper.Map<DepartmentFormModel, Department>(model);
                        GetSession.Save(item);
                        existing_dep_list.Add(new_dep[4].ToString().Trim());
                    }
                }

            }
        }