private void SaveChange(object sender, RoutedEventArgs e)
        {
            _ConsoleViewModel.InitializeViewModelData();

            List <Shift> temp  = _ConsoleViewModel.ShiftList();
            Shift        found = temp.Find(x => x.ShiftID.Equals(editShiftViewModel.Id));

            if (found != null)
            {
                found.DateOfShift = editShiftViewModel.Date;
                int year  = editShiftViewModel.Date.Year;
                int month = editShiftViewModel.Date.Month;
                int day   = editShiftViewModel.Date.Day;
                found.Coverage           = editShiftViewModel.Coverage;
                found.EndTime            = new DateTime(year, month, day, editShiftViewModel.EHour, editShiftViewModel.EMinute, 0);
                found.StartTime          = new DateTime(year, month, day, editShiftViewModel.SHour, editShiftViewModel.SMinute, 0);
                found.WorkingEmployees   = editShiftViewModel.WorkingEmployees;
                found.AvailableEmployees = editShiftViewModel.AvailableEmployee;
                found.NumberOfCashiers   = editShiftViewModel.NumberOfCashiers;
                found.NumberOfCooks      = editShiftViewModel.NumberOfCooks;
                found.NumberOfDiswashers = editShiftViewModel.NumberOfDiswashers;
                found.NumberOfManagers   = editShiftViewModel.NumberOfManagers;
                found.NumberOfWaiters    = editShiftViewModel.NumberOfWaiters;
            }
            int delete = temp.FindIndex(x => x.ShiftID.Equals(editShiftViewModel.Id));

            _ConsoleViewModel.DeleteFromShiftList(delete);
            _ConsoleViewModel.AddShift(found);
            _ConsoleViewModel.SaveScheduleProgress();
            Shiftviewer shiftviewer = new Shiftviewer();

            shiftviewer.Show();
            this.Close();
        }
Пример #2
0
        private void rdAvailable_Checked(object sender, RoutedEventArgs e)
        {
            // put on available list
            if (SelectedSchedule.AvailableEmployees.Exists(x => x.ID == _CurrentUser.ID) == false)
            {
                SelectedSchedule.AvailableEmployees.Add(_CurrentUser);
            }
            List <Shift> ShiftList = _ConsoleViewModel.ShiftList();
            int          index     = ShiftList.FindIndex(x => x.ShiftID.Equals(SelectedSchedule.ShiftID));

            _ConsoleViewModel.DeleteFromShiftList(index);
            _ConsoleViewModel.AddShift(SelectedSchedule);
            _ConsoleViewModel.SaveScheduleProgress();
            _ConsoleViewModel.InitializeViewModelData();
        }