private void SaveBusinessDay(BusinessDayIdentifier identifier) { if (identifier == null) throw new ArgumentNullException(nameof(identifier)); var personIdentifiers = AttendeesView.GetCollection().Select(p => p.Identifier); var businessDay = new BusinessDay(identifier, personIdentifiers); RepositoryManager.Save(businessDay); RepositoryManager.FlushBusinessDayRepositoryToDisk(); }
public BusinessDayEditorForm() { InitializeComponent(); Icon = Properties.Resources.PepeBlazingIcon; var dayBeingEdited = DateTime.Now.ToString(Default.DateFormat); Text = $"{_FormBaseTitle} [{dayBeingEdited}]]"; saveFastToolStripMenuItem.Text += $" [{dayBeingEdited}]"; PersonRepositoryView.SetCollection(RepositoryManager.GetAllPerson()); var identifier = new BusinessDayIdentifier(DateTime.Today); LoadSimpleBusinessDay(identifier); }
private void SaveBusinessDay(BusinessDayIdentifier identifier) { if (identifier == null) throw new ArgumentNullException(nameof(identifier)); // Fetches the identifiers of all BusinessDayMk2 created for the same as the one we are going to create var sameDay = BusinessDayRepository.Identifiers.Where(i => i.DateTime.Date.Equals(identifier.DateTime.Date)).ToList(); // Creates and stores the BusinessDayMk2 var attendedTime = new TimeFrame(identifier.DateTime, new TimeSpan(0, 40, 0)); var people = AttendanceView.GetCollection(); var attendances = people.Select(p => new AttendanceMk2(p.Identifier, new TimeFrame[] { attendedTime })); var businessDay = new BusinessDayMk2(identifier, attendances); BusinessDayRepository.Save(businessDay); // Removed all other businessdays created for the same date foreach (var date in sameDay) BusinessDayRepository.Delete(date); }
private void LoadSimpleBusinessDay(BusinessDayIdentifier identifier) { if (identifier == null) throw new ArgumentNullException(nameof(identifier)); BusinessDay day; var found = RepositoryManager.TryGet(identifier, out day); if (!found) return; var people = new List<Person>(day.Count()); foreach (var p in day) { Person temp; if (RepositoryManager.TryGet(p, out temp)) people.Add(temp); } AttendeesView.SetCollection(people); Text = $"{_FormBaseTitle} [{identifier.Date.ToString(Default.DateFormat)}]"; }
public static bool DeleteBusinessDay(BusinessDayIdentifier id) => BusinessDayRepository.Delete(id);
public static bool TryGet(BusinessDayIdentifier id, out BusinessDay entity) => BusinessDayRepository.TryGet(id, out entity);