public IActionResult Update(FinishedLesson newFinisedLesson) { FinishedLesson updatedFinishedLesson = finishedLessonInteractor.update(newFinisedLesson); if (updatedFinishedLesson != null) { return(Ok()); } return(StatusCode(500)); }
public ActionResult Create(FinishedLesson finishedLesson) { FinishedLesson createdFinishedLesson = finishedLessonInteractor.create(finishedLesson); if (createdFinishedLesson == null) { return(StatusCode(409)); } return(Ok()); }
public ActionResult <FinishedLesson> Get(int id) { FinishedLesson finishedLesson = finishedLessonInteractor.get(id); if (finishedLesson == null) { return(NotFound()); } return(finishedLesson); }
public FinishedLesson create(FinishedLesson finishedLesson) { if (isLessonAlreadyPresent(finishedLesson)) { return(null); } _repository.create(finishedLesson); FinishedLesson createdLesson = _repository.get(finishedLesson.IDFinishedLesson); return(createdLesson); }
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); }
public void delete(int id) { FinishedLesson lessonToDelete = _context.FinishedLessons.FirstOrDefault( lesson => lesson.IDFinishedLesson == id); if (lessonToDelete != null) { _context.FinishedLessons.Remove(lessonToDelete); _context.SaveChanges(); } return; }
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); }
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); }
public void update(FinishedLesson finishedLesson) { _context.FinishedLessons.Update(finishedLesson); _context.SaveChanges(); return; }
public FinishedLesson create(FinishedLesson finishedLesson) { _context.Add(finishedLesson); _context.SaveChanges(); return(finishedLesson); }
static public bool validateFinishedLesson(FinishedLesson lesson) { return(lesson != null && lesson.IDLesson != 0 && lesson.IDCourseInProgress != 0 && lesson.IDFinishedLesson != 0); }