public bool addNewRoster(int weekNumber, string day, string name) { try { int maxRosterId = 0; //need some code to avoid dulicate usernames //maybe add some logic (busiess rules) about password policy //IUser user = new User(name, password, userType); // Construct a User Object foreach (Roster roster in RosterList) { if (roster.RosterID > maxRosterId) { maxRosterId = roster.RosterID; } } IRoster theRoster = RosterFactory.GetRoster(maxRosterId + 1, weekNumber, day, name); // Using a Factory to create the user entity object. ie seperating object creation from business logic RosterList.Add(theRoster); // Add a reference to the newly created object to the Models UserList DataLayer.addNewRosterToDB(theRoster); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
private void Awake() { lists = new List <RosterList>(); instance = this; // TODO: Load the test list XmlDocument listXmlRoot = new XmlDocument(); try { listXmlRoot.Load(testList); } catch (FileNotFoundException) { Debug.LogErrorFormat("Error trying to load the test roster list file \"{0}\"", testList); } RosterList newList = new RosterList(); newList.Load(listXmlRoot); lists.Add(newList); }
private void SetupRoster() { dispatchingCollection = new DispatchingCollection <ObservableCollection <Attendance>, Attendance>(_appContext.RosterManager.ServicePartyAttendanceList, Dispatcher); AllRosterList = new MainRosterList(dispatchingCollection, AllContacts); AllContacts.LostFocus += Contacts_LostFocus; AllContacts.DataContext = AllRosterList.ContactsView; ActiveRosterList = new ActiveRosterList(dispatchingCollection, CurrentlyActiveContacts); CurrentlyActiveContacts.LostFocus += Contacts_LostFocus; CurrentlyActiveContacts.DataContext = ActiveRosterList.ContactsView; ActiveRosterList.ContactsView.View.CollectionChanged += ActiveRosterChanged; SearchRosterList = new SearchRosterList(dispatchingCollection, SearchContacts, SearchBox); SearchContacts.LostFocus += Contacts_LostFocus; SearchContacts.DataContext = SearchRosterList.ContactsView; }
private async void UpdateView() { try { if (_isViewUpdateRunning) { _isViewUpdatePending = true; return; } _isViewUpdateRunning = true; if (!_updateCountdownTimer.IsEnabled) { if (_isListBufferUpdated) { await Frontend.RunAsync(() => { _lockContactSelection = true; { _lockListBuffer.WaitOne(4000); _lockListBuffer.Reset(); { RosterList.DataContext = _listBuffer; _isListBufferUpdated = false; } _lockListBuffer.Set(); if (_listBuffer.Contains(_selectedContact)) { RosterList.SelectedItem = _selectedContact; } else { RosterList.SelectedItem = _selectedContact = null; } } _lockContactSelection = false; }); } if (_isListScrolled) { await Frontend.RunAsync(() => { if (Frontend.Settings.autoScrollRoster && RosterList.Items.Count > 0) { if (Frontend.Settings.stickyRosterContacts || _selectedContact == null) { RosterList.ScrollIntoView(RosterList.Items.First()); } else { RosterList.ScrollIntoView(_selectedContact); } } _isListScrolled = false; }); } } _isViewUpdateRunning = false; if (_isViewUpdatePending) { _isViewUpdatePending = false; UpdateView(); } } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
public bool deleteRoster(IRoster roster) { DataLayer.deleteRosterFromDB(roster); RosterList.Remove(roster); //remove object from collection return(true); }