Exemple #1
0
		/// <summary>
		/// Creates an instance of <see cref="WorkShiftVm"/> with the given model and work shift prototype viewModel
		/// </summary>
		/// <param name="model"></param>
		/// <param name="prototype"></param>
		public WorkShiftVm(Model.WorkShift model, WorkShiftPrototypeVm prototype)
		{
			Model = model;
			Prototype = prototype;
			StartSeconds = model.StartSeconds;
			EndSeconds = model.EndSeconds;
			IsOpen = model.IsOpen;

			//add workbreak models
			foreach (var workBreak in model.WorkBreaks)
			{
				var wbreak = new WorkBreakVm(workBreak);
				wbreak.DeleteCommand = new Commands.Command(o => Breaks.Remove(wbreak));
				Breaks.Add(wbreak);
			}

			//auto add future workbreak models
			Breaks.CollectionChanged += (s, e) =>
			{
				if (e.NewItems != null)
					foreach (WorkBreakVm wbreak in e.NewItems)
					{
						Model.WorkBreaks.Add(wbreak.Model);
					}
				if(e.OldItems!=null)
					foreach (WorkBreakVm wbreak in e.OldItems)
					{
						Model.WorkBreaks.Remove(wbreak.Model);
					}
			};

			ToggleIsOpenCommand = new Commands.Command(o => IsOpen = !IsOpen);
		}
Exemple #2
0
		/// <summary>
		/// Creates an instance of WorkTimeRangeVm for the given <see cref="Soheil.Model.WorkShift"/>
		/// </summary>
		/// <param name="shift"></param>
		public PPItemWorkTime(WorkShift shift, DateTime dayStart)
		{
			DayStart = dayStart;
			Start = dayStart.AddSeconds(shift.StartSeconds);
			End = dayStart.AddSeconds(shift.EndSeconds);
			Id = shift.Id;
			Model = shift;
		}