end of tp2
This commit is contained in:
34
.idea/.idea.BookHive/.idea/workspace.xml
generated
34
.idea/.idea.BookHive/.idea/workspace.xml
generated
@@ -7,21 +7,12 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="4c0ad985-5b6e-4587-85a5-1b48273bdb1d" name="Changes" comment="">
|
<list default="true" id="4c0ad985-5b6e-4587-85a5-1b48273bdb1d" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/BookHive/DTO/Book/GetBookDetailsDto.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/DTO/Book/GetBookDetailsDto.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/BookHive/DTO/Loan/GetLoanDto.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/DTO/Loan/GetLoanDto.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/BookHive/DTO/Review/GetReviewDto.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/DTO/Review/GetReviewDto.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/BookHive/MappingProfiles/DtoToEntityMappings.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/MappingProfiles/DtoToEntityMappings.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/MappingProfiles/EntityToDtoMappings.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.dgspec.json" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.dgspec.json" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/BookHive/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/Program.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.g.props" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.g.props" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.g.targets" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/BookHive.csproj.nuget.g.targets" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.GeneratedMSBuildEditorConfig.editorconfig" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.GeneratedMSBuildEditorConfig.editorconfig" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.assets.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.assets.cache" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.csproj.AssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/BookHive.csproj.AssemblyReference.cache" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/SwaggerExportPathInitializer.g.cs" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/Debug/net10.0/SwaggerExportPathInitializer.g.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/project.assets.json" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/project.assets.json" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/project.nuget.cache" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/project.nuget.cache" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/project.packagespec.json" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/project.packagespec.json" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/rider.project.model.nuget.info" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/rider.project.model.nuget.info" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/BookHive/obj/rider.project.restore.info" beforeDir="false" afterPath="$PROJECT_DIR$/BookHive/obj/rider.project.restore.info" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -130,7 +121,7 @@
|
|||||||
<workItem from="1773087846465" duration="527000" />
|
<workItem from="1773087846465" duration="527000" />
|
||||||
<workItem from="1773088517368" duration="6491000" />
|
<workItem from="1773088517368" duration="6491000" />
|
||||||
<workItem from="1773126764051" duration="11148000" />
|
<workItem from="1773126764051" duration="11148000" />
|
||||||
<workItem from="1773739163277" duration="475000" />
|
<workItem from="1773739163277" duration="2829000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="first commit">
|
<task id="LOCAL-00001" summary="first commit">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -188,7 +179,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1773135809527</updated>
|
<updated>1773135809527</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="8" />
|
<task id="LOCAL-00008" summary="Cleaned code">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1773739675537</created>
|
||||||
|
<option name="number" value="00008" />
|
||||||
|
<option name="presentableId" value="LOCAL-00008" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1773739675537</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="9" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -204,7 +203,8 @@
|
|||||||
<MESSAGE value="insert datas" />
|
<MESSAGE value="insert datas" />
|
||||||
<MESSAGE value="added validators in project" />
|
<MESSAGE value="added validators in project" />
|
||||||
<MESSAGE value="Created all validators" />
|
<MESSAGE value="Created all validators" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Created all validators" />
|
<MESSAGE value="Cleaned code" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Cleaned code" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ public class GetBookDetailsDto
|
|||||||
public int PageCount { get; set; }
|
public int PageCount { get; set; }
|
||||||
public DateOnly PublishedDate { get; set; }
|
public DateOnly PublishedDate { get; set; }
|
||||||
public string? Genre { get; set; }
|
public string? Genre { get; set; }
|
||||||
|
public decimal? AverageRating { get; set; }
|
||||||
|
public int? ReviewCount { get; set; }
|
||||||
|
|
||||||
public int AuthorId { get; set; }
|
public int AuthorId { get; set; }
|
||||||
|
public string? AuthorNationality { get; set; }
|
||||||
public GetAuthorDto? Author { get; set; }
|
public GetAuthorDto? Author { get; set; }
|
||||||
|
|
||||||
public List<GetReviewDto>? Reviews { get; set; }
|
public List<GetReviewDto>? Reviews { get; set; }
|
||||||
|
|||||||
@@ -8,12 +8,11 @@ public class GetLoanDto
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int BookId { get; set; }
|
public int BookId { get; set; }
|
||||||
|
public string? BookTitle { get; set; }
|
||||||
public int MemberId { get; set; }
|
public int MemberId { get; set; }
|
||||||
|
public string? MemberFullName { get; set; }
|
||||||
|
|
||||||
public DateOnly LoanDate { get; set; }
|
public DateOnly LoanDate { get; set; }
|
||||||
public DateOnly DueDate { get; set; }
|
public DateOnly DueDate { get; set; }
|
||||||
public DateOnly? ReturnDate { get; set; }
|
public DateOnly? ReturnDate { get; set; }
|
||||||
|
|
||||||
public GetBookDto? Book { get; set; }
|
|
||||||
public GetMemberDto? Member { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,12 @@ public class GetReviewDto
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int BookId { get; set; }
|
public int BookId { get; set; }
|
||||||
|
public string? BookTitle { get; set; }
|
||||||
|
|
||||||
public int MemberId { get; set; }
|
public int MemberId { get; set; }
|
||||||
|
public string? MemberFullName { get; set; }
|
||||||
|
|
||||||
public int Rating { get; set; }
|
public int Rating { get; set; }
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
public GetBookDto? Book { get; set; }
|
|
||||||
public GetMemberDto? Member { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -13,18 +13,26 @@ public class DtoToEntityMappings : Profile
|
|||||||
public DtoToEntityMappings()
|
public DtoToEntityMappings()
|
||||||
{
|
{
|
||||||
CreateMap<CreateBookDto, Book>();
|
CreateMap<CreateBookDto, Book>();
|
||||||
CreateMap<UpdateBookDto, Book>();
|
CreateMap<UpdateBookDto, Book>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||||
|
|
||||||
CreateMap<CreateAuthorDto, Author>();
|
CreateMap<CreateAuthorDto, Author>();
|
||||||
CreateMap<UpdateAuthorDto, Author>();
|
CreateMap<UpdateAuthorDto, Author>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||||
|
|
||||||
CreateMap<CreateMemberDto, Member>();
|
CreateMap<CreateMemberDto, Member>();
|
||||||
CreateMap<UpdateMemberDto, Member>();
|
CreateMap<UpdateMemberDto, Member>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.Email,
|
||||||
|
opt => opt.PreCondition(src => !string.IsNullOrEmpty(src.Email)));
|
||||||
|
|
||||||
CreateMap<CreateReviewDto, Review>();
|
CreateMap<CreateReviewDto, Review>();
|
||||||
CreateMap<UpdateReviewDto, Review>();
|
CreateMap<UpdateReviewDto, Review>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||||
|
|
||||||
CreateMap<CreateLoanDto, Loan>();
|
CreateMap<CreateLoanDto, Loan>();
|
||||||
CreateMap<UpdateLoanDto, Loan>();
|
CreateMap<UpdateLoanDto, Loan>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,16 +19,40 @@ public class EntityToDtoMappings : Profile
|
|||||||
opt.MapFrom(src =>
|
opt.MapFrom(src =>
|
||||||
src.Author!.FirstName + " " + src.Author.LastName)
|
src.Author!.FirstName + " " + src.Author.LastName)
|
||||||
);
|
);
|
||||||
CreateMap<Book, GetBookDetailsDto>();
|
CreateMap<Book, GetBookDetailsDto>()
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.AverageRating,
|
||||||
|
opt => opt.MapFrom(src => src.Reviews.Any() ? src.Reviews.Average(r => r.Rating) : 0)
|
||||||
|
)
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.ReviewCount,
|
||||||
|
opt => opt.MapFrom(src => src.Reviews.Count)
|
||||||
|
);
|
||||||
|
|
||||||
CreateMap<Author, GetAuthorDto>();
|
CreateMap<Author, GetAuthorDto>();
|
||||||
CreateMap<Author, GetAuthorDetailsDto>();
|
CreateMap<Author, GetAuthorDetailsDto>();
|
||||||
|
|
||||||
CreateMap<Loan, GetLoanDto>();
|
CreateMap<Loan, GetLoanDto>()
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.BookTitle,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Book!.Title))
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.MemberFullName,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Member!.FirstName + ' ' + src.Member!.LastName));
|
||||||
|
|
||||||
CreateMap<Member, GetMemberDto>();
|
CreateMap<Member, GetMemberDto>();
|
||||||
CreateMap<Member, GetMemberDetailsDto>();
|
CreateMap<Member, GetMemberDetailsDto>();
|
||||||
|
|
||||||
CreateMap<Review, GetReviewDto>();
|
CreateMap<Review, GetReviewDto>()
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.BookTitle,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Book!.Title))
|
||||||
|
.ForMember(
|
||||||
|
dest => dest.MemberFullName,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Member!.FirstName + ' ' + src.Member!.LastName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
using AutoMapper;
|
|
||||||
using AutoMapper.EquivalencyExpression;
|
using AutoMapper.EquivalencyExpression;
|
||||||
using BookHive;
|
using BookHive;
|
||||||
using BookHive.MappingProfiles;
|
|
||||||
using BookHive.Repositories;
|
using BookHive.Repositories;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using FastEndpoints.Security;
|
using FastEndpoints.Security;
|
||||||
@@ -38,16 +36,20 @@ builder.Services.AddScoped<LoanRepository>();
|
|||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
MapperConfiguration mappingConfig = new(mc =>
|
builder.Services.AddAutoMapper(cfg =>
|
||||||
{
|
{
|
||||||
mc.AddCollectionMappers();
|
cfg.AddCollectionMappers();
|
||||||
mc.AddProfile(new DtoToEntityMappings());
|
}, typeof(Program).Assembly);
|
||||||
mc.AddProfile(new EntityToDtoMappings());
|
|
||||||
}, new LoggerFactory());
|
|
||||||
|
|
||||||
|
// MapperConfiguration mappingConfig = new(mc =>
|
||||||
|
// {
|
||||||
|
// mc.AddCollectionMappers();
|
||||||
|
// mc.AddProfile(new DtoToEntityMappings());
|
||||||
|
// mc.AddProfile(new EntityToDtoMappings());
|
||||||
|
// }, new LoggerFactory());
|
||||||
|
|
||||||
AutoMapper.IMapper mapper = mappingConfig.CreateMapper();
|
// AutoMapper.IMapper mapper = mappingConfig.CreateMapper();
|
||||||
builder.Services.AddSingleton(mapper);
|
// builder.Services.AddSingleton(mapper);
|
||||||
|
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
app.UseAuthentication()
|
||||||
|
|||||||
Reference in New Issue
Block a user