init
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace example_csharp_app.Models.Model;
|
||||
|
||||
public class BookCreateModel
|
||||
{
|
||||
public string Title { set; get; } = string.Empty;
|
||||
public string Author { set; get; } = string.Empty;
|
||||
public DateTime YearPublished { set; get; }
|
||||
public string BookIndex { set; get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace example_csharp_app.Models.Model;
|
||||
|
||||
public class BookModel
|
||||
{
|
||||
public Guid Id { set; get; }
|
||||
public string Title { set; get; } = string.Empty;
|
||||
public string Author { set; get; } = string.Empty;
|
||||
public DateTime YearPublished { set; get; }
|
||||
public string BookIndex { set; get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace example_csharp_app.Models.Model;
|
||||
|
||||
public class BookUpdateModel
|
||||
{
|
||||
public string Title { set; get; } = string.Empty;
|
||||
public string Author { set; get; } = string.Empty;
|
||||
public DateTime YearPublished { set; get; }
|
||||
public string BookIndex { set; get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using example_csharp_app.Filters;
|
||||
|
||||
namespace example_csharp_app.Models.Request;
|
||||
|
||||
public class BookCreateRequest
|
||||
{
|
||||
[Required]
|
||||
public string Title { set; get; } = string.Empty;
|
||||
[Required]
|
||||
public string Author { set; get; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime YearPublished { set; get; }
|
||||
[Required, Xml]
|
||||
public string BookIndex { set; get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace example_csharp_app.Models.Request;
|
||||
|
||||
public class BookFilterRequest
|
||||
{
|
||||
public string? Author { set; get; }
|
||||
public string? Index { set; get; }
|
||||
public string? Title { set; get; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using example_csharp_app.Filters;
|
||||
|
||||
namespace example_csharp_app.Models.Request;
|
||||
|
||||
public class BookUpdateRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid Id { set; get; } = Guid.Empty;
|
||||
[Required]
|
||||
public string Title { set; get; } = string.Empty;
|
||||
[Required]
|
||||
public string Author { set; get; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime YearPublished { set; get; }
|
||||
[Required, Xml]
|
||||
public string BookIndex { set; get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using example_csharp_app.Models.Model;
|
||||
|
||||
namespace example_csharp_app.Models.Response;
|
||||
|
||||
public class BookListResponse
|
||||
{
|
||||
public IReadOnlyCollection<BookModel> Books { set; get; } = [];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace example_csharp_app.Models.Response;
|
||||
|
||||
public class BookOperationResponse
|
||||
{
|
||||
public bool IsSuccess { set; get; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using example_csharp_app.Models.Model;
|
||||
|
||||
namespace example_csharp_app.Models.Response;
|
||||
|
||||
public class BookSingleResponse
|
||||
{
|
||||
public BookModel? Book { set; get; }
|
||||
}
|
||||
Reference in New Issue
Block a user