예제 #1
0
        public IActionResult Update(FinishedLesson newFinisedLesson)
        {
            FinishedLesson updatedFinishedLesson = finishedLessonInteractor.update(newFinisedLesson);

            if (updatedFinishedLesson != null)
            {
                return(Ok());
            }
            return(StatusCode(500));
        }
예제 #2
0
        public ActionResult Create(FinishedLesson finishedLesson)
        {
            FinishedLesson createdFinishedLesson = finishedLessonInteractor.create(finishedLesson);

            if (createdFinishedLesson == null)
            {
                return(StatusCode(409));
            }
            return(Ok());
        }
예제 #3
0
        public ActionResult <FinishedLesson> Get(int id)
        {
            FinishedLesson finishedLesson = finishedLessonInteractor.get(id);

            if (finishedLesson == null)
            {
                return(NotFound());
            }
            return(finishedLesson);
        }
예제 #4
0
        public FinishedLesson create(FinishedLesson finishedLesson)
        {
            if (isLessonAlreadyPresent(finishedLesson))
            {
                return(null);
            }
            _repository.create(finishedLesson);
            FinishedLesson createdLesson = _repository.get(finishedLesson.IDFinishedLesson);

            return(createdLesson);
        }
예제 #5
0
 public static FinishedLesson mapModel(FinishedLesson oldLesson, FinishedLesson newLesson)
 {
     if (!FinishedLessonValidator.validateFinishedLesson(newLesson))
     {
         return(null);
     }
     oldLesson.IDFinishedLesson   = newLesson.IDFinishedLesson;
     oldLesson.IDLesson           = newLesson.IDLesson;
     oldLesson.IDCourseInProgress = newLesson.IDCourseInProgress;
     return(oldLesson);
 }
예제 #6
0
        public void delete(int id)
        {
            FinishedLesson lessonToDelete = _context.FinishedLessons.FirstOrDefault(
                lesson => lesson.IDFinishedLesson == id);

            if (lessonToDelete != null)
            {
                _context.FinishedLessons.Remove(lessonToDelete);
                _context.SaveChanges();
            }
            return;
        }
예제 #7
0
        private bool isLessonAlreadyPresent(FinishedLesson fl)
        {
            int courseId = fl.IDCourseInProgress;
            List <FinishedLesson> allLessonFromCourse = getFromCourseInProgress(courseId);

            foreach (FinishedLesson lesson in allLessonFromCourse)
            {
                if (lesson.IDLesson == fl.IDLesson)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #8
0
        public FinishedLesson update(FinishedLesson newFinishedLesson)
        {
            FinishedLesson oldFinishedLesson = _repository.get(newFinishedLesson.IDFinishedLesson);

            if (oldFinishedLesson == null)
            {
                return(null);
            }
            oldFinishedLesson = FinishedLessonMapper.mapModel(oldFinishedLesson, newFinishedLesson);
            if (oldFinishedLesson == null)
            {
                return(null);
            }
            _repository.update(oldFinishedLesson);
            return(oldFinishedLesson);
        }
예제 #9
0
 public void update(FinishedLesson finishedLesson)
 {
     _context.FinishedLessons.Update(finishedLesson);
     _context.SaveChanges();
     return;
 }
예제 #10
0
 public FinishedLesson create(FinishedLesson finishedLesson)
 {
     _context.Add(finishedLesson);
     _context.SaveChanges();
     return(finishedLesson);
 }
예제 #11
0
 static public bool validateFinishedLesson(FinishedLesson lesson)
 {
     return(lesson != null && lesson.IDLesson != 0 && lesson.IDCourseInProgress != 0 &&
            lesson.IDFinishedLesson != 0);
 }