Esempio n. 1
0
        public IActionResult Update(FinishedLesson newFinisedLesson)
        {
            FinishedLesson updatedFinishedLesson = finishedLessonInteractor.update(newFinisedLesson);

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

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

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

            return(createdLesson);
        }
Esempio n. 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);
 }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 9
0
 public void update(FinishedLesson finishedLesson)
 {
     _context.FinishedLessons.Update(finishedLesson);
     _context.SaveChanges();
     return;
 }
Esempio n. 10
0
 public FinishedLesson create(FinishedLesson finishedLesson)
 {
     _context.Add(finishedLesson);
     _context.SaveChanges();
     return(finishedLesson);
 }
Esempio n. 11
0
 static public bool validateFinishedLesson(FinishedLesson lesson)
 {
     return(lesson != null && lesson.IDLesson != 0 && lesson.IDCourseInProgress != 0 &&
            lesson.IDFinishedLesson != 0);
 }