public GoalViewModel(Goal goal) { goalRep = new GoalRepository(); TheTitle = goal.Title; TheCurrentValue = Convert.ToString(goal.CurrentValue); TheGoalValue = Convert.ToString(goal.GoalValue); TheEndDate = goal.EndDate; TheIsFinished = goal.IsFinished; progress = goal.Progress; SaveGoalCommand = new Command(async() => { goal.Title = TheTitle; goal.CurrentValue = Convert.ToDouble(TheCurrentValue); goal.GoalValue = Convert.ToDouble(TheGoalValue); goal.StartDate = DateTime.Now; goal.EndDate = TheEndDate; goal.Progress = goal.CurrentValue / goal.GoalValue; await goalRep.SaveGoalAsync(goal); TheTitle = string.Empty; TheCurrentValue = string.Empty; TheGoalValue = string.Empty; TheIsFinished = false; TheEndDate = DateTime.MinValue; progress = 0; }); UpdateGoalCommand = new Command(async() => { goal.Title = TheTitle; goal.CurrentValue = Convert.ToDouble(TheCurrentValue) + Convert.ToDouble(TheAddValue); goal.GoalValue = Convert.ToDouble(TheGoalValue); goal.Progress = goal.CurrentValue / goal.GoalValue; if (goal.Progress >= 1) { goal.IsFinished = true; goal.EndDate = DateTime.Now; } await goalRep.SaveGoalAsync(goal); TheTitle = string.Empty; TheCurrentValue = string.Empty; TheGoalValue = string.Empty; TheIsFinished = false; TheEndDate = DateTime.MinValue; progress = 0; }); RemoveGoal = new Command(async() => { await goalRep.DeleteGoalAsync(goal); }); }