59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using DataProviders;
|
|
using DomainResults.Common;
|
|
|
|
using WeatherForecast.Models.Responses;
|
|
|
|
namespace WeatherForecast.Services {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public interface IContentService {
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="siteId"></param>
|
|
/// <param name="locale"></param>
|
|
/// <returns></returns>
|
|
(ContentResponseModel?, IDomainResult) GetContent(Guid siteId, string locale);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class ContentService : IContentService {
|
|
|
|
private readonly ILogger<ContentService> _logger;
|
|
private readonly IContentDataProvider _contentDataProvider;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="logger"></param>
|
|
/// <param name="contentDataprovider"></param>
|
|
public ContentService(
|
|
ILogger<ContentService> logger,
|
|
IContentDataProvider contentDataprovider
|
|
) {
|
|
_logger = logger;
|
|
_contentDataProvider = contentDataprovider;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="siteId"></param>
|
|
/// <param name="locale"></param>
|
|
/// <returns></returns>
|
|
public (ContentResponseModel?, IDomainResult) GetContent(Guid siteId, string locale) {
|
|
var (content, result) = _contentDataProvider.Get(siteId, locale);
|
|
|
|
if (!result.IsSuccess || content == null)
|
|
return (null, result);
|
|
|
|
return IDomainResult.Success(new ContentResponseModel(content));
|
|
}
|
|
}
|
|
}
|