コード例 #1
0
        /// <summary>
        /// Step #2
        /// Test #4
        /// </summary>
        /// <param name="id">Workgroup Id</param>
        /// <returns></returns>
        public ActionResult AddSubOrganizations(int id)
        {
            if (id == 0)
            {
                Message = "Workgroup must be created before proceeding";
                return(this.RedirectToAction(a => a.CreateWorkgroup()));
            }
            ViewBag.StepNumber = 2;

            var workgroup = _workgroupRepository.GetNullableById(id);

            if (workgroup == null)
            {
                Message = "Workgroup not found.";
                this.RedirectToAction <WorkgroupController>(a => a.Index(false));
            }

            var user = _userRepository.Queryable.Single(x => x.Id == CurrentUser.Identity.Name);

            var model = WorkgroupModifyModel.Create(user, _queryRepositoryFactory);

            model.Workgroup     = workgroup;
            ViewBag.WorkgroupId = workgroup.Id;

            return(View(model));
        }
コード例 #2
0
        //NOTE: This wizard will only allow adding stuff. No delete, edit or view. For that they will complete the wizard and go back to the Workgroup management

        /// <summary>
        /// Step 1
        /// Test #2
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateWorkgroup()
        {
            ViewBag.StepNumber = 1;
            var user = _userRepository.Queryable.Single(x => x.Id == CurrentUser.Identity.Name);

            var model = WorkgroupModifyModel.Create(user, _queryRepositoryFactory);

            return(View(model));
        }
コード例 #3
0
        public ActionResult CreateWorkgroup(Workgroup workgroup)
        {
            ViewBag.StepNumber = 1;

            var user = GetCurrentUser();

            //if(!user.Organizations.Any(a => a.Id == workgroup.PrimaryOrganization.Id))
            //{
            //    ModelState.AddModelError("Workgroup.PrimaryOrganization", "You do not have access to the selected organization");
            //}
            // takes into account department traversal down
            string message;

            if (!_securityService.HasWorkgroupOrOrganizationAccess(null, workgroup.PrimaryOrganization, out message))
            {
                ModelState.AddModelError("Workgroup.PrimaryOrganization", "You do not have access to the selected organization");
            }

            if (workgroup.Administrative && workgroup.SyncAccounts)
            {
                ModelState.AddModelError("Workgroup.Administrative", "Can not have both Administrative and Sync Accounts selected.");
            }

            if (workgroup.IsFullFeatured && !workgroup.Administrative)
            {
                ModelState.AddModelError("Workgroup.Administrative", "If Full Featured, workgroup must be administrative.");
            }

            if (workgroup.Administrative && !string.IsNullOrEmpty(workgroup.NotificationEmailList))
            {
                ModelState.AddModelError("Workgroup.NotificationEmailList", "Notification email list will not do anything for an administrative group.");
            }

            if (workgroup.Administrative && workgroup.DoNotInheritPermissions)
            {
                ModelState.AddModelError("Workgroup.DoNotInheritPermissions", "Can not have both Administrative and Do Not Inherit Permissions selected.");
            }



            if (!ModelState.IsValid)
            {
                var model = WorkgroupModifyModel.Create(user, _queryRepositoryFactory);
                model.Workgroup = workgroup;

                return(View(model));
            }

            var createdWorkgroup = _workgroupService.CreateWorkgroup(workgroup, null);

            Message = string.Format("{0} workgroup was created",
                                    createdWorkgroup.Name);

            return(this.RedirectToAction(a => a.AddSubOrganizations(createdWorkgroup.Id)));
        }