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.
70 lines
1.9 KiB
70 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DTO;
|
|
using Entity;
|
|
using Shared;
|
|
using Dto2Entities;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace ServicesApi
|
|
{
|
|
public class SourceService : ISourceService<SourceDTO>
|
|
{
|
|
private ISourceService<Source> srcService;
|
|
|
|
public SourceService(ISourceService<Source> src)
|
|
{
|
|
srcService = src;
|
|
}
|
|
public async Task AddSource(SourceDTO source)
|
|
{
|
|
await srcService.AddSource(source.ToEntity());
|
|
}
|
|
|
|
public async Task<PaginationResult<SourceDTO>> GetAll()
|
|
{
|
|
var sources = srcService.GetAll().Result.items;
|
|
return new PaginationResult<SourceDTO>(sources.Count(), 0, 10, sources.ToDto());
|
|
}
|
|
|
|
public async Task<int> GetLastSourceId()
|
|
{
|
|
return await srcService.GetLastSourceId();
|
|
}
|
|
|
|
public async Task<SourceDTO> GetSourceByDate(string date)
|
|
{
|
|
return srcService.GetSourceByDate(date).Result.ToDto();
|
|
}
|
|
|
|
public async Task<SourceDTO> GetSourceById(int id)
|
|
{
|
|
return srcService.GetSourceById(id).Result.ToDto();
|
|
}
|
|
|
|
public async Task<SourceDTO> GetSourceByTitle(string title)
|
|
{
|
|
return srcService.GetSourceByTitle(title).Result.ToDto();
|
|
}
|
|
|
|
public async Task<SourceDTO> GetSourceByType(string type)
|
|
{
|
|
return srcService.GetSourceByType(type).Result.ToDto();
|
|
}
|
|
|
|
public async Task RemoveSource(int id)
|
|
{
|
|
await srcService.RemoveSource(id);
|
|
}
|
|
|
|
public async Task UpdateSource(int id, SourceDTO source)
|
|
{
|
|
await srcService.UpdateSource(id, source.ToEntity());
|
|
}
|
|
}
|
|
}
|