public static WorkShiftPrototype CreateDefault(WorkProfile parent)
		{
			var model = new WorkShiftPrototype();
			if (parent.WorkShiftPrototypes.Any())
			{
				var last = parent.WorkShiftPrototypes.Last();
				model.Index = (byte)(last.Index + 1);
			}
			else model.Index = 0;
			model.Name = GetNameByIndex(model.Index);
			model.Color = GetColorByIndex(model.Index);
			model.WorkProfile = parent;
			return model;
		}
		/// <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;
		}
Example #4
0
     private void FixupWorkShiftPrototype(WorkShiftPrototype previousValue)
     {
         if (previousValue != null && previousValue.WorkShifts.Contains(this))
         {
             previousValue.WorkShifts.Remove(this);
         }
 
         if (WorkShiftPrototype != null)
         {
             if (!WorkShiftPrototype.WorkShifts.Contains(this))
             {
                 WorkShiftPrototype.WorkShifts.Add(this);
             }
         }
     }