public RegisterViewModel() { _ds = BettrFitDataSource.Instance; _sync = BettrFitDataSource.Instance._sync; RegisterCommand = new MvxCommand(()=>registerNewUser()); Selected = new UserGoalVM(); Selected.Goal_Muscle = 8; Selected.Goal_FatLoss = 5; Selected.Goal_Endurance = 2; Selected.WorkoutDays = 3; Selected.WorkoutMinutes = 45; _goal_Endurance = _selected.Goal_Endurance; _goal_FatLoss = _selected.Goal_FatLoss; _goal_Muscle = _selected.Goal_Muscle; OnPropertyChanged("Goal_Muscle"); OnPropertyChanged("Goal_Endurance"); OnPropertyChanged("Goal_FatLoss"); ; _userdata.PropertyChanged += (a, b) => { RaisePropertyChanged("IsValid"); }; _messenger = Mvx.Resolve<IMvxMessenger>(); }
internal async void DeleteUserGoal(UserGoalVM userGoal) { _sync.BeginSync(); try { var a = getAuth(); var m = AutoMapper.Mapper.Map<UserGoalVM, WebAccess.ServiceReference.UserGoalVM>(userGoal); var i = (await WebClientAsyncExtensions.DeleteUserGoalTask(a, m._id)); if (i == 0) { var d = UserGoals.FirstOrDefault(z => z._id == userGoal._id); if (d != null) UserGoals.Remove(d); userGoalStore.SaveAsync(UserGoals); } } catch (Exception) { Debug.WriteLine("Error Delete Usergoal"); } _sync.EndSync(); }
internal async void AddUserGoal(UserGoalVM userGoal) { _sync.BeginSync(); try { var a = getAuth(); var m = AutoMapper.Mapper.Map<UserGoalVM, WebAccess.ServiceReference.UserGoalVM>(userGoal); var i = (await WebClientAsyncExtensions.AddUserGoalTask(a, m)); if (!string.IsNullOrEmpty(i)) { await FillGoals(); //userGoal._id = i; //UserGoals.Insert(0, userGoal); userGoalStore.SaveAsync(UserGoals); } } catch (Exception) { Debug.WriteLine("Error Adding Usergoal"); } _sync.EndSync(); }
internal async void UpdateUserGoal(UserGoalVM userGoal) { _sync.BeginSync(); try { var a = getAuth(); var m = AutoMapper.Mapper.Map<UserGoalVM, WebAccess.ServiceReference.UserGoalVM>(userGoal); var i = (await WebClientAsyncExtensions.UpdateUserGoalTask(a, m)); await FillGoals(); userGoalStore.SaveAsync(UserGoals); } catch (Exception) { Debug.WriteLine("Error Update Usergoal"); } _sync.EndSync(); }
private void AddGoal() { SelectedGoal = null; //ds.CurrentDailyData = null; //CurrentFrame.NavigationService.Navigate(new Uri("/Views/UserGoalEdit.xaml", UriKind.Relative)); this.ShowViewModel<UserGoalEditViewModel>(); }