feat : add version 0.23.26.46 , complete slug and db
parent
f880d72d07
commit
0249727d32
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
||||||
"Postgres": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi",
|
"Postgres": "Host=pg-0;Username=visabarterAgent;Password=xHTpBf4wC+bPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=HamyanDB;Application Name=HamyanApi",
|
||||||
"MartenDB": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopMartenDB;"
|
"MartenDB": "Host=pg-0;Username=visabarterAgent;Password=xHTpBf4wC+bPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=HamyanMartenDB;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
@ -17,38 +17,38 @@
|
||||||
"TaxesFee": 9
|
"TaxesFee": 9
|
||||||
},
|
},
|
||||||
"SiteSettings": {
|
"SiteSettings": {
|
||||||
"BaseUrl": "https://api.vesmeh.com",
|
"BaseUrl": "https://api.hamyan.visabartar.com",
|
||||||
"WebSiteUrl": "https://vesmeh.com",
|
"WebSiteUrl": "https://hamyan.visabartar.com",
|
||||||
"AdminPanelBaseUrl": "https://admin.vesmeh.com",
|
"AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com",
|
||||||
"StorageBaseUrl": "https://storage.vesmeh.com",
|
"StorageBaseUrl": "https://storage.visabartar.com",
|
||||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
||||||
"UserSetting": {
|
"UserSetting": {
|
||||||
"Username": "09214802813",
|
"Username": "09214802813",
|
||||||
"Email": "avvampier@gmail.com",
|
"Email": "avvampier@gmail.com",
|
||||||
"Password": "eF79o4P4BopCUbUK",
|
"Password": "2Tsr87RWRn5T",
|
||||||
"Phone": "09214802813",
|
"Phone": "09214802813",
|
||||||
"RoleName": "RootAdmin",
|
"RoleName": "RootAdmin",
|
||||||
"FirstName": "همه کاره",
|
"FirstName": "همه کاره",
|
||||||
"LastName": "سیستم"
|
"LastName": "سیستم"
|
||||||
},
|
},
|
||||||
"Manager": {
|
"Manager": {
|
||||||
"Username": "09128387004",
|
"Username": "09122171024",
|
||||||
"Email": "mahanmasiha6@gmail.com",
|
"Email": "kamran_mirzayi@gmail.com",
|
||||||
"Password": "eF79o4P4BopCUbUK",
|
"Password": "YAWEheKEi7gh",
|
||||||
"Phone": "09128387004",
|
"Phone": "09128387004",
|
||||||
"RoleName": "Manager",
|
"RoleName": "Manager",
|
||||||
"FirstName": "ماهان",
|
"FirstName": "کامران",
|
||||||
"LastName": ""
|
"LastName": "میرزایی"
|
||||||
},
|
},
|
||||||
"StorageSetting": {
|
"StorageSetting": {
|
||||||
"AccessKey": "979313b7-30fb-40ff-94d8-d0390d3fa876",
|
"AccessKey": "de129835-b43a-4552-8ed4-865e2635ab3d",
|
||||||
"SecretKey": "d37a1cc6acfea3a6f92c538ef0f6601f1edcdc9143942b6470e5d1032aa6bfe2",
|
"SecretKey": "f00197a766336e818023f90408ba3b88b4fdc86d0e7180f74f199d9f03db7575",
|
||||||
"BucketKey": "vesmeh-content"
|
"BucketKey": "hamyan-content"
|
||||||
},
|
},
|
||||||
"JwtSettings": {
|
"JwtSettings": {
|
||||||
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_nw+8E0EABj0Wg8c4mHg/bDBf5qGMhmBPb6u16DVe9/MzYva1e+/J1zImyIoQX2Lmra2kvzsIjGiwP7r3Znd_YA_JADE_NASABE_v+Ro/CDixScDv6EkpZnkBv9MFdPnSmFXNGMH9gA1BzQUoC1iSX9Aq+pMIw/cMKXI9WA==_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_Co0F8AlDfth0PmBuY/0xZQX25iKGQsro5HNkm+gGto4ijSm3hJQ7SViLmR2/BtHN_YA_JADE_NASABE_MSwIOzaxUqn8awSbMx02MSwIOzaxUqn8awSbMx02_EegU4lf9LB5LOyZWXLzLCyXtAp0moUh0_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
||||||
"Issuer": "Brizco",
|
"Issuer": "Hamyan",
|
||||||
"Audience": "Brizco",
|
"Audience": "Hamyan",
|
||||||
"ExpireAddDay": "15"
|
"ExpireAddDay": "15"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
"TaxesFee": 9
|
"TaxesFee": 9
|
||||||
},
|
},
|
||||||
"SiteSettings": {
|
"SiteSettings": {
|
||||||
"BaseUrl": "http://192.168.1.12:32770",
|
"BaseUrl": "https://api.hamyan.visabartar.com",
|
||||||
"WebSiteUrl": "https://hamyanedalat.com",
|
"WebSiteUrl": "https://hamyan.visabartar.com",
|
||||||
"AdminPanelBaseUrl": "https://admin.hamyanedalat.com",
|
"AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com",
|
||||||
"StorageBaseUrl": "https://storage.hamyanedalat.com",
|
"StorageBaseUrl": "https://storage.visabartar.com",
|
||||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
||||||
"UserSetting": {
|
"UserSetting": {
|
||||||
"Username": "09214802813",
|
"Username": "09214802813",
|
||||||
"Email": "avvampier@gmail.com",
|
"Email": "avvampier@gmail.com",
|
||||||
"Password": "eF79o4P4BopCUbUK",
|
"Password": "2Tsr87RWRn5T",
|
||||||
"Phone": "09214802813",
|
"Phone": "09214802813",
|
||||||
"RoleName": "RootAdmin",
|
"RoleName": "RootAdmin",
|
||||||
"FirstName": "همه کاره",
|
"FirstName": "همه کاره",
|
||||||
|
@ -33,9 +33,9 @@
|
||||||
},
|
},
|
||||||
"Manager": {
|
"Manager": {
|
||||||
"Username": "09122171024",
|
"Username": "09122171024",
|
||||||
"Email": "info@hamyanedalat.com",
|
"Email": "kamran_mirzayi@gmail.com",
|
||||||
"Password": "eF79o4P4BopCUbUK",
|
"Password": "YAWEheKEi7gh",
|
||||||
"Phone": "09122171024",
|
"Phone": "09128387004",
|
||||||
"RoleName": "Manager",
|
"RoleName": "Manager",
|
||||||
"FirstName": "کامران",
|
"FirstName": "کامران",
|
||||||
"LastName": "میرزایی"
|
"LastName": "میرزایی"
|
||||||
|
@ -46,9 +46,9 @@
|
||||||
"BucketKey": "hamyan-content"
|
"BucketKey": "hamyan-content"
|
||||||
},
|
},
|
||||||
"JwtSettings": {
|
"JwtSettings": {
|
||||||
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_nw+8E0EABj0Wg8c4mHg/bDBf5qGMhmBPb6u16DVe9/MzYva1e+/J1zImyIoQX2Lmra2kvzsIjGiwP7r3Znd_YA_JADE_NASABE_v+Ro/CDixScDv6EkpZnkBv9MFdPnSmFXNGMH9gA1BzQUoC1iSX9Aq+pMIw/cMKXI9WA==_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_Co0F8AlDfth0PmBuY/0xZQX25iKGQsro5HNkm+gGto4ijSm3hJQ7SViLmR2/BtHN_YA_JADE_NASABE_MSwIOzaxUqn8awSbMx02MSwIOzaxUqn8awSbMx02_EegU4lf9LB5LOyZWXLzLCyXtAp0moUh0_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
||||||
"Issuer": "HamaynEdalat",
|
"Issuer": "Hamyan",
|
||||||
"Audience": "HamaynEdalat",
|
"Audience": "Hamyan",
|
||||||
"ExpireAddDay": "15"
|
"ExpireAddDay": "15"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
"PostgresServer": "Host=185.220.227.88;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi",
|
||||||
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
||||||
"MartenDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB;"
|
"MartenDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB;"
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SeedController : ICarterModule
|
||||||
.WithDisplayName("SeedBlogsAsync")
|
.WithDisplayName("SeedBlogsAsync")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
group.MapPost("blog/categories", SeedBlogCategoriesAsync)
|
group.MapPost("blog/categories", SeedBlogCategoriesSlugAsync)
|
||||||
.WithDisplayName("SeedBlogCategoriesAsync")
|
.WithDisplayName("SeedBlogCategoriesAsync")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
}
|
}
|
||||||
|
@ -141,12 +141,34 @@ public class SeedController : ICarterModule
|
||||||
categories.Add(0, baseCategory.Id);
|
categories.Add(0, baseCategory.Id);
|
||||||
foreach (var requestDto in request)
|
foreach (var requestDto in request)
|
||||||
{
|
{
|
||||||
var ent = BlogCategory.Create(requestDto.Name, requestDto.Description);
|
var ent = BlogCategory.Create(requestDto.Name,requestDto.Slug, requestDto.Description);
|
||||||
repositoryWrapper.SetRepository<BlogCategory>().Add(ent);
|
repositoryWrapper.SetRepository<BlogCategory>().Add(ent);
|
||||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
categories.Add(requestDto.BaseCategoryId, ent.Id);
|
categories.Add(requestDto.BaseCategoryId, ent.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TypedResults.Ok(categories);
|
||||||
|
}
|
||||||
|
public async Task<IResult> SeedBlogCategoriesSlugAsync([FromBody] List<SeedBlogCategoryRequestDto> request, [FromQuery] string key, [FromServices] IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==")
|
||||||
|
throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized);
|
||||||
|
|
||||||
|
Dictionary<int, Guid> categories = new Dictionary<int, Guid>();
|
||||||
|
foreach (var requestDto in request)
|
||||||
|
{
|
||||||
|
var ent = await repositoryWrapper.SetRepository<BlogCategory>()
|
||||||
|
.TableNoTracking
|
||||||
|
.FirstOrDefaultAsync(bc=>bc.Name==requestDto.Name,cancellationToken);
|
||||||
|
if (ent == null)
|
||||||
|
continue;
|
||||||
|
ent.Slug = requestDto.Slug;
|
||||||
|
repositoryWrapper.SetRepository<BlogCategory>().Update(ent);
|
||||||
|
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
|
categories.Add(requestDto.BaseCategoryId, ent.Id);
|
||||||
|
}
|
||||||
|
|
||||||
return TypedResults.Ok(categories);
|
return TypedResults.Ok(categories);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ builder.Host.UseSerilog();
|
||||||
LoggerConfig.ConfigureSerilog();
|
LoggerConfig.ConfigureSerilog();
|
||||||
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
|
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
|
||||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||||
string projectName = "Hamyan";
|
string projectName = "Vesmeh";
|
||||||
if (builder.Environment.IsDevelopment())
|
if (builder.Environment.IsDevelopment())
|
||||||
builder.Configuration.AddJsonFile($"AppSettings/appsettings.json").AddJsonFile($"AppSettings/appsettings.{env}{projectName}.json");
|
builder.Configuration.AddJsonFile($"AppSettings/appsettings.json").AddJsonFile($"AppSettings/appsettings.{env}{projectName}.json");
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
namespace Netina.Common.Extensions
|
using System.Web;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace Netina.Common.Extensions
|
||||||
{
|
{
|
||||||
public static class StringExtensions
|
public static class StringExtensions
|
||||||
{
|
{
|
||||||
|
public static string GetSlug(string title)
|
||||||
|
{
|
||||||
|
return HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
||||||
|
}
|
||||||
public static string ToPriceWhitPriceType(this long price, string priceType)
|
public static string ToPriceWhitPriceType(this long price, string priceType)
|
||||||
{
|
{
|
||||||
return price.ToString("N0") + " " + priceType;
|
return price.ToString("N0") + " " + priceType;
|
||||||
|
|
|
@ -17,5 +17,6 @@ public class SeedBlogCategoryRequestDto
|
||||||
{
|
{
|
||||||
public int BaseCategoryId { get; set; }
|
public int BaseCategoryId { get; set; }
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Web;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
|
|
||||||
namespace Netina.Domain.Entities.Blogs;
|
namespace Netina.Domain.Entities.Blogs;
|
||||||
|
|
||||||
|
@ -7,14 +6,14 @@ public partial class Blog
|
||||||
{
|
{
|
||||||
public static Blog Create(string title, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
|
public static Blog Create(string title, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
|
||||||
{
|
{
|
||||||
var slug = HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
var slug = StringExtensions.GetSlug(title);
|
||||||
return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
|
return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Blog Create(string title, string slug, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
|
public static Blog Create(string title, string slug, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
|
||||||
{
|
{
|
||||||
if (slug.IsNullOrEmpty())
|
if (slug.IsNullOrEmpty())
|
||||||
slug = HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
slug = StringExtensions.GetSlug(title);
|
||||||
return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
|
return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
|
||||||
}
|
}
|
||||||
public BlogStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
public BlogStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
||||||
|
@ -37,6 +36,13 @@ public partial class BlogCategory
|
||||||
{
|
{
|
||||||
public static BlogCategory Create(string name, string description)
|
public static BlogCategory Create(string name, string description)
|
||||||
{
|
{
|
||||||
return new BlogCategory(name, description);
|
var slug = StringExtensions.GetSlug(name);
|
||||||
|
return new BlogCategory(name, slug, description);
|
||||||
|
}
|
||||||
|
public static BlogCategory Create(string name, string slug, string description)
|
||||||
|
{
|
||||||
|
if (slug.IsNullOrEmpty())
|
||||||
|
slug = StringExtensions.GetSlug(name);
|
||||||
|
return new BlogCategory(name, slug, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,12 +10,14 @@ public partial class BlogCategory : ApiEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlogCategory(string name, string description)
|
public BlogCategory(string name,string slug, string description)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Slug = slug;
|
||||||
Description = description;
|
Description = description;
|
||||||
}
|
}
|
||||||
public string Name { get; internal set; } = string.Empty;
|
public string Name { get; internal set; } = string.Empty;
|
||||||
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Description { get; internal set; } = string.Empty;
|
public string Description { get; internal set; } = string.Empty;
|
||||||
public List<Blog> Blogs { get; internal set; } = new();
|
public List<Blog> Blogs { get; internal set; } = new();
|
||||||
}
|
}
|
|
@ -4,7 +4,9 @@ public partial class Brand
|
||||||
{
|
{
|
||||||
public static Brand Create(string persianName, string englishName, string description, bool hasSpecialPage, string pageUrl)
|
public static Brand Create(string persianName, string englishName, string description, bool hasSpecialPage, string pageUrl)
|
||||||
{
|
{
|
||||||
return new Brand(persianName,englishName, description, hasSpecialPage, pageUrl);
|
|
||||||
|
var slug = StringExtensions.GetSlug(persianName);
|
||||||
|
return new Brand(persianName, slug, englishName, description, hasSpecialPage, pageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrandStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
public BrandStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
||||||
|
|
|
@ -12,9 +12,10 @@ public partial class Brand : ApiEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Brand(string persianName,string englishName, string description, bool hasSpecialPage, string pageUrl)
|
public Brand(string persianName,string slug,string englishName, string description, bool hasSpecialPage, string pageUrl)
|
||||||
{
|
{
|
||||||
PersianName = persianName;
|
PersianName = persianName;
|
||||||
|
Slug = slug;
|
||||||
EnglishName = englishName;
|
EnglishName = englishName;
|
||||||
Description = description;
|
Description = description;
|
||||||
HasSpecialPage = hasSpecialPage;
|
HasSpecialPage = hasSpecialPage;
|
||||||
|
@ -22,6 +23,7 @@ public partial class Brand : ApiEntity
|
||||||
}
|
}
|
||||||
public string PersianName { get; internal set; } = string.Empty;
|
public string PersianName { get; internal set; } = string.Empty;
|
||||||
public string EnglishName { get; internal set; } = string.Empty;
|
public string EnglishName { get; internal set; } = string.Empty;
|
||||||
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Description { get; internal set; } = string.Empty;
|
public string Description { get; internal set; } = string.Empty;
|
||||||
public bool HasSpecialPage { get; internal set; }
|
public bool HasSpecialPage { get; internal set; }
|
||||||
public string PageUrl { get; internal set; } = string.Empty;
|
public string PageUrl { get; internal set; } = string.Empty;
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
namespace Netina.Domain.Entities.ProductCategories;
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Netina.Domain.Entities.ProductCategories;
|
||||||
|
|
||||||
public partial class ProductCategory
|
public partial class ProductCategory
|
||||||
{
|
{
|
||||||
public static ProductCategory Create(string name, string description,bool isMain)
|
public static ProductCategory Create(string name, string description,bool isMain)
|
||||||
{
|
{
|
||||||
return new ProductCategory(name, description, isMain);
|
var slug = StringExtensions.GetSlug(name);
|
||||||
|
return new ProductCategory(name, slug, description, isMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetParent(Guid parentId)
|
public void SetParent(Guid parentId)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
namespace Netina.Domain.Entities.ProductCategories;
|
namespace Netina.Domain.Entities.ProductCategories;
|
||||||
|
|
||||||
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
[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)]
|
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
|
||||||
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
||||||
|
@ -10,13 +11,15 @@ public partial class ProductCategory : ApiEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductCategory(string name, string description,bool isMain)
|
public ProductCategory(string name,string slug, string description,bool isMain)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Slug = slug;
|
||||||
Description = description;
|
Description = description;
|
||||||
IsMain = isMain;
|
IsMain = isMain;
|
||||||
}
|
}
|
||||||
public string Name { get; internal set; } = string.Empty;
|
public string Name { get; internal set; } = string.Empty;
|
||||||
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Description { get; internal set; } = string.Empty;
|
public string Description { get; internal set; } = string.Empty;
|
||||||
public bool IsMain { get; set; }
|
public bool IsMain { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Netina.Domain.Entities.Products;
|
namespace Netina.Domain.Entities.Products;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ public partial class Product
|
||||||
Guid brandId,
|
Guid brandId,
|
||||||
Guid categoryId)
|
Guid categoryId)
|
||||||
{
|
{
|
||||||
var slug = HttpUtility.UrlEncode(persianName.Replace(' ', '-'));
|
var slug = StringExtensions.GetSlug(persianName);
|
||||||
return new Product(
|
return new Product(
|
||||||
persianName,
|
persianName,
|
||||||
englishName,
|
englishName,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Netina.Domain.CommandQueries.Commands;
|
using Netina.Domain.CommandQueries.Commands;
|
||||||
using Netina.Domain.Dtos.ScraperDtos.Response;
|
using Netina.Domain.Dtos.ScraperDtos.Response;
|
||||||
using Netina.Domain.Dtos.SmallDtos;
|
using Netina.Domain.Dtos.SmallDtos;
|
||||||
|
@ -94,7 +95,8 @@ public class DigikalaScraper : IDigikalaScraper
|
||||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (digiProduct.product.title_en.IsNullOrEmpty())
|
||||||
|
digiProduct.product.title_en = digiProduct.product.title_fa;
|
||||||
|
|
||||||
var request = new CreateProductCommand(digiProduct.product.title_fa, digiProduct.product.title_en,
|
var request = new CreateProductCommand(digiProduct.product.title_fa, digiProduct.product.title_en,
|
||||||
newSummery,
|
newSummery,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using Netina.Domain.CommandQueries.Commands;
|
using Netina.Domain.Entities.Brands;
|
||||||
using Netina.Domain.Dtos.SmallDtos;
|
|
||||||
using Netina.Domain.Entities.Brands;
|
|
||||||
using Netina.Repository.Repositories.Base.Contracts;
|
|
||||||
|
|
||||||
namespace Netina.Repository.Handlers.Brands;
|
namespace Netina.Repository.Handlers.Brands;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Netina.Common.Models.Exception;
|
|
||||||
using Netina.Domain.CommandQueries.Commands;
|
|
||||||
using Netina.Domain.Entities.Brands;
|
using Netina.Domain.Entities.Brands;
|
||||||
using Netina.Repository.Repositories.Base.Contracts;
|
|
||||||
|
|
||||||
namespace Netina.Repository.Handlers.Brands;
|
namespace Netina.Repository.Handlers.Brands;
|
||||||
|
|
||||||
|
|
2025
Netina.Repository/Migrations/20240422113439_AddSlugCategoriesAndBrand.Designer.cs
generated
100644
2025
Netina.Repository/Migrations/20240422113439_AddSlugCategoriesAndBrand.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace NetinaShop.Repository.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddSlugCategoriesAndBrand : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "ProductCategories",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "BlogCategories",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "ProductCategories");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Slug",
|
||||||
|
schema: "public",
|
||||||
|
table: "BlogCategories");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ namespace NetinaShop.Repository.Migrations
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasDefaultSchema("public")
|
.HasDefaultSchema("public")
|
||||||
.HasAnnotation("ProductVersion", "8.0.3")
|
.HasAnnotation("ProductVersion", "8.0.4")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
@ -304,6 +304,10 @@ namespace NetinaShop.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Slug")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("BlogCategories", "public");
|
b.ToTable("BlogCategories", "public");
|
||||||
|
@ -358,6 +362,10 @@ namespace NetinaShop.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Slug")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Brands", "public");
|
b.ToTable("Brands", "public");
|
||||||
|
@ -756,6 +764,10 @@ namespace NetinaShop.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Slug")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ParentId");
|
b.HasIndex("ParentId");
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using Netina.Domain.Entities.Blogs;
|
||||||
|
using Netina.Domain.Entities.Brands;
|
||||||
|
|
||||||
namespace Netina.Repository.Services;
|
namespace Netina.Repository.Services;
|
||||||
|
|
||||||
|
@ -186,21 +188,86 @@ public class DbInitializerService : IDbInitializerService
|
||||||
|
|
||||||
public async Task Refactor()
|
public async Task Refactor()
|
||||||
{
|
{
|
||||||
var noSlugProducts = await _repositoryWrapper.SetRepository<Product>()
|
//var noSlugProducts = await _repositoryWrapper.SetRepository<Product>()
|
||||||
.TableNoTracking
|
// .TableNoTracking
|
||||||
.Where(p => p.Slug==string.Empty)
|
// .Where(p => p.Slug==string.Empty)
|
||||||
.ToListAsync();
|
// .ToListAsync();
|
||||||
|
|
||||||
if (noSlugProducts.Count > 0)
|
//if (noSlugProducts.Count > 0)
|
||||||
{
|
//{
|
||||||
noSlugProducts.ForEach(p =>
|
// noSlugProducts.ForEach(p =>
|
||||||
{
|
// {
|
||||||
var slug = HttpUtility.UrlEncode(p.PersianName.Replace(' ', '-'));
|
// var slug = StringExtensions.GetSlug(p.PersianName);
|
||||||
p.Slug = slug;
|
// p.Slug = slug;
|
||||||
});
|
// });
|
||||||
_repositoryWrapper.SetRepository<Product>()
|
// _repositoryWrapper.SetRepository<Product>()
|
||||||
.UpdateRange(noSlugProducts);
|
// .UpdateRange(noSlugProducts);
|
||||||
await _repositoryWrapper.SaveChangesAsync();
|
// await _repositoryWrapper.SaveChangesAsync();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
//var noSlugProductCategories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||||
|
// .TableNoTracking
|
||||||
|
// .Where(pc=>pc.Slug == string.Empty)
|
||||||
|
// .ToListAsync();
|
||||||
|
//if (noSlugProductCategories.Count > 0)
|
||||||
|
//{
|
||||||
|
// noSlugProductCategories.ForEach(p =>
|
||||||
|
// {
|
||||||
|
// var slug = StringExtensions.GetSlug(p.Name);
|
||||||
|
// p.Slug = slug;
|
||||||
|
// });
|
||||||
|
// _repositoryWrapper.SetRepository<ProductCategory>()
|
||||||
|
// .UpdateRange(noSlugProductCategories);
|
||||||
|
// await _repositoryWrapper.SaveChangesAsync();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//var notSlugBrands = await _repositoryWrapper.SetRepository<Brand>()
|
||||||
|
// .TableNoTracking
|
||||||
|
// .Where(pc => pc.Slug == string.Empty)
|
||||||
|
// .ToListAsync();
|
||||||
|
//if (notSlugBrands.Count > 0)
|
||||||
|
//{
|
||||||
|
// notSlugBrands.ForEach(p =>
|
||||||
|
// {
|
||||||
|
// var slug = StringExtensions.GetSlug(p.PersianName);
|
||||||
|
// p.Slug = slug;
|
||||||
|
// });
|
||||||
|
// _repositoryWrapper.SetRepository<Brand>()
|
||||||
|
// .UpdateRange(notSlugBrands);
|
||||||
|
// await _repositoryWrapper.SaveChangesAsync();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//var noSlugBlogs = await _repositoryWrapper.SetRepository<Blog>()
|
||||||
|
// .TableNoTracking
|
||||||
|
// .Where(pc => pc.Slug == string.Empty)
|
||||||
|
// .ToListAsync();
|
||||||
|
//if (noSlugBlogs.Count > 0)
|
||||||
|
//{
|
||||||
|
// noSlugBlogs.ForEach(p =>
|
||||||
|
// {
|
||||||
|
// var slug = StringExtensions.GetSlug(p.Title);
|
||||||
|
// p.Slug = slug;
|
||||||
|
// });
|
||||||
|
// _repositoryWrapper.SetRepository<Blog>()
|
||||||
|
// .UpdateRange(noSlugBlogs);
|
||||||
|
// await _repositoryWrapper.SaveChangesAsync();
|
||||||
|
//}
|
||||||
|
//var noSlugBogCategories = await _repositoryWrapper.SetRepository<BlogCategory>()
|
||||||
|
// .TableNoTracking
|
||||||
|
// .Where(pc => pc.Slug == string.Empty)
|
||||||
|
// .ToListAsync();
|
||||||
|
//if (noSlugBogCategories.Count > 0)
|
||||||
|
//{
|
||||||
|
// noSlugBogCategories.ForEach(p =>
|
||||||
|
// {
|
||||||
|
// var slug = StringExtensions.GetSlug(p.Name);
|
||||||
|
// p.Slug = slug;
|
||||||
|
// });
|
||||||
|
// _repositoryWrapper.SetRepository<BlogCategory>()
|
||||||
|
// .UpdateRange(noSlugBogCategories);
|
||||||
|
// await _repositoryWrapper.SaveChangesAsync();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,6 +64,7 @@ foreach (var taxonomy in termTaxonomies)
|
||||||
{
|
{
|
||||||
BaseCategoryId = term.term_id.ToInt(),
|
BaseCategoryId = term.term_id.ToInt(),
|
||||||
Description = taxonomy.description,
|
Description = taxonomy.description,
|
||||||
|
Slug = term.slug,
|
||||||
Name = term.name
|
Name = term.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ foreach (var taxonomy in termTaxonomies)
|
||||||
|
|
||||||
}
|
}
|
||||||
var categoriesRest = new Dictionary<int, Guid>();
|
var categoriesRest = new Dictionary<int, Guid>();
|
||||||
//categoriesRest = await RestWrapper.Instance.SeedRestApi.SeedBlogCategoriesAsync(categories, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==");
|
categoriesRest = await RestWrapper.Instance.SeedRestApi.SeedBlogCategoriesAsync(categories, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==");
|
||||||
Console.WriteLine($"{categories.Count} BlogCategory Added Success !");
|
Console.WriteLine($"{categories.Count} BlogCategory Added Success !");
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue