29 lines
881 B
C#
29 lines
881 B
C#
using CoreProfilerExample.Repository.Models.DataModels;
|
|
using CoreProfilerExample.Service.Models.Dtos;
|
|
|
|
namespace CoreProfilerExample.Service.Extensions
|
|
{
|
|
public static class MapperExtension
|
|
{
|
|
public static async Task<GetWeatherForecastDto> ToDtoAsync(this Task<IEnumerable<WeatherForecastDataModel>> task)
|
|
{
|
|
var dataModels = await task;
|
|
|
|
return new GetWeatherForecastDto
|
|
{
|
|
WeatherForecasts = dataModels.Select(model => model.ToDto()),
|
|
};
|
|
}
|
|
|
|
public static GetWeatherForecastItemDto ToDto(this WeatherForecastDataModel dataModel)
|
|
{
|
|
return new GetWeatherForecastItemDto
|
|
{
|
|
Date = dataModel.Date,
|
|
Summary = dataModel.Summary,
|
|
TemperatureC = dataModel.TemperatureC,
|
|
};
|
|
}
|
|
}
|
|
}
|