Exemplo n.º 1
0
		public GoalHistoryViewModel(User selectedUser)
		{
			SelectedUser = selectedUser;
			//get the Member Image
			if(SelectedUser.ImageURL == null || SelectedUser.ImageURL == ""){
				MemberImage = "memberpic.png";

			}else{

				MemberImage = SelectedUser.ImageURL;
			}
			GoalHistoryList = new ObservableCollection<GoalHistory> ();
			if (CrossConnectivity.Current.IsConnected) {
				Task.Run (async() => {
					var goalHistoryDBList = await GoalHistoryDAL.GetGoalHistory (SelectedUser.ProfileID);
					foreach (var gHistoryDB in goalHistoryDBList) {
						await GoalHistoryDAL.DeleteGoalHistory (gHistoryDB);
					}
					var goalHistoryListAPI = await CoachServices.RequestGoalHistory (SelectedUser.ProfileID);
					foreach (var goalHistoryDTO in goalHistoryListAPI) {
						GoalHistory goalHistory = new GoalHistory (goalHistoryDTO);
						await GoalHistoryDAL.InsertGoalHistory (goalHistory);
					}
					var goalHistoryDBList2 = await GoalHistoryDAL.GetGoalHistory (SelectedUser.ProfileID);
					//goalHistoryDBList2 = goalHistoryDBList2.OrderByDescending(row => row.Id).ToList();
					GoalHistoryList = new ObservableCollection<GoalHistory> (goalHistoryDBList2);
				});
			} else {
				DependencyService.Get<ICustomDialog>().Display("You are not connected to a network. The displayed data might not be up to date.", "OK");
				Task.Run (async() => {
					var goalHistoryDBList = await GoalHistoryDAL.GetGoalHistory(SelectedUser.ProfileID);
					GoalHistoryList = new ObservableCollection<GoalHistory> (goalHistoryDBList);
				});
			}
		}
Exemplo n.º 2
0
		public async static Task DeleteGoalHistory (GoalHistory goalHistory)
		{

			var db = DependencyService.Get<ISQLite> ().GetAsyncConnection ();

			await db.DeleteAsync (goalHistory);


		}
Exemplo n.º 3
0
		public async static Task InsertGoalHistory (GoalHistory goalHistory)
		{

			var db = DependencyService.Get<ISQLite> ().GetAsyncConnection ();
			await db.CreateTableAsync<GoalHistory> ();

			await db.InsertAsync (goalHistory);

		}
Exemplo n.º 4
0
		public GoalHistory(GoalHistory goalHistoryDTO)
		{
			this.ProfileID = goalHistoryDTO.ProfileID;
			this.Date = goalHistoryDTO.Date;
			this.Description = goalHistoryDTO.Description;
			this.PercentageComplete = goalHistoryDTO.PercentageComplete;
			this.Status = goalHistoryDTO.Status;
			this.Target = goalHistoryDTO.Target;
			this.ActualValue = goalHistoryDTO.ActualValue;
		}