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.3 KiB
31 lines
1.3 KiB
using Dto;
|
|
using Entities;
|
|
using Model.OrderCriteria;
|
|
using Shared;
|
|
using Shared.Mapper;
|
|
|
|
namespace API.Service;
|
|
|
|
public class ParagraphDataServiceApi(IParagraphService<ParagraphEntity> paragraphService)
|
|
: IParagraphService<ParagraphDTO>
|
|
{
|
|
public IEnumerable<ParagraphDTO> GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria)
|
|
{
|
|
var paragraphsEntities = paragraphService.GetParagraphs(page, number, orderCriteria);
|
|
return paragraphsEntities.Select(e => e.FromEntityToDTO()).ToList();
|
|
}
|
|
|
|
public ParagraphDTO GetParagraphById(int id) => paragraphService.GetParagraphById(id).FromEntityToDTO();
|
|
|
|
public ParagraphDTO GetParagraphByTitle(string title) =>
|
|
paragraphService.GetParagraphByTitle(title).FromEntityToDTO();
|
|
|
|
public bool DeleteParagraph(int id) => paragraphService.DeleteParagraph(id);
|
|
|
|
public ParagraphDTO UpdateParagraph(int id, ParagraphDTO paragraph) =>
|
|
paragraphService.UpdateParagraph(id, paragraph.FromDTOToEntity()).FromEntityToDTO();
|
|
|
|
public ParagraphDTO CreateParagraph(string title, string content, string info, string query, string comment,
|
|
int lessonId) =>
|
|
paragraphService.CreateParagraph(title, content, info, query, comment, lessonId).FromEntityToDTO();
|
|
} |