public ActionResult ModuleInDepartment(ModuleInDepartmentViewModel moduleInDeptViewModel, string buttonType)
        {
            if (buttonType == "Add")
                return RedirectToAction("AddModule", "Dashboard");
            ValidateModuleInDepartmentVM(moduleInDeptViewModel);
            if (ModelState.IsValid)
            {
                var modInDeptLst = new List<ModuleInDepartment>();

                foreach (var mod in moduleInDeptViewModel.Modules)
                {
                    var modInDept = new ModuleInDepartment()
                    {
                        DepartmentId = moduleInDeptViewModel.DepartmentId,
                        ModuleId = mod.As<long>(),
                        Active = true
                    };
                    modInDeptLst.Add(modInDept);
                }
                _wcfService.InvokeService<IOrganizationService>((svc) => svc.AddModuleInDepartment(modInDeptLst));
                moduleInDeptViewModel.Message = "Thank you for choosing the modules.";
                moduleInDeptViewModel.CreationSuccessful = true;
            }
            return View(moduleInDeptViewModel);
        }
        private void ValidateModuleInDepartmentVM(ModuleInDepartmentViewModel moduleInDeptViewModel)
        {
            if (moduleInDeptViewModel.DepartmentId == 0)
                ModelState.AddModelError("DepartmentId", "Please slect a Department.");
            if (!moduleInDeptViewModel.Modules.IsCollectionValid())
                ModelState.AddModelError("Modules", "Please select a Module.");

        }
 public ActionResult ModuleInDepartment()
 {
     var moduleInDept = new ModuleInDepartmentViewModel();
     var deptInOrg = _wcfService.InvokeService<IOrganizationService, List<Department>>((svc) => svc.GetDepartmentInOrg(SessionContext.CurrentUser.OrganizationId.Value));
     moduleInDept.Department = deptInOrg;
     moduleInDept.ModuleVm = new List<ModuleInDeptVM>();
     return View(moduleInDept);
 }