Exemplo n.º 1
0
        /// <summary>
        /// Delete this shift
        /// </summary>
        /// <param name="shift">Shift</param>
        public void DeleteShift(Shift shift)
        {
            if (!Shifts.Contains(shift))
            {
                return;
            }

            // can't be in use
            foreach (Shift inUseShift in Shifts)
            {
                foreach (Team team in Teams)
                {
                    Rotation rotation = team.Rotation;

                    foreach (TimePeriod period in rotation.GetPeriods())
                    {
                        if (period.Equals(inUseShift))
                        {
                            string msg = String.Format(WorkSchedule.GetMessage("shift.in.use"), shift.Name);
                            throw new Exception(msg);
                        }
                    }
                }
            }

            Shifts.Remove(shift);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a shift
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="description">Description</param>
        /// <param name="start">Start of shift</param>
        /// <param name="duration">Duration of shift</param>
        /// <returns>Shift</returns>
        public Shift CreateShift(string name, string description, LocalTime start, Duration duration)
        {
            Shift shift = new Shift(name, description, start, duration);

            if (Shifts.Contains(shift))
            {
                string msg = String.Format(WorkSchedule.GetMessage("shift.already.exists"), name);
                throw new Exception(msg);
            }
            Shifts.Add(shift);
            shift.WorkSchedule = this;
            return(shift);
        }