示例#1
0
        public void InsertExercise(Exercise exercise)
        {
            if (exercise.Id > 0)
            {
                throw new ArgumentException("A new exercise cannot have an id");
            }

            using (var context = new SmartSessionContext())
            {
                context.Exercises.Add(exercise);
                context.SaveChanges();
            }
        }
示例#2
0
        public void InsertTask(PracticeTask task)
        {
            if (task.Id > 0)
            {
                throw new ArgumentException("A new task cannot have an id");
            }

            using (var context = new SmartSessionContext())
            {
                context.Tasks.Add(task);
                context.SaveChanges();
            }
        }
示例#3
0
        public void InsertGoal(Goal goal)
        {
            if (goal.Id > 0)
            {
                throw new ArgumentException("A new goal cannot have an id");
            }

            using (var context = new SmartSessionContext())
            {
                context.Goals.Add(goal);
                // context.Add(goal); // for polymorphic inserts.
                // context is now tracking the goal.
                context.SaveChanges(); // now is saved.
            }
        }