/// <summary> /// Creates a hashset of the staff members current availabilities for the chosen day. /// </summary> /// <param name="thisDate"></param> /// <returns></returns> private HashSet <currentAvailItem> getCurrentAvails(DateTime thisDate) { HashSet <currentAvailItem> theseAvails = new HashSet <currentAvailItem>(); try { HashSet <CurrentAvailabilities> currentAvailabilities = db.CurrentAvailabilities .Where(CA => CA.StaffId == thisStaff.Id) .Where(CA => CA.BlockStartTime.Date == thisDate.Date) .ToHashSet(); foreach (CurrentAvailabilities thisAvailability in currentAvailabilities) { currentAvailItem thisAvailItem = new currentAvailItem(thisAvailability); theseAvails.Add(thisAvailItem); } } catch (Exception e) { Debug.WriteLine("Error getting current availabilities: " + e); } return(theseAvails); }
//MARK: SETTING AN EXISTING AVAILABILITY /// <summary> /// The user selectes an existing availability /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExistingAvailsCB_SelectionChanged(object sender, SelectionChangedEventArgs e) { usingExistingAvailability = true; NewSchedETCB.IsEnabled = true; NewSchedSTCB.IsEnabled = true; currentAvailItem thisExistingAvailability = (currentAvailItem)ExistingAvailsCB.SelectedItem; existingAvailability = thisExistingAvailability.thisAvailability; if (newScheduleItem != null) { newScheduleItem.AvailabilityId = existingAvailability.Id; newScheduleItem.BlockStartTime = existingAvailability.BlockStartTime; newScheduleItem.BlockEndTime = existingAvailability.BlockEndTime; } }