public async void DoClose() { entereduUser = new UserTableDatabaseAzure(); var details = await entereduUser.GetUser(); foreach (var detail in details) { if (detail.Name == "Kazuko") { _userid = detail.Id; } } entered.UserID = _userid; entered.FoodID = _foodid; entered.Date = DateTime.Now; enteredFood = new FoodEnteredTableDatabaseAzure(); bool _checked = await enteredFood.CheckIfExists(entered); if (!_checked) { await enteredFood.InsertFood(entered); } //Close(JourneyFoodViewModel); Close(this); }
public async Task <string> getuserid() { string _userid = ""; enteredUser = new UserTableDatabaseAzure(); var details = await enteredUser.GetUser(); foreach (var detail in details) { if (detail.Name == "Kazuko") { _userid = detail.Id; } } return(_userid); }
public async void Adding() { exer.Name = JourneyExerciseViewModel.Name; exer.ExerciseType = "Running"; bool NameCorrect = (exer.Name != null && exer.Name != ""); bool DistanceCorrect = true; int DistanceVal = 0; DistanceCorrect = int.TryParse(Distance, out DistanceVal); exer.Distance = DistanceVal; bool DurationCorrect = true; int DurationVal = 0; DurationCorrect = int.TryParse(Duration, out DurationVal); exer.Duration = DurationVal; bool BurnedCorrect = true; int BurnedVal = 0; BurnedCorrect = int.TryParse(BurnedCalories, out BurnedVal); exer.Calories = BurnedVal; bool correctValues = (NameCorrect && DistanceCorrect && DurationCorrect && BurnedCorrect); if (correctValues) { exerdatabase = new ExerciseTableDatabaseAzure(); await exerdatabase.InsertExercise(exer); var details = await exerdatabase.GetConnection(); foreach (var detail in details) { if (detail.Name == exer.Name && detail.ExerciseType == exer.ExerciseType && detail.Distance == exer.Distance && detail.Duration == exer.Duration && detail.Calories == exer.Calories) { exer.Id = detail.Id; } } string _exerciseid = exer.Id; string _userid = ""; entereduUser = new UserTableDatabaseAzure(); var users = await entereduUser.GetUser(); foreach (var user in users) { if (user.Name == "Kazuko") { _userid = user.Id; } } entered.UserID = _userid; entered.ExerciseID = _exerciseid; entered.Date = DateTime.Now; enteredExercise = new ExerciseEnteredTableDatabaseAzure(); bool _checked = await enteredExercise.CheckIfExists(entered); if (!_checked) { await enteredExercise.InsertExercise(entered); Close(this); } } }