60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using DomainResults.Common;
|
|
|
|
using DataProviders.Collections;
|
|
|
|
using Core.Abstractions;
|
|
using WeatherForecast.Models.Content.Responses;
|
|
using WeatherForecast.Models.Content.Requests;
|
|
|
|
namespace WeatherForecast.Services {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public interface IContentService {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="siteId"></param>
|
|
/// <param name="requestData"></param>
|
|
/// <returns></returns>
|
|
(GetContentResponseModel?, IDomainResult) GetContent(Guid siteId, GetContentRequestModel requestData);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class ContentService : ServiceBase<ContentService>, IContentService {
|
|
|
|
private readonly IContentDataProvider _contentDataProvider;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="logger"></param>
|
|
/// <param name="contentDataprovider"></param>
|
|
public ContentService(
|
|
ILogger<ContentService> logger,
|
|
IContentDataProvider contentDataprovider
|
|
) : base(logger) {
|
|
_contentDataProvider = contentDataprovider;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="siteId"></param>
|
|
/// <param name="requestData"></param>
|
|
/// <returns></returns>
|
|
public (GetContentResponseModel?, IDomainResult) GetContent(Guid siteId, GetContentRequestModel requestData) {
|
|
var (content, result) = _contentDataProvider.Get(siteId);
|
|
if (!result.IsSuccess || content == null)
|
|
return (null, result);
|
|
|
|
|
|
return IDomainResult.Success(new GetContentResponseModel(content, requestData.Locale));
|
|
}
|
|
}
|
|
}
|