/// <summary>
		/// Creates a default WorkDay with current WorkProfile and its default WorkShiftPrototype
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="proto"></param>
		/// <param name="state"></param>
		/// <returns></returns>
		public static WorkDay CreateDefault(WorkProfile parent, WorkShiftPrototype proto, BusinessDayType state)
		{
			var model = new WorkDay();
			
			var shift = WorkShift.CreateDefault(model, proto);
			shift.IsOpen = (state == BusinessDayType.Open || state == BusinessDayType.HalfClosed);
			model.WorkShifts.Add(shift);

			model.Name = GetNameByNr((int)state);
			model.Color = GetColorByNr((int)state);
			model.BusinessState = state;
			model.WorkProfile = parent;
			return model;
		}
		public static WorkShift CreateDefault(WorkDay parent, WorkShiftPrototype proto)
		{
			var model = new WorkShift();
			if (parent.WorkShifts.Any())
			{
				var last = parent.WorkShifts.Last();
				model.StartSeconds = last.EndSeconds;
				model.EndSeconds = last.EndSeconds + 3600;
				if (model.EndSeconds > SoheilConstants.EDITOR_END_SECONDS) throw new Exception("قادر به افزودن شیفت نمی باشد. زمان کافی در روز وجود ندارد");
			}
			else
			{
				model.StartSeconds = SoheilConstants.EDITOR_START_SECONDS;
				model.EndSeconds = SoheilConstants.EDITOR_START_SECONDS + 3600;
			}
			model.WorkDay = parent;
			model._workShiftPrototype = proto;
			return model;
		}
示例#3
0
     private void FixupWorkDay(WorkDay previousValue)
     {
         if (previousValue != null && previousValue.WorkShifts.Contains(this))
         {
             previousValue.WorkShifts.Remove(this);
         }
 
         if (WorkDay != null)
         {
             if (!WorkDay.WorkShifts.Contains(this))
             {
                 WorkDay.WorkShifts.Add(this);
             }
         }
     }