Beispiel #1
0
        public void AcceptAvailableShiftTest()
        {
            ScheduleShift shift    = _scheduleShiftRepository.GetShiftById(1);
            Employee      employee = new EmployeeRepository().GetEmployeeById(5);

            Assert.AreNotEqual(shift.Employee, employee);
            _scheduleShiftRepository.AcceptAvailableShift(shift, employee);
            shift = _scheduleShiftRepository.GetShiftById(1);
            Assert.AreEqual(shift.Employee.Name, employee.Name);
            Assert.AreEqual(shift.IsForSale, false);
        }
Beispiel #2
0
 /// <summary>
 /// This method is used when a user wants to accept a shift, that is available for sale.
 /// The method will also call the MailGun api method to send a mail to the employee whom accepted a shift.
 /// </summary>
 /// <param name="shift"></param>
 /// <param name="employee"></param>
 public void AcceptAvailableShift(ScheduleShift shift, Employee employee)
 {
     if (shift.IsForSale)
     {
         _scheduleShiftRepository.AcceptAvailableShift(shift, employee);
         MailSender   mailSender = new MailSender();
         const string subject    = "A shift has been accepted";
         string       text       = "The shift starting " + shift.StartTime + " and has a length of " + shift.Hours + " hours has been accepted by " + employee.Name;
         mailSender.SendMailToEmployeesInDepartmentByDepartmentId(subject, text, employee.DepartmentId);
     }
     else
     {
         throw new ArgumentException("Failure to accept shift. One or more arguments are illegal!");
     }
 }