From a18976d34f0b68d2c175e706c57accc61efe36bb Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Thu, 29 Feb 2024 17:07:48 +0330 Subject: [PATCH] feat : add blog controller and entities --- .../AppSettings/appsettings.Development.json | 4 +- HiVakil.Api/Controller/AuthController.cs | 64 ++ .../Controller/BlogCategoryController.cs | 48 + HiVakil.Api/Controller/BlogController.cs | 48 + HiVakil.Api/HiVakil.Api.csproj | 5 + HiVakil.Api/Program.cs | 4 +- HiVakil.Api/Properties/launchSettings.json | 4 +- .../Configurations/ServiceExtensions.cs | 3 +- .../Commands/BlogCategoryCommands.cs | 5 + .../CommandQueries/Commands/BlogCommands.cs | 7 + .../Queries/BlogCategoryQueries.cs | 4 + .../CommandQueries/Queries/BlogQueries.cs | 4 + .../Dtos/LargDto/BlogCategoryLDto.cs | 11 + HiVakil.Domain/Dtos/LargDto/BlogLDto.cs | 16 + .../Dtos/RequestDto/LoginRequestDto.cs | 8 + .../Dtos/ResponseDto/GetBlogsResponseDto.cs | 7 + .../Dtos/ResponseDto/PagerResponseDto.cs | 8 + .../Dtos/SmallDtos/BlogCategorySDto.cs | 9 + HiVakil.Domain/Dtos/SmallDtos/BlogSDto.cs | 15 + .../Entities/Blogs/Blog.Aggregate.cs | 35 + HiVakil.Domain/Entities/Blogs/Blog.cs | 34 + HiVakil.Domain/Entities/Blogs/BlogCategory.cs | 21 + .../Entities/Blogs/BlogStorageFile.cs | 16 + .../LawyerCategories/LawyerCategory.cs | 9 + .../LawyerCategories/LawyerCategoryUser.cs | 10 + .../Entities/LegalForms/LegalForm.cs | 10 + .../Entities/LegalRequests/LegalRequest.cs | 10 + HiVakil.Domain/Entities/Payments/Payment.cs | 17 + .../Entities/Reviews/LawyerReview.cs | 7 + HiVakil.Domain/Entities/Reviews/Review.cs | 8 + .../Entities/Users/ApplicationUser.cs | 3 + HiVakil.Domain/Entities/Users/Lawyer.cs | 6 + .../Entities/Users/UserCallRequest.cs | 9 + HiVakil.Domain/Enums/LegalFormStatus.cs | 6 + HiVakil.Domain/Enums/LegalFormType.cs | 6 + HiVakil.Domain/Enums/LegalRequestStatus.cs | 6 + HiVakil.Domain/Enums/LegalRequestType.cs | 6 + HiVakil.Domain/Enums/PaymentStatus.cs | 13 + HiVakil.Domain/Enums/PaymentType.cs | 13 + HiVakil.Domain/Enums/ReviewType.cs | 7 + HiVakil.Domain/HiVakil.Domain.csproj | 10 +- .../Mappers/BlogCategoryMapper.g.cs | 294 ++++++ HiVakil.Domain/Mappers/BlogMapper.g.cs | 340 +++++++ .../Mappers/BlogStorageFileMapper.g.cs | 6 + HiVakil.Domain/Mappers/LawyerMapper.g.cs | 6 + .../Models/Claims/ApplicationClaims.cs | 228 +---- .../Models/Claims/ApplicationPermission.cs | 35 +- .../CreateBlogCategoryCommandHandler.cs | 19 + .../DeleteBlogCategoryCommandHandler.cs | 24 + .../GetBlogCategoriesQueryHandler.cs | 21 + .../GetBlogCategoryCommandHandler.cs | 23 + .../UpdateBlogCategoryCommandHandler.cs | 29 + .../CreateBlogCategoryCommandValidator.cs | 12 + .../Blogs/CreateBlogCommandHandler.cs | 26 + .../Blogs/DeleteBlogCommandHandler.cs | 26 + .../Handlers/Blogs/GetBlogQueryHandler.cs | 24 + .../Handlers/Blogs/GetBlogsQueryHandler.cs | 29 + .../Blogs/UpdateBlogCommandHandler.cs | 32 + .../Validators/CreateBlogCommandValidator.cs | 27 + HiVakil.Repository/HiVakil.Repository.csproj | 12 + .../20240227185334_Init.Designer.cs | 847 ++++++++++++++++++ .../Migrations/20240227185334_Init.cs | 596 ++++++++++++ .../ApplicationContextModelSnapshot.cs | 844 +++++++++++++++++ .../Models/ApplicationContext.cs | 1 + 64 files changed, 3790 insertions(+), 247 deletions(-) create mode 100644 HiVakil.Api/Controller/AuthController.cs create mode 100644 HiVakil.Api/Controller/BlogCategoryController.cs create mode 100644 HiVakil.Api/Controller/BlogController.cs create mode 100644 HiVakil.Domain/CommandQueries/Commands/BlogCategoryCommands.cs create mode 100644 HiVakil.Domain/CommandQueries/Commands/BlogCommands.cs create mode 100644 HiVakil.Domain/CommandQueries/Queries/BlogCategoryQueries.cs create mode 100644 HiVakil.Domain/CommandQueries/Queries/BlogQueries.cs create mode 100644 HiVakil.Domain/Dtos/LargDto/BlogCategoryLDto.cs create mode 100644 HiVakil.Domain/Dtos/LargDto/BlogLDto.cs create mode 100644 HiVakil.Domain/Dtos/RequestDto/LoginRequestDto.cs create mode 100644 HiVakil.Domain/Dtos/ResponseDto/GetBlogsResponseDto.cs create mode 100644 HiVakil.Domain/Dtos/ResponseDto/PagerResponseDto.cs create mode 100644 HiVakil.Domain/Dtos/SmallDtos/BlogCategorySDto.cs create mode 100644 HiVakil.Domain/Dtos/SmallDtos/BlogSDto.cs create mode 100644 HiVakil.Domain/Entities/Blogs/Blog.Aggregate.cs create mode 100644 HiVakil.Domain/Entities/Blogs/Blog.cs create mode 100644 HiVakil.Domain/Entities/Blogs/BlogCategory.cs create mode 100644 HiVakil.Domain/Entities/Blogs/BlogStorageFile.cs create mode 100644 HiVakil.Domain/Entities/LawyerCategories/LawyerCategory.cs create mode 100644 HiVakil.Domain/Entities/LawyerCategories/LawyerCategoryUser.cs create mode 100644 HiVakil.Domain/Entities/LegalForms/LegalForm.cs create mode 100644 HiVakil.Domain/Entities/LegalRequests/LegalRequest.cs create mode 100644 HiVakil.Domain/Entities/Payments/Payment.cs create mode 100644 HiVakil.Domain/Entities/Reviews/LawyerReview.cs create mode 100644 HiVakil.Domain/Entities/Reviews/Review.cs create mode 100644 HiVakil.Domain/Entities/Users/Lawyer.cs create mode 100644 HiVakil.Domain/Entities/Users/UserCallRequest.cs create mode 100644 HiVakil.Domain/Enums/LegalFormStatus.cs create mode 100644 HiVakil.Domain/Enums/LegalFormType.cs create mode 100644 HiVakil.Domain/Enums/LegalRequestStatus.cs create mode 100644 HiVakil.Domain/Enums/LegalRequestType.cs create mode 100644 HiVakil.Domain/Enums/PaymentStatus.cs create mode 100644 HiVakil.Domain/Enums/PaymentType.cs create mode 100644 HiVakil.Domain/Enums/ReviewType.cs create mode 100644 HiVakil.Domain/Mappers/BlogCategoryMapper.g.cs create mode 100644 HiVakil.Domain/Mappers/BlogMapper.g.cs create mode 100644 HiVakil.Domain/Mappers/BlogStorageFileMapper.g.cs create mode 100644 HiVakil.Domain/Mappers/LawyerMapper.g.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/CreateBlogCategoryCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/DeleteBlogCategoryCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoriesQueryHandler.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoryCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/UpdateBlogCategoryCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/BlogCategories/Validators/CreateBlogCategoryCommandValidator.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/CreateBlogCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/DeleteBlogCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/GetBlogQueryHandler.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/GetBlogsQueryHandler.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/UpdateBlogCommandHandler.cs create mode 100644 HiVakil.Repository/Handlers/Blogs/Validators/CreateBlogCommandValidator.cs create mode 100644 HiVakil.Repository/Migrations/20240227185334_Init.Designer.cs create mode 100644 HiVakil.Repository/Migrations/20240227185334_Init.cs create mode 100644 HiVakil.Repository/Migrations/ApplicationContextModelSnapshot.cs diff --git a/HiVakil.Api/AppSettings/appsettings.Development.json b/HiVakil.Api/AppSettings/appsettings.Development.json index d3a42c1..3caf960 100644 --- a/HiVakil.Api/AppSettings/appsettings.Development.json +++ b/HiVakil.Api/AppSettings/appsettings.Development.json @@ -14,14 +14,14 @@ } }, "SiteSettings": { - "BaseUrl": "http://192.168.88.251:27137", + "BaseUrl": "http://localhost:32776", "AdminPanelBaseUrl": "https://admin.vesmook.com", "KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B", "StorageSetting": { "AccessKey": "", "SecretKey": "" }, - "UserSetting": { + "RootUser": { "Username": "09214802813", "Email": "avvampier@gmail.com", "Password": "55k6bXxIWT5M487L", diff --git a/HiVakil.Api/Controller/AuthController.cs b/HiVakil.Api/Controller/AuthController.cs new file mode 100644 index 0000000..bc6d6cc --- /dev/null +++ b/HiVakil.Api/Controller/AuthController.cs @@ -0,0 +1,64 @@ +namespace HiVakil.Api.Controller; + + +public class AuthController : ICarterModule +{ + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Auth") + .MapGroup($"api/auth"); + + group.MapPost("login/password", LoginWithPassword) + .WithDisplayName("LoginWithPassword") + .HasApiVersion(1.0); + + group.MapPost("login/swagger", LoginSwagger) + .WithDisplayName("LoginSwagger") + .HasApiVersion(1.0); + + group.MapPost("login/code", LoginWithVerifyCode) + .WithDisplayName("LoginWithVerifyCode") + .HasApiVersion(1.0); + + group.MapGet("verifycode", GetVerifyCodeCode) + .WithDisplayName("GetVerifyCodeCode") + .HasApiVersion(1.0); + + group.MapPut("forget/password", ForgetPassword) + .WithDisplayName("ForgetPassword") + .HasApiVersion(1.0); + + group.MapPost("signup", SignUpComplex) + .WithDisplayName("SignUp") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .HasApiVersion(1.0); + } + + public async Task SignUpComplex([FromBody] SignUpRequestDto request, IAccountService accountService, CancellationToken cancellationToken) => + TypedResults.Ok(await accountService.CompleteSignUpAsync(request, cancellationToken)); + + public async Task LoginWithPassword([FromBody] LoginRequestDto loginRequestDto, IAccountService accountService, CancellationToken cancellationToken) => + TypedResults.Ok(await accountService.LoginWithPasswordAsync(loginRequestDto.UserName, loginRequestDto.Password, cancellationToken)); + + + public async Task LoginWithVerifyCode([FromBody] LoginRequestDto loginRequestDto, IAccountService accountService, CancellationToken cancellationToken) => + TypedResults.Ok(await accountService.LoginWithVerifyCodeAsync(loginRequestDto.UserName, loginRequestDto.VerifyCode, cancellationToken)); + + + public async Task GetVerifyCodeCode([FromQuery] string phoneNumber, IAccountService accountService) => + TypedResults.Ok(await accountService.GetVerifyCodeAsync(phoneNumber)); + + + public async Task ForgetPassword([FromQuery] string phoneNumber, IAccountService accountService) => + TypedResults.Ok(await accountService.ForgetPasswordAsync(phoneNumber)); + + + public async Task LoginSwagger(HttpContext ctx, IAccountService accountService, CancellationToken cancellationToken) + { + + var username = ctx.Request.Form["username"]; + var password = ctx.Request.Form["password"]; + return TypedResults.Json(await accountService.LoginWithPasswordAsync(username, password, cancellationToken)); + } + +} \ No newline at end of file diff --git a/HiVakil.Api/Controller/BlogCategoryController.cs b/HiVakil.Api/Controller/BlogCategoryController.cs new file mode 100644 index 0000000..23c42a1 --- /dev/null +++ b/HiVakil.Api/Controller/BlogCategoryController.cs @@ -0,0 +1,48 @@ +namespace HiVakil.Api.Controller; + +public class BlogCategoryController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("BlogCategory").MapGroup("api/blog/category"); + + group.MapGet("", GetBlogCategoriesAsync) + .WithDisplayName("GetBlogCategories") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetBlogCategoryAsync) + .WithDisplayName("GetBlogCategory") + .HasApiVersion(1.0); + + group.MapPost("", CreateBlogCategoryAsync) + .WithDisplayName("CreateBlogCategory") + .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission,ApplicationPermission.ManageBlogCategories)) + .HasApiVersion(1.0); + + group.MapPut("", UpdateBlogCategoryAsync) + .WithDisplayName("UpdateBlogCategory") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogCategories)) + .HasApiVersion(1.0); + + group.MapDelete("{id}", DeleteBlogCategoryAsync) + .WithDisplayName("DeleteBlogCategory") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogCategories)) + .HasApiVersion(1.0); + + } + + private async Task GetBlogCategoriesAsync([FromQuery] int page, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetBlogCategoriesQuery(Page: page), cancellationToken)); + + private async Task GetBlogCategoryAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetBlogCategoryQuery(Id: id), cancellationToken)); + + private async Task CreateBlogCategoryAsync(CreateBlogCategoryCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + private async Task UpdateBlogCategoryAsync(UpdateBlogCategoryCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + private async Task DeleteBlogCategoryAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteBlogCategoryCommand(Id: id), cancellationToken)); +} \ No newline at end of file diff --git a/HiVakil.Api/Controller/BlogController.cs b/HiVakil.Api/Controller/BlogController.cs new file mode 100644 index 0000000..05ecbab --- /dev/null +++ b/HiVakil.Api/Controller/BlogController.cs @@ -0,0 +1,48 @@ +namespace HiVakil.Api.Controller; + +public class BlogController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Blog") + .MapGroup("api/blog"); + + group.MapGet("", GetBlogsAsync) + .WithDisplayName("GetBlogs") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetBlogAsync) + .WithDisplayName("GetBlog") + .HasApiVersion(1.0); + + group.MapPost("", CreateBlogAsync) + .WithDisplayName("CreateBlog") + .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission,ApplicationPermission.ManageBlogs)) + .HasApiVersion(1.0); + + group.MapPut("", UpdateBlogAsync) + .WithDisplayName("UpdateBlog") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) + .HasApiVersion(1.0); + + group.MapDelete("{id}", DeleteBlogAsync) + .WithDisplayName("DeleteBlog") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) + .HasApiVersion(1.0); + } + + private async Task GetBlogsAsync([FromQuery] int page, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetBlogsQuery(Page : page),cancellationToken)); + + private async Task GetBlogAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetBlogQuery(id),cancellationToken)); + + private async Task CreateBlogAsync(CreateBlogCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + private async Task UpdateBlogAsync(UpdateBlogCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + private async Task DeleteBlogAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteBlogCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/HiVakil.Api/HiVakil.Api.csproj b/HiVakil.Api/HiVakil.Api.csproj index a755fe9..de01d59 100644 --- a/HiVakil.Api/HiVakil.Api.csproj +++ b/HiVakil.Api/HiVakil.Api.csproj @@ -72,9 +72,14 @@ + + + + + diff --git a/HiVakil.Api/Program.cs b/HiVakil.Api/Program.cs index c5843bc..73bdc2c 100644 --- a/HiVakil.Api/Program.cs +++ b/HiVakil.Api/Program.cs @@ -34,7 +34,7 @@ builder.Services.AddCustomAuthorization(); builder.Services.AddJwtCustomAuthentication(siteSetting.JwtSettings); builder.Services.AddMvcCore().AddRazorPages().AddRazorViewEngine().AddViews(); builder.Services.AddCustomIdentity(); -//builder.Services.AddCustomDbContext(configuration); +builder.Services.AddCustomDbContext(configuration); builder.Services.AddMarten(configuration, builder.Environment); builder.Services.AddCarter(); @@ -106,7 +106,7 @@ app.UseExceptionHandlerMiddleware(); app.MapCarter(); app.UseStaticFiles(); -//await app.InitialDb(); +await app.InitialDb(); app.MapControllers(); app.Run(); \ No newline at end of file diff --git a/HiVakil.Api/Properties/launchSettings.json b/HiVakil.Api/Properties/launchSettings.json index 3c56aaa..eb430ca 100644 --- a/HiVakil.Api/Properties/launchSettings.json +++ b/HiVakil.Api/Properties/launchSettings.json @@ -23,10 +23,10 @@ "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", "environmentVariables": { - "ASPNETCORE_HTTP_PORTS": "8080" + "ASPNETCORE_URLS": "http://+:80" }, "publishAllPorts": true, - "DockerfileRunArguments": " --network=mother -p 27137:80" + "DockerfileRunArguments": " --network=mother -p 32776:80" } }, "$schema": "http://json.schemastore.org/launchsettings.json", diff --git a/HiVakil.Api/WebFramework/Configurations/ServiceExtensions.cs b/HiVakil.Api/WebFramework/Configurations/ServiceExtensions.cs index 2cf343a..b1d8659 100644 --- a/HiVakil.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/HiVakil.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -183,7 +183,8 @@ public static class ServiceExtensions }).AddEntityFrameworkStores() .AddDefaultTokenProviders() .AddErrorDescriber(); - ; + + serviceCollection.AddIdentityCore().AddEntityFrameworkStores(); } public static void AddCustomApiVersioning(this IServiceCollection serviceCollection) diff --git a/HiVakil.Domain/CommandQueries/Commands/BlogCategoryCommands.cs b/HiVakil.Domain/CommandQueries/Commands/BlogCategoryCommands.cs new file mode 100644 index 0000000..ac5dc52 --- /dev/null +++ b/HiVakil.Domain/CommandQueries/Commands/BlogCategoryCommands.cs @@ -0,0 +1,5 @@ +namespace HiVakil.Domain.CommandQueries.Commands; + +public record CreateBlogCategoryCommand(string Name ,string Description) : IRequest; +public record UpdateBlogCategoryCommand(Guid Id,string Name, string Description) : IRequest; +public record DeleteBlogCategoryCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/HiVakil.Domain/CommandQueries/Commands/BlogCommands.cs b/HiVakil.Domain/CommandQueries/Commands/BlogCommands.cs new file mode 100644 index 0000000..24be22b --- /dev/null +++ b/HiVakil.Domain/CommandQueries/Commands/BlogCommands.cs @@ -0,0 +1,7 @@ +using System.Net.Http; + +namespace HiVakil.Domain.CommandQueries.Commands; + +public record CreateBlogCommand(string Title, string Content, string Tags, int ReadingTime, string Summery, bool IsSuggested, List Files, Guid CategoryId) : IRequest; +public record UpdateBlogCommand(Guid Id, string Title, string Content, string Tags, int ReadingTime, string Summery, bool IsSuggested, List Files, Guid CategoryId) : IRequest; +public record DeleteBlogCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/HiVakil.Domain/CommandQueries/Queries/BlogCategoryQueries.cs b/HiVakil.Domain/CommandQueries/Queries/BlogCategoryQueries.cs new file mode 100644 index 0000000..c5ef757 --- /dev/null +++ b/HiVakil.Domain/CommandQueries/Queries/BlogCategoryQueries.cs @@ -0,0 +1,4 @@ +namespace HiVakil.Domain.CommandQueries.Queries; + +public record GetBlogCategoriesQuery(int Page) : IRequest>; +public record GetBlogCategoryQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/HiVakil.Domain/CommandQueries/Queries/BlogQueries.cs b/HiVakil.Domain/CommandQueries/Queries/BlogQueries.cs new file mode 100644 index 0000000..6d6f4a1 --- /dev/null +++ b/HiVakil.Domain/CommandQueries/Queries/BlogQueries.cs @@ -0,0 +1,4 @@ +namespace HiVakil.Domain.CommandQueries.Queries; + +public record GetBlogsQuery(int Page = 0) : IRequest; +public record GetBlogQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/LargDto/BlogCategoryLDto.cs b/HiVakil.Domain/Dtos/LargDto/BlogCategoryLDto.cs new file mode 100644 index 0000000..272fd74 --- /dev/null +++ b/HiVakil.Domain/Dtos/LargDto/BlogCategoryLDto.cs @@ -0,0 +1,11 @@ +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Dtos.LargDto; + +public class BlogCategoryLDto : BaseDto +{ + + public string Name { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public List Blogs { get; internal set; } = new(); +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/LargDto/BlogLDto.cs b/HiVakil.Domain/Dtos/LargDto/BlogLDto.cs new file mode 100644 index 0000000..3357f51 --- /dev/null +++ b/HiVakil.Domain/Dtos/LargDto/BlogLDto.cs @@ -0,0 +1,16 @@ +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Dtos.LargDto; + +public class BlogLDto : BaseDto +{ + + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public string Tags { get; set; } = string.Empty; + public int ReadingTime { get; set; } + public string Summery { get; set; } = string.Empty; + public bool IsSuggested { get; set; } + public Guid CategoryId { get; set; } + public List Files { get; set; } = new(); +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/RequestDto/LoginRequestDto.cs b/HiVakil.Domain/Dtos/RequestDto/LoginRequestDto.cs new file mode 100644 index 0000000..ca770ef --- /dev/null +++ b/HiVakil.Domain/Dtos/RequestDto/LoginRequestDto.cs @@ -0,0 +1,8 @@ +namespace HiVakil.Domain.Dtos.RequestDto; + +public class LoginRequestDto +{ + public string UserName { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string VerifyCode { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/ResponseDto/GetBlogsResponseDto.cs b/HiVakil.Domain/Dtos/ResponseDto/GetBlogsResponseDto.cs new file mode 100644 index 0000000..a49a963 --- /dev/null +++ b/HiVakil.Domain/Dtos/ResponseDto/GetBlogsResponseDto.cs @@ -0,0 +1,7 @@ +namespace HiVakil.Domain.Dtos.ResponseDto; + +public class GetBlogsResponseDto +{ + public List Blogs { get; set; } = new(); + public PagerResponseDto Pager { get; set; } = new PagerResponseDto(); +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/ResponseDto/PagerResponseDto.cs b/HiVakil.Domain/Dtos/ResponseDto/PagerResponseDto.cs new file mode 100644 index 0000000..3357b48 --- /dev/null +++ b/HiVakil.Domain/Dtos/ResponseDto/PagerResponseDto.cs @@ -0,0 +1,8 @@ +namespace HiVakil.Domain.Dtos.ResponseDto; + +public class PagerResponseDto +{ + public int CurrentPage { get; set; } + public int TotalItems { get; set; } + public int TotalPage { get; set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/SmallDtos/BlogCategorySDto.cs b/HiVakil.Domain/Dtos/SmallDtos/BlogCategorySDto.cs new file mode 100644 index 0000000..349e152 --- /dev/null +++ b/HiVakil.Domain/Dtos/SmallDtos/BlogCategorySDto.cs @@ -0,0 +1,9 @@ +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Dtos.SmallDtos; + +public class BlogCategorySDto : BaseDto +{ + public string Name { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; +} \ No newline at end of file diff --git a/HiVakil.Domain/Dtos/SmallDtos/BlogSDto.cs b/HiVakil.Domain/Dtos/SmallDtos/BlogSDto.cs new file mode 100644 index 0000000..582d33b --- /dev/null +++ b/HiVakil.Domain/Dtos/SmallDtos/BlogSDto.cs @@ -0,0 +1,15 @@ +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Dtos.SmallDtos; + +public class BlogSDto : BaseDto +{ + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public string Tags { get; set; } = string.Empty; + public int ReadingTime { get; set; } + public string Summery { get; set; } = string.Empty; + public bool IsSuggested { get; set; } + public Guid CategoryId { get; set; } + public string CategoryName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Blogs/Blog.Aggregate.cs b/HiVakil.Domain/Entities/Blogs/Blog.Aggregate.cs new file mode 100644 index 0000000..2501356 --- /dev/null +++ b/HiVakil.Domain/Entities/Blogs/Blog.Aggregate.cs @@ -0,0 +1,35 @@ +namespace HiVakil.Domain.Entities.Blogs; + +public partial class Blog +{ + public static Blog Create(string title, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId) + { + return new Blog(title, content, tags, readingTime, summery, isSuggested, categoryId); + } + + public BlogStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + var file = BlogStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, this.Id); + Files.Add(file); + return file; + } +} + +public partial class BlogStorageFile +{ + public static BlogStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid blogId) + { + return new BlogStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, blogId); + } +} + +public partial class BlogCategory +{ + public static BlogCategory Create(string name,string description) + { + if (name.IsNullOrEmpty()) + throw new AppException("Category Name cant be null"); + + return new BlogCategory(name, description); + } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Blogs/Blog.cs b/HiVakil.Domain/Entities/Blogs/Blog.cs new file mode 100644 index 0000000..9ef0d50 --- /dev/null +++ b/HiVakil.Domain/Entities/Blogs/Blog.cs @@ -0,0 +1,34 @@ +namespace HiVakil.Domain.Entities.Blogs; + +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] + +public partial class Blog : ApiEntity +{ + public Blog() + { + + } + public Blog(string title,string content,string tags, int readingTime,string summery, bool isSuggested, Guid categoryId) + { + Title = title; + Content = content; + Tags = tags; + ReadingTime = readingTime; + Summery = summery; + IsSuggested = isSuggested; + CategoryId = categoryId; + } + public string Title { get; internal set; } = string.Empty; + public string Content { get; internal set; } = string.Empty; + public string Tags { get; internal set; } = string.Empty; + public int ReadingTime { get; internal set; } + public string Summery { get; internal set; } = string.Empty; + public bool IsSuggested { get; internal set; } + public Guid CategoryId { get; internal set; } + public BlogCategory? Category { get; internal set; } + public List Files { get; internal set; } = new(); + +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Blogs/BlogCategory.cs b/HiVakil.Domain/Entities/Blogs/BlogCategory.cs new file mode 100644 index 0000000..35061d9 --- /dev/null +++ b/HiVakil.Domain/Entities/Blogs/BlogCategory.cs @@ -0,0 +1,21 @@ +namespace HiVakil.Domain.Entities.Blogs; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class BlogCategory : ApiEntity +{ + public BlogCategory() + { + + } + + public BlogCategory(string name, string description) + { + Name = name; + Description = description; + } + public string Name { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public List Blogs { get; internal set; } = new(); +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Blogs/BlogStorageFile.cs b/HiVakil.Domain/Entities/Blogs/BlogStorageFile.cs new file mode 100644 index 0000000..c4accdf --- /dev/null +++ b/HiVakil.Domain/Entities/Blogs/BlogStorageFile.cs @@ -0,0 +1,16 @@ +namespace HiVakil.Domain.Entities.Blogs; + +public partial class BlogStorageFile : StorageFile +{ + public BlogStorageFile() + { + + } + public BlogStorageFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid blogId) : + base(name, fileLocation, fileName, isHeader, isPrimary, fileType) + { + BlogId = blogId; + } + public Guid BlogId { get; internal set; } + public Blog? Blog { get; internal set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/LawyerCategories/LawyerCategory.cs b/HiVakil.Domain/Entities/LawyerCategories/LawyerCategory.cs new file mode 100644 index 0000000..5369131 --- /dev/null +++ b/HiVakil.Domain/Entities/LawyerCategories/LawyerCategory.cs @@ -0,0 +1,9 @@ +namespace HiVakil.Domain.Entities.LawyerCategories; + +public class LawyerCategory : ApiEntity +{ + public string Title { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + + public List Users { get; internal set; } = new(); +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/LawyerCategories/LawyerCategoryUser.cs b/HiVakil.Domain/Entities/LawyerCategories/LawyerCategoryUser.cs new file mode 100644 index 0000000..b77a08a --- /dev/null +++ b/HiVakil.Domain/Entities/LawyerCategories/LawyerCategoryUser.cs @@ -0,0 +1,10 @@ +namespace HiVakil.Domain.Entities.LawyerCategories; + +public class LawyerCategoryUser : ApiEntity +{ + public Guid CategoryId { get; internal set; } + public LawyerCategory? Category { get; internal set; } + + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/LegalForms/LegalForm.cs b/HiVakil.Domain/Entities/LegalForms/LegalForm.cs new file mode 100644 index 0000000..62906fa --- /dev/null +++ b/HiVakil.Domain/Entities/LegalForms/LegalForm.cs @@ -0,0 +1,10 @@ +namespace HiVakil.Domain.Entities.LegalForms; + +public class LegalForm : ApiEntity +{ + public string Title { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public LegalFormStatus Status { get; set; } + public LegalFormType Type { get; internal set; } + +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/LegalRequests/LegalRequest.cs b/HiVakil.Domain/Entities/LegalRequests/LegalRequest.cs new file mode 100644 index 0000000..0e030fc --- /dev/null +++ b/HiVakil.Domain/Entities/LegalRequests/LegalRequest.cs @@ -0,0 +1,10 @@ +namespace HiVakil.Domain.Entities.LegalRequests; + +public class LegalRequest : ApiEntity +{ + public string Title { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public LegalRequestStatus Status { get; internal set; } + public LegalRequestType Type { get; internal set; } + +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Payments/Payment.cs b/HiVakil.Domain/Entities/Payments/Payment.cs new file mode 100644 index 0000000..56aed48 --- /dev/null +++ b/HiVakil.Domain/Entities/Payments/Payment.cs @@ -0,0 +1,17 @@ +namespace HiVakil.Domain.Entities.Payments; + +public class Payment +{ + + public string FactorNumber { get; internal set; } = string.Empty; + public double Amount { get; internal set; } + public string Description { get; internal set; } = string.Empty; + public string TransactionCode { get; internal set; } = string.Empty; + public string CardPan { get; internal set; } = string.Empty; + public string Authority { get; internal set; } = string.Empty; + public PaymentType Type { get; internal set; } + public PaymentStatus Status { get; internal set; } + + public Guid PayerId { get; internal set; } + public ApplicationUser? Payer { get; internal set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Reviews/LawyerReview.cs b/HiVakil.Domain/Entities/Reviews/LawyerReview.cs new file mode 100644 index 0000000..39fc667 --- /dev/null +++ b/HiVakil.Domain/Entities/Reviews/LawyerReview.cs @@ -0,0 +1,7 @@ + namespace HiVakil.Domain.Entities.Reviews; + +public class LawyerReview : Review +{ + public Guid ApplicationUserId { get; internal set; } + public ApplicationUser? User { get; internal set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Reviews/Review.cs b/HiVakil.Domain/Entities/Reviews/Review.cs new file mode 100644 index 0000000..e40aeb9 --- /dev/null +++ b/HiVakil.Domain/Entities/Reviews/Review.cs @@ -0,0 +1,8 @@ + namespace HiVakil.Domain.Entities.Reviews; + +public class Review : ApiEntity +{ + public string Comment { get; internal set; } = string.Empty; + public double Rate { get; internal set; } + public ReviewType Type { get; internal set; } +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Users/ApplicationUser.cs b/HiVakil.Domain/Entities/Users/ApplicationUser.cs index 87441fc..df72ea7 100644 --- a/HiVakil.Domain/Entities/Users/ApplicationUser.cs +++ b/HiVakil.Domain/Entities/Users/ApplicationUser.cs @@ -12,6 +12,9 @@ public class ApplicationUser : IdentityUser public string LastName { get; set; } = string.Empty; public string NationalId { get; set; } = string.Empty; + public string City { get; set; } = string.Empty; + public int CityId { get; set; } + public DateTime BirthDate { get; set; } public Gender Gender { get; set; } public SignUpStatus SignUpStatus { get; set; } diff --git a/HiVakil.Domain/Entities/Users/Lawyer.cs b/HiVakil.Domain/Entities/Users/Lawyer.cs new file mode 100644 index 0000000..a2956ef --- /dev/null +++ b/HiVakil.Domain/Entities/Users/Lawyer.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Entities.Users; + +public class Lawyer : ApplicationUser +{ + public string LawyerCode { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/HiVakil.Domain/Entities/Users/UserCallRequest.cs b/HiVakil.Domain/Entities/Users/UserCallRequest.cs new file mode 100644 index 0000000..605606e --- /dev/null +++ b/HiVakil.Domain/Entities/Users/UserCallRequest.cs @@ -0,0 +1,9 @@ +namespace HiVakil.Domain.Entities.Users; + +public class UserCallRequest : ApiEntity +{ + public string FullName { get; internal set; } = string.Empty; + public string PhoneNumber { get; internal set; } = string.Empty; + public string Email { get; internal set; } = string.Empty; + public string Message { get; internal set; } = string.Empty; +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/LegalFormStatus.cs b/HiVakil.Domain/Enums/LegalFormStatus.cs new file mode 100644 index 0000000..53016e7 --- /dev/null +++ b/HiVakil.Domain/Enums/LegalFormStatus.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Enums; + +public enum LegalFormStatus +{ + +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/LegalFormType.cs b/HiVakil.Domain/Enums/LegalFormType.cs new file mode 100644 index 0000000..4254ea6 --- /dev/null +++ b/HiVakil.Domain/Enums/LegalFormType.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Enums; + +public enum LegalFormType +{ + +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/LegalRequestStatus.cs b/HiVakil.Domain/Enums/LegalRequestStatus.cs new file mode 100644 index 0000000..5ac029e --- /dev/null +++ b/HiVakil.Domain/Enums/LegalRequestStatus.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Enums; + +public enum LegalRequestStatus +{ + +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/LegalRequestType.cs b/HiVakil.Domain/Enums/LegalRequestType.cs new file mode 100644 index 0000000..6a631d8 --- /dev/null +++ b/HiVakil.Domain/Enums/LegalRequestType.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Enums; + +public enum LegalRequestType +{ + +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/PaymentStatus.cs b/HiVakil.Domain/Enums/PaymentStatus.cs new file mode 100644 index 0000000..2fed238 --- /dev/null +++ b/HiVakil.Domain/Enums/PaymentStatus.cs @@ -0,0 +1,13 @@ +namespace HiVakil.Domain.Enums; + +public enum PaymentStatus +{ + [Display(Name = "در انتظار پرداخت درگاه")] + InPaymentGateway = 0, + [Display(Name = "در انتظار پرداخت")] + NotPaidYet = 1, + [Display(Name = "پرداخت شده")] + Paid = 200, + [Display(Name = "کنسل شده")] + Cancel = 500 +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/PaymentType.cs b/HiVakil.Domain/Enums/PaymentType.cs new file mode 100644 index 0000000..042ca1a --- /dev/null +++ b/HiVakil.Domain/Enums/PaymentType.cs @@ -0,0 +1,13 @@ +namespace HiVakil.Domain.Enums; + +public enum PaymentType +{ + [Display(Name = "نقدی")] + Cash, + [Display(Name = "کارت به کارت")] + CardTransfer, + [Display(Name = "آنلاین")] + Online, + [Display(Name = "در محل")] + PayOnDoor +} \ No newline at end of file diff --git a/HiVakil.Domain/Enums/ReviewType.cs b/HiVakil.Domain/Enums/ReviewType.cs new file mode 100644 index 0000000..b373b8f --- /dev/null +++ b/HiVakil.Domain/Enums/ReviewType.cs @@ -0,0 +1,7 @@ +namespace HiVakil.Domain.Enums; + +public enum ReviewType +{ + Lawyer, + Request +} \ No newline at end of file diff --git a/HiVakil.Domain/HiVakil.Domain.csproj b/HiVakil.Domain/HiVakil.Domain.csproj index 5da02f7..dae867f 100644 --- a/HiVakil.Domain/HiVakil.Domain.csproj +++ b/HiVakil.Domain/HiVakil.Domain.csproj @@ -49,8 +49,12 @@ + + + + @@ -69,8 +73,12 @@ - + + + + + diff --git a/HiVakil.Domain/Mappers/BlogCategoryMapper.g.cs b/HiVakil.Domain/Mappers/BlogCategoryMapper.g.cs new file mode 100644 index 0000000..a4820ff --- /dev/null +++ b/HiVakil.Domain/Mappers/BlogCategoryMapper.g.cs @@ -0,0 +1,294 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using HiVakil.Domain.Dtos.LargDto; +using HiVakil.Domain.Dtos.SmallDtos; +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Mappers +{ + public static partial class BlogCategoryMapper + { + public static BlogCategory AdaptToBlogCategory(this BlogCategoryLDto p1) + { + return p1 == null ? null : new BlogCategory() + { + Name = p1.Name, + Description = p1.Description, + Blogs = funcMain1(p1.Blogs), + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static BlogCategory AdaptTo(this BlogCategoryLDto p3, BlogCategory p4) + { + if (p3 == null) + { + return null; + } + BlogCategory result = p4 ?? new BlogCategory(); + + result.Name = p3.Name; + result.Description = p3.Description; + result.Blogs = funcMain2(p3.Blogs, result.Blogs); + result.Id = p3.Id; + result.CreatedAt = p3.CreatedAt; + return result; + + } + public static Expression> ProjectToBlogCategory => p7 => new BlogCategory() + { + Name = p7.Name, + Description = p7.Description, + Blogs = p7.Blogs.Select(p8 => new Blog() + { + Title = p8.Title, + Content = p8.Content, + Tags = p8.Tags, + ReadingTime = p8.ReadingTime, + Summery = p8.Summery, + IsSuggested = p8.IsSuggested, + CategoryId = p8.CategoryId, + Id = p8.Id, + CreatedAt = p8.CreatedAt + }).ToList(), + Id = p7.Id, + CreatedAt = p7.CreatedAt + }; + public static BlogCategoryLDto AdaptToLDto(this BlogCategory p9) + { + return p9 == null ? null : new BlogCategoryLDto() + { + Name = p9.Name, + Description = p9.Description, + Blogs = funcMain3(p9.Blogs), + Id = p9.Id, + CreatedAt = p9.CreatedAt + }; + } + public static BlogCategoryLDto AdaptTo(this BlogCategory p11, BlogCategoryLDto p12) + { + if (p11 == null) + { + return null; + } + BlogCategoryLDto result = p12 ?? new BlogCategoryLDto(); + + result.Name = p11.Name; + result.Description = p11.Description; + result.Blogs = funcMain4(p11.Blogs, result.Blogs); + result.Id = p11.Id; + result.CreatedAt = p11.CreatedAt; + return result; + + } + public static Expression> ProjectToLDto => p15 => new BlogCategoryLDto() + { + Name = p15.Name, + Description = p15.Description, + Blogs = p15.Blogs.Select(p16 => new BlogSDto() + { + Title = p16.Title, + Content = p16.Content, + Tags = p16.Tags, + ReadingTime = p16.ReadingTime, + Summery = p16.Summery, + IsSuggested = p16.IsSuggested, + CategoryId = p16.CategoryId, + CategoryName = p16.Category.Name, + Id = p16.Id, + CreatedAt = p16.CreatedAt + }).ToList(), + Id = p15.Id, + CreatedAt = p15.CreatedAt + }; + public static BlogCategory AdaptToBlogCategory(this BlogCategorySDto p17) + { + return p17 == null ? null : new BlogCategory() + { + Name = p17.Name, + Description = p17.Description, + Id = p17.Id, + CreatedAt = p17.CreatedAt + }; + } + public static BlogCategory AdaptTo(this BlogCategorySDto p18, BlogCategory p19) + { + if (p18 == null) + { + return null; + } + BlogCategory result = p19 ?? new BlogCategory(); + + result.Name = p18.Name; + result.Description = p18.Description; + result.Id = p18.Id; + result.CreatedAt = p18.CreatedAt; + return result; + + } + public static BlogCategorySDto AdaptToSDto(this BlogCategory p20) + { + return p20 == null ? null : new BlogCategorySDto() + { + Name = p20.Name, + Description = p20.Description, + Id = p20.Id, + CreatedAt = p20.CreatedAt + }; + } + public static BlogCategorySDto AdaptTo(this BlogCategory p21, BlogCategorySDto p22) + { + if (p21 == null) + { + return null; + } + BlogCategorySDto result = p22 ?? new BlogCategorySDto(); + + result.Name = p21.Name; + result.Description = p21.Description; + result.Id = p21.Id; + result.CreatedAt = p21.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p23 => new BlogCategorySDto() + { + Name = p23.Name, + Description = p23.Description, + Id = p23.Id, + CreatedAt = p23.CreatedAt + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + BlogSDto item = p2[i]; + result.Add(item == null ? null : new Blog() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + BlogSDto item = p5[i]; + result.Add(item == null ? null : new Blog() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + Blog item = p10[i]; + result.Add(item == null ? null : new BlogSDto() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain4(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + Blog item = p13[i]; + result.Add(item == null ? null : new BlogSDto() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/HiVakil.Domain/Mappers/BlogMapper.g.cs b/HiVakil.Domain/Mappers/BlogMapper.g.cs new file mode 100644 index 0000000..3bdf063 --- /dev/null +++ b/HiVakil.Domain/Mappers/BlogMapper.g.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using HiVakil.Domain.Dtos.LargDto; +using HiVakil.Domain.Dtos.SmallDtos; +using HiVakil.Domain.Entities.Blogs; + +namespace HiVakil.Domain.Mappers +{ + public static partial class BlogMapper + { + public static Blog AdaptToBlog(this BlogLDto p1) + { + return p1 == null ? null : new Blog() + { + Title = p1.Title, + Content = p1.Content, + Tags = p1.Tags, + ReadingTime = p1.ReadingTime, + Summery = p1.Summery, + IsSuggested = p1.IsSuggested, + CategoryId = p1.CategoryId, + Files = funcMain1(p1.Files), + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static Blog AdaptTo(this BlogLDto p3, Blog p4) + { + if (p3 == null) + { + return null; + } + Blog result = p4 ?? new Blog(); + + result.Title = p3.Title; + result.Content = p3.Content; + result.Tags = p3.Tags; + result.ReadingTime = p3.ReadingTime; + result.Summery = p3.Summery; + result.IsSuggested = p3.IsSuggested; + result.CategoryId = p3.CategoryId; + result.Files = funcMain2(p3.Files, result.Files); + result.Id = p3.Id; + result.CreatedAt = p3.CreatedAt; + return result; + + } + public static Expression> ProjectToBlog => p7 => new Blog() + { + Title = p7.Title, + Content = p7.Content, + Tags = p7.Tags, + ReadingTime = p7.ReadingTime, + Summery = p7.Summery, + IsSuggested = p7.IsSuggested, + CategoryId = p7.CategoryId, + Files = p7.Files.Select(p8 => new BlogStorageFile() + { + Name = p8.Name, + FileLocation = p8.FileLocation, + FileName = p8.FileName, + IsHeader = p8.IsHeader, + IsPrimary = p8.IsPrimary, + FileType = p8.FileType, + Id = p8.Id, + CreatedAt = p8.CreatedAt + }).ToList(), + Id = p7.Id, + CreatedAt = p7.CreatedAt + }; + public static BlogLDto AdaptToLDto(this Blog p9) + { + return p9 == null ? null : new BlogLDto() + { + Title = p9.Title, + Content = p9.Content, + Tags = p9.Tags, + ReadingTime = p9.ReadingTime, + Summery = p9.Summery, + IsSuggested = p9.IsSuggested, + CategoryId = p9.CategoryId, + Files = funcMain3(p9.Files), + Id = p9.Id, + CreatedAt = p9.CreatedAt + }; + } + public static BlogLDto AdaptTo(this Blog p11, BlogLDto p12) + { + if (p11 == null) + { + return null; + } + BlogLDto result = p12 ?? new BlogLDto(); + + result.Title = p11.Title; + result.Content = p11.Content; + result.Tags = p11.Tags; + result.ReadingTime = p11.ReadingTime; + result.Summery = p11.Summery; + result.IsSuggested = p11.IsSuggested; + result.CategoryId = p11.CategoryId; + result.Files = funcMain4(p11.Files, result.Files); + result.Id = p11.Id; + result.CreatedAt = p11.CreatedAt; + return result; + + } + public static Expression> ProjectToLDto => p15 => new BlogLDto() + { + Title = p15.Title, + Content = p15.Content, + Tags = p15.Tags, + ReadingTime = p15.ReadingTime, + Summery = p15.Summery, + IsSuggested = p15.IsSuggested, + CategoryId = p15.CategoryId, + Files = p15.Files.Select(p16 => new StorageFileSDto() + { + Name = p16.Name, + FileLocation = p16.FileLocation, + FileName = p16.FileName, + IsHeader = p16.IsHeader, + IsPrimary = p16.IsPrimary, + FileType = p16.FileType, + Id = p16.Id + }).ToList(), + Id = p15.Id, + CreatedAt = p15.CreatedAt + }; + public static Blog AdaptToBlog(this BlogSDto p17) + { + return p17 == null ? null : new Blog() + { + Title = p17.Title, + Content = p17.Content, + Tags = p17.Tags, + ReadingTime = p17.ReadingTime, + Summery = p17.Summery, + IsSuggested = p17.IsSuggested, + CategoryId = p17.CategoryId, + Id = p17.Id, + CreatedAt = p17.CreatedAt + }; + } + public static Blog AdaptTo(this BlogSDto p18, Blog p19) + { + if (p18 == null) + { + return null; + } + Blog result = p19 ?? new Blog(); + + result.Title = p18.Title; + result.Content = p18.Content; + result.Tags = p18.Tags; + result.ReadingTime = p18.ReadingTime; + result.Summery = p18.Summery; + result.IsSuggested = p18.IsSuggested; + result.CategoryId = p18.CategoryId; + result.Id = p18.Id; + result.CreatedAt = p18.CreatedAt; + return result; + + } + public static BlogSDto AdaptToSDto(this Blog p20) + { + return p20 == null ? null : new BlogSDto() + { + Title = p20.Title, + Content = p20.Content, + Tags = p20.Tags, + ReadingTime = p20.ReadingTime, + Summery = p20.Summery, + IsSuggested = p20.IsSuggested, + CategoryId = p20.CategoryId, + CategoryName = p20.Category == null ? null : p20.Category.Name, + Id = p20.Id, + CreatedAt = p20.CreatedAt + }; + } + public static BlogSDto AdaptTo(this Blog p21, BlogSDto p22) + { + if (p21 == null) + { + return null; + } + BlogSDto result = p22 ?? new BlogSDto(); + + result.Title = p21.Title; + result.Content = p21.Content; + result.Tags = p21.Tags; + result.ReadingTime = p21.ReadingTime; + result.Summery = p21.Summery; + result.IsSuggested = p21.IsSuggested; + result.CategoryId = p21.CategoryId; + result.CategoryName = p21.Category == null ? null : p21.Category.Name; + result.Id = p21.Id; + result.CreatedAt = p21.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p23 => new BlogSDto() + { + Title = p23.Title, + Content = p23.Content, + Tags = p23.Tags, + ReadingTime = p23.ReadingTime, + Summery = p23.Summery, + IsSuggested = p23.IsSuggested, + CategoryId = p23.CategoryId, + CategoryName = p23.Category.Name, + Id = p23.Id, + CreatedAt = p23.CreatedAt + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + StorageFileSDto item = p2[i]; + result.Add(item == null ? null : new BlogStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + StorageFileSDto item = p5[i]; + result.Add(item == null ? null : new BlogStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + BlogStorageFile item = p10[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + BlogStorageFile item = p13[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/HiVakil.Domain/Mappers/BlogStorageFileMapper.g.cs b/HiVakil.Domain/Mappers/BlogStorageFileMapper.g.cs new file mode 100644 index 0000000..6860547 --- /dev/null +++ b/HiVakil.Domain/Mappers/BlogStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Mappers +{ + public static partial class BlogStorageFileMapper + { + } +} \ No newline at end of file diff --git a/HiVakil.Domain/Mappers/LawyerMapper.g.cs b/HiVakil.Domain/Mappers/LawyerMapper.g.cs new file mode 100644 index 0000000..326bf29 --- /dev/null +++ b/HiVakil.Domain/Mappers/LawyerMapper.g.cs @@ -0,0 +1,6 @@ +namespace HiVakil.Domain.Mappers +{ + public static partial class LawyerMapper + { + } +} \ No newline at end of file diff --git a/HiVakil.Domain/Models/Claims/ApplicationClaims.cs b/HiVakil.Domain/Models/Claims/ApplicationClaims.cs index 89808a4..5edcf89 100644 --- a/HiVakil.Domain/Models/Claims/ApplicationClaims.cs +++ b/HiVakil.Domain/Models/Claims/ApplicationClaims.cs @@ -15,239 +15,55 @@ public static class ApplicationClaims Type = CustomClaimType.Permission, Value = ApplicationPermission.ViewBlogs, }; - - public static ClaimDto ManageBrands { get; } = new ClaimDto + public static ClaimDto ViewBlogCategories { get; } = new ClaimDto { - Title = "مدیریت برند ها", + Title = "مشاهده دسته بندی بلاگ ها", Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageBrands, + Value = ApplicationPermission.ViewBlogCategories, }; - public static ClaimDto ViewBrands { get; } = new ClaimDto + public static ClaimDto ManageBlogCategories { get; } = new ClaimDto { - Title = "مشاهده برند ها", + Title = "مدیریت دسته بندی بلاگ ها", Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewBrands, + Value = ApplicationPermission.ManageBlogCategories, }; - public static ClaimDto ManageCategories { get; } = new ClaimDto - { - Title = "مدیریت دسته بندی ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageCategories, - }; - public static ClaimDto ViewCategories { get; } = new ClaimDto - { - Title = "مشاهده دسته بندی ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewCategories, - }; - public static ClaimDto ManageDiscounts { get; } = new ClaimDto - { - Title = "مدیریت تخفیف ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageDiscounts, - }; - public static ClaimDto ViewDiscounts { get; } = new ClaimDto - { - Title = "مشاهده تخفیف ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewDiscounts, - }; - public static ClaimDto ManageOrders { get; } = new ClaimDto - { - Title = "مدیریت فروش ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageOrders, - }; - public static ClaimDto ViewAllOrders { get; } = new ClaimDto - { - Title = "مشاهده فروش ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewAllOrders, - }; - public static ClaimDto ViewMineOrders { get; } = new ClaimDto - { - Title = "مشاهده فروش های خود", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewMineOrders, - }; - public static ClaimDto CreateOrder { get; } = new ClaimDto - { - Title = "ثبت سفارش", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.CreateOrder, - }; - public static ClaimDto ManageProducts { get; } = new ClaimDto - { - Title = "مدیریت محصولات", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageProducts, - }; - public static ClaimDto ViewProducts { get; } = new ClaimDto - { - Title = "مشاهده محصولات", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewProducts, - }; - public static ClaimDto ManageReview { get; } = new ClaimDto - { - Title = "مدیریت کامنت ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageReview, - }; - public static ClaimDto ViewAllReviews { get; } = new ClaimDto - { - Title = "مشاهده کامنت ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewAllReviews, - }; - public static ClaimDto ViewMineReviews { get; } = new ClaimDto - { - Title = "مشاهده کامنت های خود", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewMineReviews, - }; - public static ClaimDto AddReview { get; } = new ClaimDto - { - Title = "ثبت کامنت جدید", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.AddReview, - }; - public static ClaimDto ConfirmReview { get; } = new ClaimDto - { - Title = "تائید کامنت ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ConfirmReview, - }; - - public static ClaimDto ViewWarehouses { get; } = new ClaimDto - { - Title = "مشاهده انبار ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewWarehouses, - }; - public static ClaimDto ManageWarehouses { get; } = new ClaimDto - { - Title = "مدیریت انبار ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageWarehouses, - }; - - public static ClaimDto ViewShipping { get; } = new ClaimDto - { - Title = "مشاهده روش های ارسال", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewShipping, - }; - public static ClaimDto ManageShipping { get; } = new ClaimDto - { - Title = "مدیریت روش های ارسال", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageShipping, - }; - - public static ClaimDto ManageUsers { get; } = new ClaimDto - { - Title = "مدیریت کاربران", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageUsers, - }; - public static ClaimDto ViewUsers { get; } = new ClaimDto - { - Title = "مشاهده کاربران", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewUsers, - }; - - public static ClaimDto ManageFiles { get; } = new ClaimDto - { - Title = "مدیریت فایل ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ManageFiles, - }; - public static ClaimDto ViewFiles { get; } = new ClaimDto - { - Title = "مشاهده فایل ها", - Type = CustomClaimType.Permission, - Value = ApplicationPermission.ViewFiles, - }; + /// + /// + /// public static List AllClaimDtos = new List { ManageBlogs, ViewBlogs, - ManageBrands, - ViewBrands, - ManageCategories, - ViewCategories, - ManageDiscounts, - ViewDiscounts, - ManageOrders, - ViewAllOrders, - ViewMineOrders, - CreateOrder, - ManageProducts, - ViewProducts, - ManageReview, - AddReview, - ConfirmReview, - ViewAllReviews, - ViewMineReviews, - ManageWarehouses, - ViewWarehouses, - ManageShipping, - ViewShipping, - ManageUsers, - ViewUsers, - ManageFiles, - ViewFiles + ViewBlogCategories, + ManageBlogCategories }; public static List AllClaims = new List { ManageBlogs.GetClaim, ViewBlogs.GetClaim, - ManageBrands.GetClaim, - ViewBrands.GetClaim, - ManageCategories.GetClaim, - ViewCategories.GetClaim, - ManageDiscounts.GetClaim, - ViewDiscounts.GetClaim, - ManageOrders.GetClaim, - ViewAllOrders.GetClaim, - ViewMineOrders.GetClaim, - CreateOrder.GetClaim, - ManageProducts.GetClaim, - ViewProducts.GetClaim, - ManageReview.GetClaim, - AddReview.GetClaim, - ConfirmReview.GetClaim, - ViewAllReviews.GetClaim, - ViewMineReviews.GetClaim, - ManageWarehouses.GetClaim, - ViewWarehouses.GetClaim, - ManageShipping.GetClaim, - ViewShipping.GetClaim, - ManageUsers.GetClaim, - ViewUsers.GetClaim, - ManageFiles.GetClaim, - ViewFiles.GetClaim + ViewBlogCategories.GetClaim, + ManageBlogCategories.GetClaim }; + public static List ManagerClaims = new List + { + ManageBlogs.GetClaim, + ViewBlogs.GetClaim, + ViewBlogCategories.GetClaim, + ManageBlogCategories.GetClaim + }; + + public static List CustomerClaims = new List { ViewBlogs.GetClaim, - ViewBrands.GetClaim, - ViewCategories.GetClaim, - ViewMineOrders.GetClaim, - CreateOrder.GetClaim, - ViewProducts.GetClaim, - AddReview.GetClaim, - ViewMineReviews.GetClaim, }; } diff --git a/HiVakil.Domain/Models/Claims/ApplicationPermission.cs b/HiVakil.Domain/Models/Claims/ApplicationPermission.cs index 1e35888..b483c4e 100644 --- a/HiVakil.Domain/Models/Claims/ApplicationPermission.cs +++ b/HiVakil.Domain/Models/Claims/ApplicationPermission.cs @@ -5,38 +5,7 @@ public static class ApplicationPermission public const string ManageBlogs = nameof(ManageBlogs); public const string ViewBlogs = nameof(ManageBlogs); - public const string ManageBrands = nameof(ManageBrands); - public const string ViewBrands = nameof(ViewBrands); - public const string ManageCategories = nameof(ManageCategories); - public const string ViewCategories = nameof(ViewCategories); - - public const string ManageDiscounts = nameof(ManageDiscounts); - public const string ViewDiscounts = nameof(ViewDiscounts); - - public const string ManageOrders = nameof(ManageOrders); - public const string ViewAllOrders = nameof(ViewAllOrders); - public const string ViewMineOrders = nameof(ViewMineOrders); - public const string CreateOrder = nameof(CreateOrder); - - public const string ManageProducts = nameof(ManageProducts); - public const string ViewProducts = nameof(ViewProducts); - - public const string ManageReview = nameof(AddReview); - public const string AddReview = nameof(AddReview); - public const string ConfirmReview = nameof(ConfirmReview); - public const string ViewAllReviews = nameof(ViewAllReviews); - public const string ViewMineReviews = nameof(ViewMineReviews); - - public const string ManageWarehouses = nameof(ManageWarehouses); - public const string ViewWarehouses = nameof(ViewWarehouses); - - public const string ManageShipping = nameof(ManageShipping); - public const string ViewShipping = nameof(ViewShipping); - - public const string ManageUsers = nameof(ManageUsers); - public const string ViewUsers = nameof(ViewUsers); - - public const string ManageFiles = nameof(ManageFiles); - public const string ViewFiles = nameof(ViewFiles); + public const string ManageBlogCategories = nameof(ManageBlogCategories); + public const string ViewBlogCategories = nameof(ViewBlogCategories); } \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/CreateBlogCategoryCommandHandler.cs b/HiVakil.Repository/Handlers/BlogCategories/CreateBlogCategoryCommandHandler.cs new file mode 100644 index 0000000..d28b13e --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/CreateBlogCategoryCommandHandler.cs @@ -0,0 +1,19 @@ +namespace HiVakil.Repository.Handlers.BlogCategories; + +public class CreateBlogCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateBlogCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateBlogCategoryCommand request, CancellationToken cancellationToken) + { + var ent = BlogCategory.Create(request.Name, request.Description); + _repositoryWrapper.SetRepository() + .Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/DeleteBlogCategoryCommandHandler.cs b/HiVakil.Repository/Handlers/BlogCategories/DeleteBlogCategoryCommandHandler.cs new file mode 100644 index 0000000..e979452 --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/DeleteBlogCategoryCommandHandler.cs @@ -0,0 +1,24 @@ +namespace HiVakil.Repository.Handlers.BlogCategories; + +public class DeleteBlogCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteBlogCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteBlogCategoryCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(bc => bc.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Blog Category not found", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository() + .Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoriesQueryHandler.cs b/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoriesQueryHandler.cs new file mode 100644 index 0000000..5a07a05 --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoriesQueryHandler.cs @@ -0,0 +1,21 @@ +namespace HiVakil.Repository.Handlers.BlogCategories; + +public class GetBlogCategoriesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetBlogCategoriesQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetBlogCategoriesQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper.SetRepository() + .TableNoTracking + .Skip(request.Page * 20) + .Take(20) + .Select(BlogCategoryMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoryCommandHandler.cs b/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoryCommandHandler.cs new file mode 100644 index 0000000..c2b1d41 --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/GetBlogCategoryCommandHandler.cs @@ -0,0 +1,23 @@ +namespace HiVakil.Repository.Handlers.BlogCategories; + +public class GetBlogCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetBlogCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetBlogCategoryQuery request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(bc => bc.Id == request.Id) + .Select(BlogCategoryMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (ent == null) + throw new AppException("BlogCategory not found", ApiResultStatusCode.NotFound); + + return ent; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/UpdateBlogCategoryCommandHandler.cs b/HiVakil.Repository/Handlers/BlogCategories/UpdateBlogCategoryCommandHandler.cs new file mode 100644 index 0000000..25a0390 --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/UpdateBlogCategoryCommandHandler.cs @@ -0,0 +1,29 @@ +namespace HiVakil.Repository.Handlers.BlogCategories; + +public class UpdateBlogCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateBlogCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateBlogCategoryCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(bc => bc.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Blog Category not found", ApiResultStatusCode.NotFound); + + var newEnt = BlogCategory.Create(request.Name, request.Description); + newEnt.CreatedAt = ent.CreatedAt; + newEnt.CreatedBy = ent.CreatedBy; + newEnt.Id = ent.Id; + + _repositoryWrapper.SetRepository() + .Update(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/BlogCategories/Validators/CreateBlogCategoryCommandValidator.cs b/HiVakil.Repository/Handlers/BlogCategories/Validators/CreateBlogCategoryCommandValidator.cs new file mode 100644 index 0000000..2fdc25e --- /dev/null +++ b/HiVakil.Repository/Handlers/BlogCategories/Validators/CreateBlogCategoryCommandValidator.cs @@ -0,0 +1,12 @@ +namespace HiVakil.Repository.Handlers.BlogCategories.Validators; + +public class CreateBlogCategoryCommandValidator : AbstractValidator +{ + public CreateBlogCategoryCommandValidator() + { + RuleFor(cb => cb.Name) + .NotNull() + .NotEmpty() + .WithMessage("نام دسته بندی را وارد کنید"); + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/CreateBlogCommandHandler.cs b/HiVakil.Repository/Handlers/Blogs/CreateBlogCommandHandler.cs new file mode 100644 index 0000000..fe08ebb --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/CreateBlogCommandHandler.cs @@ -0,0 +1,26 @@ +namespace HiVakil.Repository.Handlers.Blogs; + +public class CreateBlogCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateBlogCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateBlogCommand request, CancellationToken cancellationToken) + { + var ent = Blog.Create(request.Title, request.Content, request.Tags, request.ReadingTime, request.Summery, + request.IsSuggested, request.CategoryId); + + foreach (var file in request.Files) + { + ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + + _repositoryWrapper.SetRepository() + .Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/DeleteBlogCommandHandler.cs b/HiVakil.Repository/Handlers/Blogs/DeleteBlogCommandHandler.cs new file mode 100644 index 0000000..7662c7a --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/DeleteBlogCommandHandler.cs @@ -0,0 +1,26 @@ +namespace HiVakil.Repository.Handlers.Blogs; + +public class DeleteBlogCommandHandler :IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteBlogCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteBlogCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(b => b.Id == request.Id, cancellationToken); + + if (ent == null) + throw new AppException("Blog is not found", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository() + .Delete(ent); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/GetBlogQueryHandler.cs b/HiVakil.Repository/Handlers/Blogs/GetBlogQueryHandler.cs new file mode 100644 index 0000000..80e23e4 --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/GetBlogQueryHandler.cs @@ -0,0 +1,24 @@ +namespace HiVakil.Repository.Handlers.Blogs; + +public class GetBlogQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetBlogQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetBlogQuery request, CancellationToken cancellationToken) + { + var blog = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(b => b.Id == request.Id) + .Select(BlogMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + + if (blog == null) + throw new AppException("Blog not found", ApiResultStatusCode.NotFound); + + return blog; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/GetBlogsQueryHandler.cs b/HiVakil.Repository/Handlers/Blogs/GetBlogsQueryHandler.cs new file mode 100644 index 0000000..e4884fc --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/GetBlogsQueryHandler.cs @@ -0,0 +1,29 @@ +namespace HiVakil.Repository.Handlers.Blogs; + +public class GetBlogsQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetBlogsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetBlogsQuery request, CancellationToken cancellationToken) + { + var originals = _repositoryWrapper.SetRepository() + .TableNoTracking; + + var blogs = await originals.Skip(request.Page * 20) + .Take(20) + .Select(BlogMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + var response = new GetBlogsResponseDto(); + response.Blogs = blogs; + response.Pager.CurrentPage = request.Page; + response.Pager.TotalItems = await originals.CountAsync(cancellationToken); + response.Pager.TotalPage = response.Pager.TotalItems / 20; + + return response; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/UpdateBlogCommandHandler.cs b/HiVakil.Repository/Handlers/Blogs/UpdateBlogCommandHandler.cs new file mode 100644 index 0000000..5bf362f --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/UpdateBlogCommandHandler.cs @@ -0,0 +1,32 @@ +namespace HiVakil.Repository.Handlers.Blogs; + +public class UpdateBlogCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateBlogCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateBlogCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(b => b.Id == request.Id, cancellationToken); + + if (ent == null) + throw new AppException("Blog not found", ApiResultStatusCode.NotFound); + + var newEnt = Blog.Create(request.Title, request.Content, request.Tags, request.ReadingTime, request.Summery, + request.IsSuggested, request.CategoryId); + + newEnt.CreatedAt = ent.CreatedAt; + newEnt.CreatedBy = ent.CreatedBy; + newEnt.Id = ent.Id; + + _repositoryWrapper.SetRepository() + .Update(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/HiVakil.Repository/Handlers/Blogs/Validators/CreateBlogCommandValidator.cs b/HiVakil.Repository/Handlers/Blogs/Validators/CreateBlogCommandValidator.cs new file mode 100644 index 0000000..faccc6b --- /dev/null +++ b/HiVakil.Repository/Handlers/Blogs/Validators/CreateBlogCommandValidator.cs @@ -0,0 +1,27 @@ +namespace HiVakil.Repository.Handlers.Blogs.Validators; + +public class CreateBlogCommandValidator : AbstractValidator +{ + public CreateBlogCommandValidator() + { + RuleFor(b => b.Content) + .NotNull() + .NotEmpty() + .WithMessage("محتوا بلاگ نمی تواند خالی باشد"); + + RuleFor(b => b.Title) + .NotNull() + .NotEmpty() + .WithMessage("عنوان بلاگ را وارد کنید"); + + RuleFor(b => b.Tags) + .NotNull() + .NotEmpty() + .WithMessage("تگ های بلاگ را وارد کنید"); + + RuleFor(b => b.Summery) + .NotNull() + .NotEmpty() + .WithMessage("خلاصه بلاگ را واردی کنید"); + } +} \ No newline at end of file diff --git a/HiVakil.Repository/HiVakil.Repository.csproj b/HiVakil.Repository/HiVakil.Repository.csproj index 17f0500..8eae311 100644 --- a/HiVakil.Repository/HiVakil.Repository.csproj +++ b/HiVakil.Repository/HiVakil.Repository.csproj @@ -39,8 +39,15 @@ + + + + + + + @@ -65,4 +72,9 @@ + + + + + diff --git a/HiVakil.Repository/Migrations/20240227185334_Init.Designer.cs b/HiVakil.Repository/Migrations/20240227185334_Init.Designer.cs new file mode 100644 index 0000000..328781c --- /dev/null +++ b/HiVakil.Repository/Migrations/20240227185334_Init.Designer.cs @@ -0,0 +1,847 @@ +// +using System; +using HiVakil.Repository.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace HiVakil.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20240227185334_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LawyerCategories", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategoryUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("UserId"); + + b.ToTable("LawyerCategoryUsers", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LegalForms.LegalForm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LegalForms", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LegalRequests.LegalRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LegalRequests", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("character varying(13)"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Reviews", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Review"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CityId") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.UserCallRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("UserCallRequests", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.LawyerReview", b => + { + b.HasBaseType("HiVakil.Domain.Entities.Reviews.Review"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.HasIndex("ApplicationUserId"); + + b.HasDiscriminator().HasValue("LawyerReview"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("HiVakil.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.Lawyer", b => + { + b.HasBaseType("HiVakil.Domain.Entities.Users.ApplicationUser"); + + b.Property("LawyerCode") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Lawyers", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("HiVakil.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategoryUser", b => + { + b.HasOne("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", "Category") + .WithMany("Users") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.LawyerReview", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("HiVakil.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.Lawyer", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithOne() + .HasForeignKey("HiVakil.Domain.Entities.Users.Lawyer", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", b => + { + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/HiVakil.Repository/Migrations/20240227185334_Init.cs b/HiVakil.Repository/Migrations/20240227185334_Init.cs new file mode 100644 index 0000000..2be6c9d --- /dev/null +++ b/HiVakil.Repository/Migrations/20240227185334_Init.cs @@ -0,0 +1,596 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace HiVakil.Repository.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "public"); + + migrationBuilder.CreateTable( + name: "BlogCategories", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BlogCategories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "LawyerCategories", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LawyerCategories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "LegalForms", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Type = table.Column(type: "integer", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LegalForms", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "LegalRequests", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Type = table.Column(type: "integer", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LegalRequests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Roles", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Description = table.Column(type: "text", nullable: false), + EnglishName = table.Column(type: "text", nullable: false), + PersianName = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "UserCallRequests", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FullName = table.Column(type: "text", nullable: false), + PhoneNumber = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + Message = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserCallRequests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + NationalId = table.Column(type: "text", nullable: false), + City = table.Column(type: "text", nullable: false), + CityId = table.Column(type: "integer", nullable: false), + BirthDate = table.Column(type: "timestamp without time zone", nullable: false), + Gender = table.Column(type: "integer", nullable: false), + SignUpStatus = table.Column(type: "integer", nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Blogs", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Title = table.Column(type: "text", nullable: false), + Content = table.Column(type: "text", nullable: false), + Tags = table.Column(type: "text", nullable: false), + ReadingTime = table.Column(type: "integer", nullable: false), + Summery = table.Column(type: "text", nullable: false), + IsSuggested = table.Column(type: "boolean", nullable: false), + CategoryId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Blogs", x => x.Id); + table.ForeignKey( + name: "FK_Blogs_BlogCategories_CategoryId", + column: x => x.CategoryId, + principalSchema: "public", + principalTable: "BlogCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "RoleClaims", + schema: "public", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_RoleClaims_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Claims", + schema: "public", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Claims", x => x.Id); + table.ForeignKey( + name: "FK_Claims_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "LawyerCategoryUsers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CategoryId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LawyerCategoryUsers", x => x.Id); + table.ForeignKey( + name: "FK_LawyerCategoryUsers_LawyerCategories_CategoryId", + column: x => x.CategoryId, + principalSchema: "public", + principalTable: "LawyerCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_LawyerCategoryUsers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Lawyers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + LawyerCode = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lawyers", x => x.Id); + table.ForeignKey( + name: "FK_Lawyers_Users_Id", + column: x => x.Id, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Logins", + schema: "public", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_Logins_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Reviews", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Comment = table.Column(type: "text", nullable: false), + Rate = table.Column(type: "double precision", nullable: false), + Type = table.Column(type: "integer", nullable: false), + Discriminator = table.Column(type: "character varying(13)", maxLength: 13, nullable: false), + ApplicationUserId = table.Column(type: "uuid", nullable: true), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Reviews", x => x.Id); + table.ForeignKey( + name: "FK_Reviews_Users_ApplicationUserId", + column: x => x.ApplicationUserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Tokens", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_Tokens_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "UserRoles", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_UserRoles_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserRoles_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "StorageFiles", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + FileLocation = table.Column(type: "text", nullable: false), + FileName = table.Column(type: "text", nullable: false), + IsHeader = table.Column(type: "boolean", nullable: false), + IsPrimary = table.Column(type: "boolean", nullable: false), + FileType = table.Column(type: "integer", nullable: false), + Discriminator = table.Column(type: "character varying(21)", maxLength: 21, nullable: false), + BlogId = table.Column(type: "uuid", nullable: true), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_StorageFiles", x => x.Id); + table.ForeignKey( + name: "FK_StorageFiles_Blogs_BlogId", + column: x => x.BlogId, + principalSchema: "public", + principalTable: "Blogs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Blogs_CategoryId", + schema: "public", + table: "Blogs", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Claims_UserId", + schema: "public", + table: "Claims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_LawyerCategoryUsers_CategoryId", + schema: "public", + table: "LawyerCategoryUsers", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_LawyerCategoryUsers_UserId", + schema: "public", + table: "LawyerCategoryUsers", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Logins_UserId", + schema: "public", + table: "Logins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Reviews_ApplicationUserId", + schema: "public", + table: "Reviews", + column: "ApplicationUserId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleClaims_RoleId", + schema: "public", + table: "RoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + schema: "public", + table: "Roles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_StorageFiles_BlogId", + schema: "public", + table: "StorageFiles", + column: "BlogId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoles_RoleId", + schema: "public", + table: "UserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + schema: "public", + table: "Users", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + schema: "public", + table: "Users", + column: "NormalizedUserName", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Claims", + schema: "public"); + + migrationBuilder.DropTable( + name: "LawyerCategoryUsers", + schema: "public"); + + migrationBuilder.DropTable( + name: "Lawyers", + schema: "public"); + + migrationBuilder.DropTable( + name: "LegalForms", + schema: "public"); + + migrationBuilder.DropTable( + name: "LegalRequests", + schema: "public"); + + migrationBuilder.DropTable( + name: "Logins", + schema: "public"); + + migrationBuilder.DropTable( + name: "Reviews", + schema: "public"); + + migrationBuilder.DropTable( + name: "RoleClaims", + schema: "public"); + + migrationBuilder.DropTable( + name: "StorageFiles", + schema: "public"); + + migrationBuilder.DropTable( + name: "Tokens", + schema: "public"); + + migrationBuilder.DropTable( + name: "UserCallRequests", + schema: "public"); + + migrationBuilder.DropTable( + name: "UserRoles", + schema: "public"); + + migrationBuilder.DropTable( + name: "LawyerCategories", + schema: "public"); + + migrationBuilder.DropTable( + name: "Blogs", + schema: "public"); + + migrationBuilder.DropTable( + name: "Roles", + schema: "public"); + + migrationBuilder.DropTable( + name: "Users", + schema: "public"); + + migrationBuilder.DropTable( + name: "BlogCategories", + schema: "public"); + } + } +} diff --git a/HiVakil.Repository/Migrations/ApplicationContextModelSnapshot.cs b/HiVakil.Repository/Migrations/ApplicationContextModelSnapshot.cs new file mode 100644 index 0000000..36c85cc --- /dev/null +++ b/HiVakil.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -0,0 +1,844 @@ +// +using System; +using HiVakil.Repository.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace HiVakil.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + partial class ApplicationContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LawyerCategories", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategoryUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("UserId"); + + b.ToTable("LawyerCategoryUsers", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LegalForms.LegalForm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LegalForms", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LegalRequests.LegalRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LegalRequests", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("character varying(13)"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Reviews", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Review"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CityId") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.UserCallRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("UserCallRequests", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.LawyerReview", b => + { + b.HasBaseType("HiVakil.Domain.Entities.Reviews.Review"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.HasIndex("ApplicationUserId"); + + b.HasDiscriminator().HasValue("LawyerReview"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("HiVakil.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.Lawyer", b => + { + b.HasBaseType("HiVakil.Domain.Entities.Users.ApplicationUser"); + + b.Property("LawyerCode") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Lawyers", "public"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("HiVakil.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategoryUser", b => + { + b.HasOne("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", "Category") + .WithMany("Users") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Reviews.LawyerReview", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("HiVakil.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Users.Lawyer", b => + { + b.HasOne("HiVakil.Domain.Entities.Users.ApplicationUser", null) + .WithOne() + .HasForeignKey("HiVakil.Domain.Entities.Users.Lawyer", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("HiVakil.Domain.Entities.LawyerCategories.LawyerCategory", b => + { + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/HiVakil.Repository/Models/ApplicationContext.cs b/HiVakil.Repository/Models/ApplicationContext.cs index 4c82549..5ddd0dc 100644 --- a/HiVakil.Repository/Models/ApplicationContext.cs +++ b/HiVakil.Repository/Models/ApplicationContext.cs @@ -36,6 +36,7 @@ public class ApplicationContext : IdentityDbContext().ToTable("Users"); + builder.Entity().ToTable("Lawyers"); builder.Entity().ToTable("Roles"); builder.Entity>().ToTable("RoleClaims"); builder.Entity>().ToTable("UserRoles");