예제 #1
0
        public int WriteWorkout(WorkoutItem w)
        {
            /*return the ID of the workout after it's been added*/
            /*Write the WorkoutItem (which is in our ViewModel) to the WorkoutItemDB and SetDB models*/
            WorkoutItemDB wi = new WorkoutItemDB
            {
                Name = w.Name,
                Date = w.Date.ToString("yyyy-MM-dd"),
                Unit = w.Unit
            };
            int t = _connection.Insert(wi);

            System.Diagnostics.Debug.WriteLine("LINES WRITTEN: " + t);

            string sql = @"select last_insert_rowid()";
            int    key = _connection.ExecuteScalar <int>(sql);

            foreach (double d in w.Set)
            {
                SetDB s = new SetDB
                {
                    WorkoutItemID = key,
                    Amount        = d
                };
                t = _connection.Insert(s);
                System.Diagnostics.Debug.WriteLine("LINES WRITTEN: " + t);
            }
            return(key);
        }
예제 #2
0
        public void RemoveWorkout(WorkoutItem w)
        {
            // delete the workout
            WorkoutItemDB wi = new WorkoutItemDB
            {
                ID = w.ID
            };

            _connection.Delete(wi);

            // delete the sets that belong to that ID
            _connection.Execute("DELETE FROM [SetDB] WHERE [WorkoutItemID] = ?", w.ID);
        }