faet : add version 0.26.30.51 , add navbaritem , fix : scheduler job issue

release
Amir Hossein Khademi 2024-04-28 22:10:54 +03:30
parent 12ab03a520
commit e024b4d977
45 changed files with 176 additions and 137 deletions

View File

@ -1 +1 @@
0.25.29.50 0.26.30.51

View File

@ -17,7 +17,7 @@
"TaxesFee": 9 "TaxesFee": 9
}, },
"SiteSettings": { "SiteSettings": {
"BaseUrl": "http://192.168.1.12:32770", "BaseUrl": "http://localhost:32770",
"WebSiteUrl": "https://hamyan.visabartar.com", "WebSiteUrl": "https://hamyan.visabartar.com",
"AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com", "AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com",
"StorageBaseUrl": "https://storage.visabartar.com", "StorageBaseUrl": "https://storage.visabartar.com",

View File

@ -1,7 +1,4 @@
using Netina.Core.CoreServices.Abstracts; namespace Netina.Api.Controllers;
using Netina.Domain.Dtos.RequestDtos;
namespace Netina.Api.Controller;
public class AuthController : ICarterModule public class AuthController : ICarterModule

View File

@ -1,6 +1,6 @@
using Netina.Domain.Entities.Blogs; using Netina.Domain.Entities.Blogs;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class BlogCategoryController : ICarterModule public class BlogCategoryController : ICarterModule
{ {
@ -32,20 +32,22 @@ public class BlogCategoryController : ICarterModule
} }
// GET:Get All Entity // GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int? page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public async Task<IResult> GetAllAsync([FromQuery] int? page,[FromQuery]string? categoryName , IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{ {
var query = repositoryWrapper.SetRepository<BlogCategory>()
.TableNoTracking;
if (categoryName != null)
query = query.Where(q => q.Name.Trim().ToUpper().Contains(categoryName.Trim().ToUpper()));
if (page != null) if (page != null)
{ {
return TypedResults.Ok(await repositoryWrapper.SetRepository<BlogCategory>().TableNoTracking return TypedResults.Ok(await query.OrderByDescending(b => b.Name).Skip(page.Value * 10).Take(10)
.OrderByDescending(b => b.Name).Skip(page.Value * 10).Take(10)
.Select(BlogCategoryMapper.ProjectToSDto) .Select(BlogCategoryMapper.ProjectToSDto)
.ToListAsync(cancellationToken)); .ToListAsync(cancellationToken));
} }
else else
{ {
return TypedResults.Ok(await repositoryWrapper.SetRepository<BlogCategory>().TableNoTracking return TypedResults.Ok(await query.OrderByDescending(b => b.Name)
.OrderByDescending(b => b.Name)
.Select(BlogCategoryMapper.ProjectToSDto) .Select(BlogCategoryMapper.ProjectToSDto)
.ToListAsync(cancellationToken)); .ToListAsync(cancellationToken));
} }

View File

@ -1,10 +1,6 @@
using Netina.Common.Models.Exception; using Netina.Domain.Entities.Blogs;
using Netina.Domain.Dtos.LargDtos;
using Netina.Domain.Entities.Blogs;
using Netina.Domain.Models.Claims;
using Netina.Repository.Repositories.Base.Contracts;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class BlogController : ICarterModule public class BlogController : ICarterModule
{ {
@ -42,15 +38,19 @@ public class BlogController : ICarterModule
} }
// GET:Get All Entity // GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery] Guid? blogCategoryId, IMediator mediator, CancellationToken cancellationToken) public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery]int? count, [FromQuery] Guid? blogCategoryId, [FromQuery]string? blogName, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetBlogsQuery(page, CategoryId: blogCategoryId), cancellationToken)); => TypedResults.Ok(await mediator.Send(new GetBlogsQuery(page,Count: count, CategoryId: blogCategoryId,BlogName: blogName), cancellationToken));
// GET:Get An Entity By Id // GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper,
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Blog>().TableNoTracking CancellationToken cancellationToken)
.Where(b=>b.Id==id) {
var dto = await repositoryWrapper.SetRepository<Blog>().TableNoTracking
.Where(b => b.Id == id)
.Select(BlogMapper.ProjectToLDto) .Select(BlogMapper.ProjectToLDto)
.FirstOrDefaultAsync(cancellationToken)); .FirstOrDefaultAsync(cancellationToken);
return TypedResults.Ok(dto);
}
// POST:Create Entity // POST:Create Entity
public async Task<IResult> Post([FromBody] BlogLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public async Task<IResult> Post([FromBody] BlogLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)

View File

@ -1,10 +1,6 @@
using Netina.Domain.CommandQueries.Commands; using Netina.Domain.Entities.Brands;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Entities.Brands;
using Netina.Domain.Models.Claims;
using Netina.Repository.Repositories.Base.Contracts;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class BrandController : ICarterModule public class BrandController : ICarterModule
{ {

View File

@ -1,7 +1,4 @@
using Netina.Core.BaseServices.Abstracts; namespace Netina.Api.Controllers;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class DashboardController : ICarterModule public class DashboardController : ICarterModule
{ {

View File

@ -1,8 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class DiscountController : ICarterModule public class DiscountController : ICarterModule
{ {

View File

@ -1,6 +1,4 @@
using Netina.Core.Abstracts; namespace Netina.Api.Controllers;
namespace Netina.Api.Controller;
public class DistrictController : ICarterModule public class DistrictController : ICarterModule
{ {

View File

@ -1,9 +1,6 @@
using Netina.Common.Models.Api; using Netina.Domain.Enums;
using Netina.Core.Abstracts;
using Netina.Domain.Enums;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class FileController : ICarterModule public class FileController : ICarterModule
{ {

View File

@ -1,6 +1,6 @@
using MD.PersianDateTime.Standard; using MD.PersianDateTime.Standard;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class HealthController : ICarterModule public class HealthController : ICarterModule
{ {

View File

@ -1,6 +1,6 @@
using Netina.Api.Views.Home; using Netina.Api.Views.Home;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
[Route("")] [Route("")]
[AllowAnonymous] [AllowAnonymous]

View File

@ -1,6 +1,6 @@
using Netina.Domain.MartenEntities.Settings; using Netina.Domain.MartenEntities.Settings;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class MarketerController : ICarterModule public class MarketerController : ICarterModule
{ {

View File

@ -1,8 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class NewsletterMemberController : ICarterModule public class NewsletterMemberController : ICarterModule
{ {

View File

@ -1,10 +1,6 @@
using Netina.Domain.CommandQueries.Commands; using Netina.Domain.Enums;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Dtos.RequestDtos;
using Netina.Domain.Enums;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class OrderBagController : ICarterModule public class OrderBagController : ICarterModule
{ {

View File

@ -1,9 +1,6 @@
using Netina.Domain.CommandQueries.Commands; using Netina.Domain.Enums;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Enums;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class OrderController : ICarterModule public class OrderController : ICarterModule
{ {
public void AddRoutes(IEndpointRouteBuilder app) public void AddRoutes(IEndpointRouteBuilder app)

View File

@ -1,8 +1,4 @@
using Netina.Core.CoreServices.Abstracts; namespace Netina.Api.Controllers;
using Netina.Domain.Dtos.RequestDtos;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class PageController : ICarterModule public class PageController : ICarterModule
{ {

View File

@ -1,10 +1,7 @@
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Netina.Core.Abstracts;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
using TypedResults = Microsoft.AspNetCore.Http.TypedResults; using TypedResults = Microsoft.AspNetCore.Http.TypedResults;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class PaymentController : ICarterModule public class PaymentController : ICarterModule
{ {

View File

@ -1,8 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class ProductCategoryController : ICarterModule public class ProductCategoryController : ICarterModule
{ {

View File

@ -1,9 +1,6 @@
using Netina.Domain.CommandQueries.Commands; using Netina.Domain.Enums;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Enums;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class ProductController : ICarterModule public class ProductController : ICarterModule
{ {

View File

@ -1,8 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class ProductReviewController : ICarterModule public class ProductReviewController : ICarterModule
{ {

View File

@ -1,8 +1,6 @@
using Netina.Core.EntityServices.Abstracts; using Netina.Core.EntityServices.Abstracts;
using Netina.Domain.Dtos.RequestDtos;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class RoleController : ICarterModule public class RoleController : ICarterModule
{ {

View File

@ -1,4 +1,4 @@
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class ScraperController : ICarterModule public class ScraperController : ICarterModule
{ {

View File

@ -1,6 +1,4 @@
using Netina.Core.CoreServices.Abstracts; namespace Netina.Api.Controllers;
namespace Netina.Api.Controller;
public class SearchController : ICarterModule public class SearchController : ICarterModule
{ {

View File

@ -1,7 +1,7 @@
using Netina.Domain.Dtos.RequestDtos.SeedDtos; using Netina.Domain.Dtos.RequestDtos.SeedDtos;
using Netina.Domain.Entities.Blogs; using Netina.Domain.Entities.Blogs;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class SeedController : ICarterModule public class SeedController : ICarterModule
{ {
private readonly IWebHostEnvironment _environment; private readonly IWebHostEnvironment _environment;
@ -110,10 +110,10 @@ public class SeedController : ICarterModule
var noCategory = await repositoryWrapper.SetRepository<BlogCategory>() var noCategory = await repositoryWrapper.SetRepository<BlogCategory>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(bc => bc.Name == "دسته بندی نشده", cancellationToken); .FirstOrDefaultAsync(bc => bc.Name == "دسته بندی نشده", cancellationToken);
if(noCategory != null) if (noCategory != null)
seedBlogRequestDto.CategoryId = noCategory.Id; seedBlogRequestDto.CategoryId = noCategory.Id;
} }
var ent = Blog.Create(seedBlogRequestDto.Title,seedBlogRequestDto.Slug, seedBlogRequestDto.Content, seedBlogRequestDto.Tags, seedBlogRequestDto.ReadingTime, var ent = Blog.Create(seedBlogRequestDto.Title, seedBlogRequestDto.Slug, seedBlogRequestDto.Content, seedBlogRequestDto.Tags, seedBlogRequestDto.ReadingTime,
seedBlogRequestDto.Summery, seedBlogRequestDto.IsSuggested, seedBlogRequestDto.CategoryId); seedBlogRequestDto.Summery, seedBlogRequestDto.IsSuggested, seedBlogRequestDto.CategoryId);
foreach (var storageFileSDto in seedBlogRequestDto.Files) foreach (var storageFileSDto in seedBlogRequestDto.Files)
@ -125,6 +125,35 @@ public class SeedController : ICarterModule
repositoryWrapper.SetRepository<Blog>().Add(ent); repositoryWrapper.SetRepository<Blog>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
} }
//var blogs = await repositoryWrapper.SetRepository<Blog>()
// .TableNoTracking
// .ToListAsync(cancellationToken);
//foreach (var blog in blogs)
//{
// if (blog.Id == Guid.Parse("358192ec-32b0-4643-8269-b42268755b5b"))
// {
// }
// blog.Content = blog.Content.Replace(@"<p style=""text-align: center;""><strong>(10 خط ) </strong><a href=""tel:02144850335"">02144850335</a>📞  <a href=""tel:02144872230"">02144872230</a> 📞  <a href=""tel:02144872230"">02144872231</a> 📞</p>", string.Empty);
// blog.Content = blog.Content.Replace(@"<p style=""text-align: center;""><strong>(10 خط ) </strong><a href=""tel:02144850335"">02144850335</a>📞  <a href=""tel:02144872230"">02144872230</a> 📞  <a href=""tel:02144872230"">02144872231</a> 📞</p>", string.Empty);
// blog.Content = blog.Content.Replace(@"<p style=""text-align: center;"">تلفن های تماس :</p>", string.Empty);
// blog.Content = blog.Content.Replace("02122894819", string.Empty);
// blog.Content = blog.Content.Replace("02144850335", string.Empty);
// blog.Content = blog.Content.Replace("02126702518", string.Empty);
// blog.Content = blog.Content.Replace("02144872230", string.Empty);
// blog.Content = blog.Content.Replace("02144872231", string.Empty);
// blog.Content = blog.Content.Replace("02144850335", string.Empty);
// blog.Content = blog.Content.Replace("02144872230", string.Empty);
// blog.Content = blog.Content.Replace("02144872231", string.Empty);
// blog.Content = blog.Content.Replace("۰۲۱۴۴۸۵۰۳۳۵", string.Empty);
// blog.Content = blog.Content.Replace("۰۲۱۴۴۸۷۲۲۳۰", string.Empty);
// blog.Content = blog.Content.Replace("۰۲۱۴۴۸۷۲۲۳۱", string.Empty);
// repositoryWrapper.SetRepository<Blog>()
// .Update(blog);
// await repositoryWrapper.SaveChangesAsync(cancellationToken);
//}
return TypedResults.Ok(); return TypedResults.Ok();
} }

View File

@ -1,8 +1,6 @@
using System.Text.Json; using System.Text.Json;
using Netina.Core.CoreServices.Abstracts;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class SettingController : ICarterModule public class SettingController : ICarterModule
{ {

View File

@ -1,8 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
namespace Netina.Api.Controller;
public class ShippingController : ICarterModule public class ShippingController : ICarterModule
{ {

View File

@ -1,7 +1,4 @@
using Netina.Domain.CommandQueries.Commands; namespace Netina.Api.Controllers;
using Netina.Domain.CommandQueries.Queries;
namespace Netina.Api.Controller;
public class UserAddressController : ICarterModule public class UserAddressController : ICarterModule
{ {

View File

@ -1,12 +1,7 @@
using Netina.Common.Models.Api; using Netina.Core.EntityServices.Abstracts;
using Netina.Common.Models.Exception;
using Netina.Core.EntityServices.Abstracts;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Dtos.RequestDtos;
using Netina.Domain.Models.Claims;
using Netina.Repository.Abstracts; using Netina.Repository.Abstracts;
namespace Netina.Api.Controller; namespace Netina.Api.Controllers;
public class UserController : ICarterModule public class UserController : ICarterModule
{ {

View File

@ -0,0 +1,28 @@
using Netina.Domain.MartenEntities.Settings;
namespace Netina.Api.Controllers;
public class WebSiteController:ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("WebSite").MapGroup("api/website");
group.MapGet("/navbar", GetNavBarItemsAsync)
.WithDisplayName("Get NavBar Items")
.HasApiVersion(1.0);
}
private async Task<IResult> GetNavBarItemsAsync([FromServices]ISettingService settingService,CancellationToken cancellationToken)
{
var navBarSetting = await settingService.GetSettingAsync(nameof(NavMenuSetting), cancellationToken) as NavMenuSetting;
if (navBarSetting == null)
return TypedResults.Ok();
navBarSetting.NavMenuItems.ForEach(n =>
{
n.Children = navBarSetting.NavMenuItems.Where(ni => ni.ParentId == n.Id).ToList();
});
navBarSetting.NavMenuItems.Where(n=>n.ParentId != default).ToList().ForEach(ni=>navBarSetting.NavMenuItems.Remove(ni));
return TypedResults.Ok(navBarSetting.NavMenuItems);
}
}

View File

@ -6,8 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>0.25.29.50</AssemblyVersion> <AssemblyVersion>0.26.30.51</AssemblyVersion>
<FileVersion>0.25.29.50</FileVersion> <FileVersion>0.26.30.51</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -123,6 +123,7 @@ app.UseExceptionHandlerMiddleware();
app.MapCarter(); app.MapCarter();
app.UseStaticFiles(); app.UseStaticFiles();
await app.InitialDb(); await app.InitialDb();
await app.CoreInit();
app.MapControllers(); app.MapControllers();
app.Run(); app.Run();

View File

@ -13,7 +13,7 @@ public static class ServiceExtensions
// configure and register Quartz // configure and register Quartz
var schedulerConfig = new NameValueCollection { var schedulerConfig = new NameValueCollection {
{"quartz.threadPool.threadCount", "3"}, {"quartz.threadPool.threadCount", "3"},
{"quartz.scheduler.threadName", "BrizCo_Scheduler"} {"quartz.scheduler.threadName", "Netina_Scheduler"}
}; };
builder.RegisterModule(new QuartzAutofacFactoryModule builder.RegisterModule(new QuartzAutofacFactoryModule

View File

@ -1,7 +1,19 @@
namespace Netina.Core using Microsoft.AspNetCore.Builder;
{ using Microsoft.Extensions.DependencyInjection;
public class CoreConfig using Netina.Core.QuartzServices;
{
namespace Netina.Core;
public static class CoreConfig
{
public static async Task CoreInit(this IApplicationBuilder app)
{
var scopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();
using (var scope = scopeFactory.CreateScope())
{
var jobScheduler = scope.ServiceProvider.GetService<JobScheduler>();
jobScheduler.Start();
}
} }
} }

View File

@ -23,7 +23,7 @@ public class JobScheduler
.Build(); .Build();
ITrigger trigger = TriggerBuilder.Create() ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("SiteMapJobTrigger", "admin") .WithIdentity("SiteMapJobTrigger", "admin")
.WithSchedule(CronScheduleBuilder.AtHourAndMinuteOnGivenDaysOfWeek(3, 0, .WithSchedule(CronScheduleBuilder.AtHourAndMinuteOnGivenDaysOfWeek(3, 30,
DayOfWeek.Saturday, DayOfWeek.Saturday,
DayOfWeek.Sunday, DayOfWeek.Sunday,
DayOfWeek.Monday, DayOfWeek.Monday,

View File

@ -1,4 +1,4 @@
namespace Netina.Domain.CommandQueries.Queries; namespace Netina.Domain.CommandQueries.Queries;
public record GetBlogsQuery(int Page, Guid? CategoryId) : IRequest<GetBlogsResponseDto>; public record GetBlogsQuery(int Page,int? Count, Guid? CategoryId,string? BlogName) : IRequest<GetBlogsResponseDto>;

View File

@ -5,4 +5,5 @@ public class BlogCategorySDto : BaseDto<BlogCategorySDto , BlogCategory>
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public int BlogCount { get; set; } public int BlogCount { get; set; }
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
} }

View File

@ -4,6 +4,7 @@ public class ProductCategorySDto : BaseDto<ProductCategorySDto , ProductCategory
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public string Slug { get; internal set; } = string.Empty;
public bool IsMain { get; set; } public bool IsMain { get; set; }
public Guid ParentId { get; set; } public Guid ParentId { get; set; }
public string ParentName { get; set; } = string.Empty; public string ParentName { get; set; } = string.Empty;

View File

@ -23,7 +23,7 @@ public partial class Blog : ApiEntity
Slug = slug; Slug = slug;
} }
public string Title { get; internal set; } = string.Empty; public string Title { get; internal set; } = string.Empty;
public string Content { get; internal set; } = string.Empty; public string Content { get; set; } = string.Empty;
public string Slug { get; internal set; } = string.Empty; public string Slug { get; internal set; } = string.Empty;
public string Tags { get; internal set; } = string.Empty; public string Tags { get; internal set; } = string.Empty;
public int ReadingTime { get; internal set; } public int ReadingTime { get; internal set; }

View File

@ -116,6 +116,7 @@ namespace Netina.Domain.Mappers
return p17 == null ? null : new BlogCategory() return p17 == null ? null : new BlogCategory()
{ {
Name = p17.Name, Name = p17.Name,
Slug = p17.Slug,
Description = p17.Description, Description = p17.Description,
Id = p17.Id, Id = p17.Id,
CreatedAt = p17.CreatedAt CreatedAt = p17.CreatedAt
@ -130,6 +131,7 @@ namespace Netina.Domain.Mappers
BlogCategory result = p19 ?? new BlogCategory(); BlogCategory result = p19 ?? new BlogCategory();
result.Name = p18.Name; result.Name = p18.Name;
result.Slug = p18.Slug;
result.Description = p18.Description; result.Description = p18.Description;
result.Id = p18.Id; result.Id = p18.Id;
result.CreatedAt = p18.CreatedAt; result.CreatedAt = p18.CreatedAt;
@ -143,6 +145,7 @@ namespace Netina.Domain.Mappers
Name = p20.Name, Name = p20.Name,
BlogCount = funcMain7(p20.Blogs == null ? null : (int?)p20.Blogs.Count), BlogCount = funcMain7(p20.Blogs == null ? null : (int?)p20.Blogs.Count),
Description = p20.Description, Description = p20.Description,
Slug = p20.Slug,
Id = p20.Id, Id = p20.Id,
CreatedAt = p20.CreatedAt CreatedAt = p20.CreatedAt
}; };
@ -158,6 +161,7 @@ namespace Netina.Domain.Mappers
result.Name = p22.Name; result.Name = p22.Name;
result.BlogCount = funcMain8(p22.Blogs == null ? null : (int?)p22.Blogs.Count, result.BlogCount); result.BlogCount = funcMain8(p22.Blogs == null ? null : (int?)p22.Blogs.Count, result.BlogCount);
result.Description = p22.Description; result.Description = p22.Description;
result.Slug = p22.Slug;
result.Id = p22.Id; result.Id = p22.Id;
result.CreatedAt = p22.CreatedAt; result.CreatedAt = p22.CreatedAt;
return result; return result;
@ -168,6 +172,7 @@ namespace Netina.Domain.Mappers
Name = p26.Name, Name = p26.Name,
BlogCount = p26.Blogs.Count, BlogCount = p26.Blogs.Count,
Description = p26.Description, Description = p26.Description,
Slug = p26.Slug,
Id = p26.Id, Id = p26.Id,
CreatedAt = p26.CreatedAt CreatedAt = p26.CreatedAt
}; };

View File

@ -131,6 +131,7 @@ namespace Netina.Domain.Mappers
return p19 == null ? null : new ProductCategory() return p19 == null ? null : new ProductCategory()
{ {
Name = p19.Name, Name = p19.Name,
Slug = p19.Slug,
Description = p19.Description, Description = p19.Description,
IsMain = p19.IsMain, IsMain = p19.IsMain,
ParentId = (Guid?)p19.ParentId, ParentId = (Guid?)p19.ParentId,
@ -152,6 +153,7 @@ namespace Netina.Domain.Mappers
ProductCategory result = p21 ?? new ProductCategory(); ProductCategory result = p21 ?? new ProductCategory();
result.Name = p20.Name; result.Name = p20.Name;
result.Slug = p20.Slug;
result.Description = p20.Description; result.Description = p20.Description;
result.IsMain = p20.IsMain; result.IsMain = p20.IsMain;
result.ParentId = (Guid?)p20.ParentId; result.ParentId = (Guid?)p20.ParentId;
@ -167,6 +169,7 @@ namespace Netina.Domain.Mappers
{ {
Name = p24.Name, Name = p24.Name,
Description = p24.Description, Description = p24.Description,
Slug = p24.Slug,
IsMain = p24.IsMain, IsMain = p24.IsMain,
ParentId = p24.ParentId == null ? default(Guid) : (Guid)p24.ParentId, ParentId = p24.ParentId == null ? default(Guid) : (Guid)p24.ParentId,
ParentName = p24.Parent != null ? p24.Parent.Name : string.Empty, ParentName = p24.Parent != null ? p24.Parent.Name : string.Empty,
@ -185,6 +188,7 @@ namespace Netina.Domain.Mappers
result.Name = p25.Name; result.Name = p25.Name;
result.Description = p25.Description; result.Description = p25.Description;
result.Slug = p25.Slug;
result.IsMain = p25.IsMain; result.IsMain = p25.IsMain;
result.ParentId = p25.ParentId == null ? default(Guid) : (Guid)p25.ParentId; result.ParentId = p25.ParentId == null ? default(Guid) : (Guid)p25.ParentId;
result.ParentName = p25.Parent != null ? p25.Parent.Name : string.Empty; result.ParentName = p25.Parent != null ? p25.Parent.Name : string.Empty;
@ -198,6 +202,7 @@ namespace Netina.Domain.Mappers
{ {
Name = p27.Name, Name = p27.Name,
Description = p27.Description, Description = p27.Description,
Slug = p27.Slug,
IsMain = p27.IsMain, IsMain = p27.IsMain,
ParentId = p27.ParentId == null ? default(Guid) : (Guid)p27.ParentId, ParentId = p27.ParentId == null ? default(Guid) : (Guid)p27.ParentId,
ParentName = p27.Parent != null ? p27.Parent.Name : string.Empty, ParentName = p27.Parent != null ? p27.Parent.Name : string.Empty,

View File

@ -0,0 +1,22 @@
namespace Netina.Domain.MartenEntities.Settings;
public class NavMenuSetting
{
public bool ShowProductCategories { get; set; }
public bool ShowBlogCategories { get; set; }
public List<NavMenuItem> NavMenuItems { get; set; } = new();
}
public class NavMenuItem
{
public NavMenuItem()
{
Id = Guid.NewGuid();
}
public Guid Id { get; set; }
public string Title { get; set; } = string.Empty;
public string Url { get; set; } = string.Empty;
public Guid ParentId { get; set; }
public NavMenuItem? Parent { get; set; }
public List<NavMenuItem> Children { get; set; } = new();
}

View File

@ -78,6 +78,7 @@
<Using Include="Netina.Domain.Entities.Users" /> <Using Include="Netina.Domain.Entities.Users" />
<Using Include="Netina.Domain.Entities.Warehouses" /> <Using Include="Netina.Domain.Entities.Warehouses" />
<Using Include="Netina.Domain.Enums" /> <Using Include="Netina.Domain.Enums" />
<Using Include="Netina.Domain.MartenEntities.Settings" />
<Using Include="System.ComponentModel.DataAnnotations" /> <Using Include="System.ComponentModel.DataAnnotations" />
<Using Include="System.Diagnostics" /> <Using Include="System.Diagnostics" />
<Using Include="System.Reflection" /> <Using Include="System.Reflection" />

View File

@ -14,13 +14,18 @@ public class GetBlogsQueryHandler : IRequestHandler<GetBlogsQuery,GetBlogsRespon
public async Task<GetBlogsResponseDto> Handle (GetBlogsQuery request, CancellationToken cancellationToken) public async Task<GetBlogsResponseDto> Handle (GetBlogsQuery request, CancellationToken cancellationToken)
{ {
var response = new GetBlogsResponseDto(); var response = new GetBlogsResponseDto();
int count = 20;
if (request.Count != null)
count = request.Count.Value;
var query = _repositoryWrapper.SetRepository<Blog>().TableNoTracking; var query = _repositoryWrapper.SetRepository<Blog>().TableNoTracking;
if (request.CategoryId != null) if (request.CategoryId != null)
query = query.Where(b => b.CategoryId == request.CategoryId); query = query.Where(b => b.CategoryId == request.CategoryId);
if (request.BlogName != null)
query = query.Where(b => b.Title.Trim().ToUpper().Contains(request.BlogName.Trim().ToUpper()));
var result = await query var result = await query
.OrderByDescending(b => b.CreatedAt) .OrderByDescending(b => b.CreatedAt)
.Skip(request.Page * 20).Take(20) .Skip(request.Page * count).Take(count)
.Select(BlogMapper.ProjectToSDto).ToListAsync(cancellationToken); .Select(BlogMapper.ProjectToSDto).ToListAsync(cancellationToken);
response.Pager.CurrentPage = request.Page; response.Pager.CurrentPage = request.Page;
response.Pager.TotalItems = await query.CountAsync(cancellationToken); response.Pager.TotalItems = await query.CountAsync(cancellationToken);

View File

@ -1,11 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Netina.Common.Models.Api;
using Netina.Common.Models.Exception;
using Netina.Domain.CommandQueries.Commands;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Dtos.ResponseDtos;
using Netina.Domain.Entities.Products;
using Netina.Repository.Repositories.Base.Contracts;
namespace Netina.Repository.Handlers.Products; namespace Netina.Repository.Handlers.Products;