コード例 #1
0
        public void SaveTutorial()
        {
            var tutorialFacade = new TutorialFacade();

            var tut = new Tutorial();
            tut.Description = "Learn Grammar";
            tut.FullFilePath = "/uploads/Grammar.mp4";
            tut.Grade = "2";
            tut.Subject = "1"; // denotes english subject

            tutorialFacade.SaveTutorial(tut);

            Assert.IsTrue(tut.Id > 0);
        }
コード例 #2
0
 public void SaveTutorial(Tutorial tutorial)
 {
     _dataAccess.SaveTutorial(tutorial);
 }
コード例 #3
0
        public void SaveTutorial(Tutorial tutorial)
        {
            int courseGradeId = FindCourseId(tutorial.Subject, tutorial.Grade);

            if (courseGradeId > 0)
            {
                tutorial.CourseGradeId = courseGradeId;
                _dataContext.Tutorial.Add(tutorial);
                _dataContext.SaveChanges();
            }
            else
            {
                throw new InvalidOperationException("Unable to find course and grade");
            }
        }