public AddStaffGroupsResponse AddStaffGroups(AddStaffGroupsRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.StaffGroups, "StaffGroups"); CollectionUtils.ForEach(request.StaffGroups, delegate(StaffGroupSummary s) { var group = PersistenceContext.Load <StaffGroup>(s.StaffGroupRef, EntityLoadFlags.Proxy); if (!group.Elective) { throw new RequestValidationException(string.Format("You cannot be added to non-elective staff group '{0}'.", group.Name)); } group.AddMember(this.CurrentUserStaff); }); return(new AddStaffGroupsResponse()); }
public void Accept() { try { // if the user added any new groups, need to add the user as a member of those groups List <TableItem> newItems = CollectionUtils.Select(_staffGroupTable.Items, delegate(TableItem item) { return(item.IsNew); }); if (newItems.Count > 0) { AddStaffGroupsRequest request = new AddStaffGroupsRequest( CollectionUtils.Map <TableItem, StaffGroupSummary>(newItems, delegate(TableItem item) { return(item.Item); })); Platform.GetService <IOrderNoteService>( delegate(IOrderNoteService service) { service.AddStaffGroups(request); }); } // save the set of folders that should be visible List <TableItem> visibleItems = CollectionUtils.Select(_staffGroupTable.Items, delegate(TableItem item) { return(item.IsChecked); }); OrderNoteboxFolderSystemSettings.Default.GroupFolders = new OrderNoteboxFolderSystemSettings.GroupFoldersData( CollectionUtils.Map <TableItem, string>(visibleItems, delegate(TableItem item) { return(item.Item.Name); })); OrderNoteboxFolderSystemSettings.Default.Save(); this.Exit(ApplicationComponentExitCode.Accepted); } catch (Exception e) { ExceptionHandler.Report(e, "", this.Host.DesktopWindow, delegate { this.Exit(ApplicationComponentExitCode.Error); }); } }