예제 #1
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();
        }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            newShift = new Shift();

            newShift.NumberOfCashiers   = addShiftViewModel.NumberOfCashiers;
            newShift.NumberOfCooks      = addShiftViewModel.NumberOfCooks;
            newShift.NumberOfDiswashers = addShiftViewModel.NumberOfDiswashers;
            newShift.NumberOfWaiters    = addShiftViewModel.NumberOfWaiters;
            newShift.NumberOfManagers   = addShiftViewModel.NumberOfManagers;
            newShift.DateOfShift        = addShiftViewModel.ShiftDate;

            int year  = newShift.DateOfShift.Year;
            int month = newShift.DateOfShift.Month;
            int day   = newShift.DateOfShift.Day;
            int hour  = Convert.ToInt32(addShiftViewModel.StartHour);
            int min   = Convert.ToInt32(addShiftViewModel.StartMinute);

            newShift.StartTime = new DateTime(year, month, day, hour, min, 0);
            hour             = Convert.ToInt32(addShiftViewModel.EndHour);
            min              = Convert.ToInt32(addShiftViewModel.EndMinute);
            newShift.EndTime = new DateTime(year, month, day, hour, min, 0);

            _ConsoleViewModel.InitializeViewModelData();

            newShift.ShiftID = newShift.GetHashCode();

            _ConsoleViewModel.AddShift(newShift);

            _ConsoleViewModel.SaveScheduleProgress();

            Shiftviewer shiftviewer = new Shiftviewer();

            shiftviewer.Show();
            this.Close();
        }
        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();
        }