This commit is contained in:
Dmitrii Kollerov
2026-09-25 08:05:46 +03:00
parent 2b05c26eb3
commit 68da43a673
29 changed files with 867 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
using System;
using example_csharp_app.Dto;
using example_csharp_app.Models.Model;
namespace example_csharp_app.Models.Mapper;
public static class BookMapper
{
public static BookModel MapToModel(this BookDto dto)
{
return new BookModel()
{
Author = dto.Author,
BookIndex = dto.BookIndex,
Id = dto.Id,
Title = dto.Title,
YearPublished = dto.YearPublished
};
}
public static BookDto MapToDto(this BookCreateModel model)
{
return new BookDto()
{
Id = Guid.NewGuid(),
Author = model.Author,
BookIndex = model.BookIndex,
Title = model.Title,
YearPublished = model.YearPublished
};
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
using example_csharp_app.Models.Model;
using example_csharp_app.Models.Request;
namespace example_csharp_app.Models.Mapper;
public static class RequestMapper
{
public static BookCreateModel MapToModel(this BookCreateRequest request)
{
return new BookCreateModel()
{
Author = request.Author,
BookIndex = request.BookIndex.Trim(),
Title = request.Title,
YearPublished = request.YearPublished
};
}
public static BookUpdateModel MapToModel(this BookUpdateRequest request)
{
return new BookUpdateModel()
{
Author = request.Author,
BookIndex = request.BookIndex.Trim(),
Title = request.Title,
YearPublished = request.YearPublished
};
}
}