Exemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WorkProfileVm"/> class from the model.
		/// </summary>
		/// <param name="entity">The model.</param>
		/// <param name="access"></param>
		/// <param name="dataService"></param>
		public WorkProfileVm(WorkProfile entity, AccessType access)
			: base(access)
		{
			IsReadonly = (access < AccessType.Update);
			_model = entity;
			InitializeData();
		}
		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 WorkProfile CreateDefault()
		{
			var workProfile = new WorkProfile
			{
				Name = "[New]",
				WeekStartNr = 0,
				SaturdayBusinessStateNr = 5,
				SundayBusinessStateNr = 5,
				MondayBusinessStateNr = 5,
				TuesdayBusinessStateNr = 5,
				WednesdayBusinessStateNr = 5,
				ThursdayBusinessStateNr = 4,
				FridayBusinessStateNr = 0,
			};
			var proto = WorkShiftPrototype.CreateDefault(workProfile);
			workProfile.WorkShiftPrototypes.Add(proto);
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.Open));
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.HalfClosed));
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.Closed));
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.SpecialDay1));
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.SpecialDay2));
			workProfile.WorkDays.Add(WorkDay.CreateDefault(workProfile, proto, BusinessDayType.SpecialDay3));
			return workProfile;
		}
Exemplo n.º 5
0
     private void FixupWorkProfile(WorkProfile previousValue)
     {
         if (previousValue != null && previousValue.WorkDays.Contains(this))
         {
             previousValue.WorkDays.Remove(this);
         }
 
         if (WorkProfile != null)
         {
             if (!WorkProfile.WorkDays.Contains(this))
             {
                 WorkProfile.WorkDays.Add(this);
             }
         }
     }