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.
API_SQLuedo/API_SQLuedo/API/Service/ParagraphDataServiceAPI.cs

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();
}