You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
31 lines
1.2 KiB
using Dto;
|
|
using Entities;
|
|
using Model.OrderCriteria;
|
|
using Shared;
|
|
using Shared.Mapper;
|
|
|
|
namespace API.Service;
|
|
|
|
public class LessonDataServiceApi(ILessonService<LessonEntity> lessonService) : ILessonService<LessonDto>
|
|
{
|
|
public IEnumerable<LessonDto> GetLessons(int page, int number, LessonOrderCriteria orderCriteria)
|
|
{
|
|
var lessonsEntities = lessonService.GetLessons(page, number, orderCriteria);
|
|
return lessonsEntities.Select(e => e.FromEntityToDto()).ToList();
|
|
}
|
|
|
|
public LessonDto GetLessonById(int id) => lessonService.GetLessonById(id).FromEntityToDto();
|
|
|
|
public LessonDto GetLessonByTitle(string title) => lessonService.GetLessonByTitle(title).FromEntityToDto();
|
|
|
|
public bool DeleteLesson(int id) => lessonService.DeleteLesson(id);
|
|
|
|
public LessonDto UpdateLesson(int id, LessonDto lesson) =>
|
|
lessonService.UpdateLesson(id, lesson.FromDtoToEntity()).FromEntityToDto();
|
|
|
|
public LessonDto UpdateLesson(int id, LessonEntity lesson) =>
|
|
lessonService.UpdateLesson(id, lesson).FromEntityToDto();
|
|
|
|
public LessonDto CreateLesson(int id, string title, string lastPublisher, DateOnly lastEdit) =>
|
|
lessonService.CreateLesson(id, title, lastPublisher, lastEdit).FromEntityToDto();
|
|
} |