public async Task When(CreateWorkout cmd) { var workoutId = new WorkoutId(cmd.Id); var challengeId = new ChallengeId(cmd.ChallengeId); await Update(workoutId, w => w.Create(workoutId, challengeId, new CoreDomain.Types.WorkoutType(cmd.WorkoutType), cmd.Repetitions)); }
public WorkoutCreated(WorkoutId id, ChallengeId challengeId, WorkoutType type, int reps, DateTime eventDateTime) : base(eventDateTime) { Id = id; ChallengeId = challengeId; Type = type; Reps = reps; }
public void Create(WorkoutId id, ChallengeId challengeId, WorkoutType type, int repetitions) { if (State.Created) { throw new InvalidOperationException($"{nameof(Workout)}-{id} already created"); } Apply(new WorkoutCreated(id, challengeId, type, repetitions, DateTime.Now)); }
public void OnTapped() { System.Diagnostics.Debug.WriteLine("{0} was tapped", Text); if (TappedCommand != null && TappedCommand.CanExecute(WorkoutId.ToString())) { TappedCommand.Execute(WorkoutId.ToString()); } var handler = Tapped; if (handler != null) { handler(this, EventArgs.Empty); } }
public override string ToString() { var s = new StringBuilder() .AppendLine(WorkoutId.ToString()) .AppendLine(InstanceId.ToString()) .AppendLine(WorkoutStarted.ToString()) .AppendLine(WorkoutEnded.ToString()); foreach (var score in Scores) { s.AppendLine(score.ToString()); } return(s.ToString()); }
public async void OnDragAborted() { onswap = false; Status = DragState.Aborted; this.Scale = 1; this.Opacity = 1; FontSize = 14; await this.LayoutTo(CurrentBounds, 100, Easing.CubicIn); OnDragCompleted(CurrentTarget); if (DraggedCommand != null && DraggedCommand.CanExecute(new string[] { "-", WorkoutId.ToString() })) { DraggedCommand.Execute(new string[] { "-", WorkoutId.ToString() }); } TapEnabled = true; }
public static void BuildPendingWorkout(IEventStore eventStore) { if (WorkoutViewModels.Any()) { return; } var id = new WorkoutId(Guid.NewGuid()); var workoutType = "Pushups"; var createEvent = new WorkoutCreated(id, ChallengeId, new WorkoutType(workoutType), 20, DateTime.Now.AddMinutes(-13)); var viewModel = new WorkoutViewModel { Id = id.Guid, Reps = 20, WorkoutType = workoutType }; eventStore.Add(id, new List <IEvent> { createEvent }); WorkoutViewModels.Add(viewModel); }
public async void OnDragCompleted(IDrop target) { if (target == CurrentDropBox) { onswap = false; } if (TargetType != target.GetType()) { return; } Constants.CurrentCategoryOrder.Remove(int.Parse(this.ClassId)); Constants.CurrentCategoryOrder.Insert(target.position, int.Parse(this.ClassId)); if (target.DraggableChildren.Count > 0 && onswap) { target.DraggableChildren[0].OnDragCompleted(CurrentDropBox); CurrentDropBox.OnDraggableDropped(target.DraggableChildren[0]); target.DraggableChildren[0].CurrentDropBox = CurrentDropBox; onswap = false; } CurrentTarget = target; CurrentDropBox = target; this.Scale = 1; this.Opacity = 1; FontSize = 10; var view = target as View; if (view != null) { var bounds = view.Bounds; await this.LayoutTo(bounds, 0, Easing.CubicIn); CurrentBounds = bounds; //System.Diagnostics.Debug.WriteLine("{0} current bounds: {1}", Text, CurrentBounds); } Status = DragState.Completed; TapEnabled = false; if (DraggedCommand != null && DraggedCommand.CanExecute(new string[] { ((DropBox)target).Date.ToString("D"), WorkoutId.ToString() })) { DraggedCommand.Execute(new string[] { ((DropBox)target).Date.ToString("d"), WorkoutId.ToString() }); } }
public WorkoutExecuted(WorkoutId id, DateTime eventDateTime) : base(eventDateTime) { Id = id; }