加入專案檔案。
This commit is contained in:
33
CoreProfilerExample.Service/Extensions/MapperExtension.cs
Normal file
33
CoreProfilerExample.Service/Extensions/MapperExtension.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using CoreProfilerExample.Repository.Models.DataModels;
|
||||
using CoreProfilerExample.Service.Models.Dtos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user