コード例 #1
0
        private void AddOrRemoveShift(ShiftType shiftType, bool isToggled)
        {
            var workShift = _workShiftsRepository.Get(SelectedDate, shiftType);

            if (isToggled)
            {
                if (workShift == null)
                {
                    var newWorkShift = new WorkShift {
                        Date = SelectedDate, ShiftType = shiftType
                    };
                    var inlineCalendarEvent = WorkShiftConverter.ToCalendarInlineEvent(newWorkShift);
                    _workShiftsRepository.Insert(newWorkShift);
                    WorkShifts.Add(inlineCalendarEvent);
                    _workshiftCalendar.Add(newWorkShift, inlineCalendarEvent);
                }
            }
            else
            {
                if (workShift != null)
                {
                    var foundCalendarItem = _workshiftCalendar[workShift];
                    _workShiftsRepository.Delete(workShift);
                    WorkShifts.Remove(foundCalendarItem);
                    _workshiftCalendar.Remove(workShift);
                }
            }
        }
コード例 #2
0
        private void OnLoaded()
        {
            if (_isAlreadyLoaded)
            {
                return;
            }

            _workShiftsRepository.Load();

            foreach (var workshift in _workShiftsRepository.Get())
            {
                var inlineCalendarEvent = WorkShiftConverter.ToCalendarInlineEvent(workshift);
                WorkShifts.Add(inlineCalendarEvent);
                _workshiftCalendar.Add(workshift, inlineCalendarEvent);
            }

            OnDateChanged();
            _isAlreadyLoaded = true;
        }