public async Task <ActionResult <WorkoutItem> > PostTodoItem(WorkoutItem item)
        {
            _context.WorkoutItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetWorkoutItem), new { id = item.Id }, item));
        }
Example #2
0
        async Task CompleteItem(WorkoutItem item)
        {
            await managerWorkout.DeleteItemAsync(item, true);


            workoutList.ItemsSource = await ReturnRefreshedItem(false);
        }
Example #3
0
        public async void OnComplete(object sender, EventArgs e)
        {
            var mi = ((MenuItem)sender);


            var Workout = WorkoutItem.ConvertToWorkoutItem((MapPreparedData)mi.CommandParameter);


            await CompleteItem(Workout);
        }
 public void Create([FromBody] WorkoutItem item)
 {
     try
     {
         WorkoutItems.Add(item);
     }
     catch (Exception e)
     {
         Console.WriteLine($"ERROR: {e}");
     }
 }
        // Remove a to-do task item from the database and collections.
        public void DeleteWorkoutItem(WorkoutItem workoutForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            WorkoutItems.Remove(workoutForDelete);

            // Remove the to-do item from the data context.
            stepTrackerDB.Items.DeleteOnSubmit(workoutForDelete);

            // Save changes to the database.
            stepTrackerDB.SubmitChanges();
        }
        //private void settingsGrid_Tap(object sender, GestureEventArgs e)
        //{
        //    System.Diagnostics.Debug.WriteLine("settingsGrid_Tap");
        //    NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
        //}

        // MH: WPControl Event Handlers
        /// <summary>
        /// Will transfer to the summary page with information from the model/database on a selected date, otherwise show
        /// just a message box saying no steps were recorded that day
        /// </summary>
        private void Cal_DateClicked(object sender, WPControls.SelectionChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Cal_DateClicked fired.  New date is " + e.SelectedDate.ToString());
            WorkoutItem workoutItem = App.ViewModel.FindWorkoutItem(e.SelectedDate);

            if (workoutItem != null)
            {
                NavigationService.Navigate(new Uri("/SummaryPage.xaml?steps=" + workoutItem.StepsTaken + "&calories=" + workoutItem.CaloriesBurned + "&time=" + workoutItem.ElapsedTime + "&fromCal=1", UriKind.Relative));
            }
            else
            {
                MessageBox.Show("No workout recorded for this day");
            }
        }
Example #7
0
        public HttpResponseMessage WorkoutsByCategory(string category)
        {
            HttpResponseMessage response;

            try
            {
                WorkoutItem workout = WorkoutManager.GetWorkoutByCategory(category);
                response = Request.CreateResponse(HttpStatusCode.OK, workout);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, new StandardResponse(ex));
            }

            return(response);
        }
        public static MapPreparedData ConvertToPreparedData(WorkoutItem data)
        {
            MapPreparedData CovertedObj = new MapPreparedData
            {
                WorkoutId    = data.Id,
                StartTime    = new DateTime(data.WorkoutDate + time40l.Ticks),
                RoadDistance = new Distance(data.Distance),
                Time         = new DateTime(data.Time),
                MaxSpeed     = data.MaxSpeed,
                MediumSpeed  = data.MediumSpeed,
                MaxAltitude  = data.MaxAltitude,
                MinAltitude  = data.MinAltitude
            };

            return(CovertedObj);
        }
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            FillFields(resultData);

            if (workoutManager != null)
            {
                sendWorkout = new WorkoutItem(resultData);
                await workoutManager.SaveItemAsync(sendWorkout, false);

                if (resultRoad.Count > 0)
                {
                    AddPath.IsEnabled = true;
                }
            }
        }
Example #10
0
        public void WorkoutItem_ReturnsNewWorkoutItem()
        {
            WorkoutItem workoutItem = new WorkoutItem
            {
                Id          = "ItemId",
                Workout     = WorkoutType.Run,
                DistanceKm  = 5,
                Duration    = new TimeSpan(0, 5, 32),
                WorkoutDate = new DateTime(2016, 1, 10)
            };

            Assert.Equal("ItemId", workoutItem.Id);
            Assert.Equal(WorkoutType.Run, workoutItem.Workout);
            Assert.Equal(5, workoutItem.DistanceKm);
            Assert.Equal("00:05:32", workoutItem.Duration.ToString());
            Assert.Equal(0, workoutItem.Reps);
            Assert.Equal(0, workoutItem.Set);
            Assert.Equal(new DateTime(2016, 1, 10), workoutItem.WorkoutDate);
        }
        // Add a to-do item to the database and collections.
        public void AddWorkoutItem(WorkoutItem newWorkoutItem)
        {
            // this app maintains only one workout per day, hence if there is a second one, delete it
            var workoutItemsInDB = from WorkoutItem workout in stepTrackerDB.Items
                                   where workout.TimeTaken == newWorkoutItem.TimeTaken
                                   select workout;

            foreach (var item in workoutItemsInDB)
            {
                DeleteWorkoutItem(item);
            }


            // Add a to-do item to the data context.

            stepTrackerDB.Items.InsertOnSubmit(newWorkoutItem);

            // Save changes to the database.
            stepTrackerDB.SubmitChanges();

            // Add a to-do item to the "all" observable collection.
            WorkoutItems.Add(newWorkoutItem);
        }
Example #12
0
        public async Task <ActionResult <WorkoutItem> > Put(WorkoutItem WorkoutItem)
        {
            var updatedWorkoutItem = await dataService.UpdateAsync <WorkoutItem, WorkoutItemBusiness>(WorkoutItem);

            return(Ok(updatedWorkoutItem));
        }
Example #13
0
        public async Task <ActionResult <WorkoutItem> > Post(WorkoutItem WorkoutItem)
        {
            var insertedWorkoutItem = await dataService.AddAsync <WorkoutItem, WorkoutItemBusiness>(WorkoutItem);

            return(Ok(insertedWorkoutItem));
        }