コード例 #1
0
        public void AddWorkout()
        {
            if (SelectedBodyPartItem == null || string.IsNullOrEmpty(WorkoutTitle))
            {
                return;
            }

            var workout = new Models.Workout.Workout()
            {
                AddedDate          = DateTime.Now,
                TargetBodyPart     = SelectedBodyPartItem.BodyPart,
                WorkoutTitle       = WorkoutTitle,
                WorkoutDescription = WorkoutDescription,
                Image     = Image,
                VideoLink = VideoLink
            };

            using var db = new AppDbContext();
            db.Workouts.Add(workout);
            db.SaveChanges();

            Workouts.Insert(0, workout);
            WorkoutTitle       = "";
            WorkoutDescription = "";
            VideoLink          = "";
            Image = null;
        }
コード例 #2
0
 // receives the changed workout and updates current listview and sendable object
 void ChangedWorkoutCell(WorkoutModel watchObject)
 {
     for (int i = 0; i < Workouts.Count; i++)
     {
         if (Workouts[i].Name == watchObject.Name)
         {
             Workouts.RemoveAt(i);
             Workouts.Insert(i, watchObject);
             CollectionToNewWatchModel(Workouts, globalWatchModelHold);
             return;
         }
     }
 }