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(); } }
public void Insert_A_Task() { var task = new PracticeTask() { Title = "Here is my first goal", DateCreated = DateTime.Now, GoalTaskType = 1, TargetPracticeDuration = 10, TargetSpeed = 120, Exercise = new Exercise() { Title = "Exercise Title", DifficultyRating = 3, RequiredDuration = 520, DateCreated = DateTime.Now }, Description = "My Description" }; DataAccess dataAccess = new DataAccess(); dataAccess.InsertTask(task); }