public ActionResult AddInclusiveMiscSortToDepartment(int id)
 {
     DepartmentMiscSortItem model = new DepartmentMiscSortItem();
     model.DepartmentId = id;
     //_AddInclusiveMiscSortToDepartment
     return PartialView("_AddInclusiveMiscSortToDepartment", model);
 }
        public JsonResult AddInclusiveMiscSortToDepartment(DepartmentMiscSortItem entity)
        {
            ScheduleManager manager = new ScheduleManager();

            if (manager.AddNewMiscSortCodeInclude(entity))
            {

            return Json(new { success = true });
            }
            else
            {
                return Json(new { success = false });
            }
        }
        public bool AddNewMiscSortCodeInclude(DepartmentMiscSortItem entity)
        {
            bool result = false;

            using (ScheduleDataContext ctx = new ScheduleDataContext())
            {

                DepartmentMiscSort misc = new DepartmentMiscSort();

                misc.IncludeFilter = false;
                misc.MiscSortValue = entity.MiscSortText;
                misc.DepartmentID = entity.DepartmentId;

                ctx.DepartmentMiscSorts.InsertOnSubmit(misc);

                try
                {
                    ctx.SubmitChanges();
                    result = true;

                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to add Misc Sort Value: " + ex.Message);
                }

            }

            return result;
        }
        public ActionResult RemoveMiscSortValue(DepartmentMiscSortItem entity)
        {
            int deptId = entity.DepartmentId;

            ScheduleManager manager = new ScheduleManager();

            if (manager.RemoveMiscSortCodeEntry(entity.MiscSortId))
            {
                return RedirectToAction("EditDepartment", new { id = deptId });
            }
            else
            {
                return View("RemoveMiscSortValue", entity);
            }
        }
        public DepartmentMiscSortItem GetMiscSortItem(int id)
        {
            using (ScheduleDataContext ctx = new ScheduleDataContext())
            {

                var item = ctx.DepartmentMiscSorts.Where(d => d.DepartmentMiscSortId == id).SingleOrDefault<DepartmentMiscSort>();

                DepartmentMiscSortItem result = new DepartmentMiscSortItem();

                try
                {
                    result.DepartmentId = item.DepartmentID;
                    result.MiscSortId = item.DepartmentMiscSortId;
                    result.MiscSortText = item.MiscSortValue;
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to get Misc Sort Value: " + ex.Message);
                }

                return result;
            }
        }