feat : add version 0.23.26.46 , complete slug and db
parent
f880d72d07
commit
0249727d32
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"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",
|
||||
"MartenDB": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopMartenDB;"
|
||||
"Postgres": "Host=pg-0;Username=visabarterAgent;Password=xHTpBf4wC+bPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=HamyanDB;Application Name=HamyanApi",
|
||||
"MartenDB": "Host=pg-0;Username=visabarterAgent;Password=xHTpBf4wC+bPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=HamyanMartenDB;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
@ -17,38 +17,38 @@
|
|||
"TaxesFee": 9
|
||||
},
|
||||
"SiteSettings": {
|
||||
"BaseUrl": "https://api.vesmeh.com",
|
||||
"WebSiteUrl": "https://vesmeh.com",
|
||||
"AdminPanelBaseUrl": "https://admin.vesmeh.com",
|
||||
"StorageBaseUrl": "https://storage.vesmeh.com",
|
||||
"BaseUrl": "https://api.hamyan.visabartar.com",
|
||||
"WebSiteUrl": "https://hamyan.visabartar.com",
|
||||
"AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com",
|
||||
"StorageBaseUrl": "https://storage.visabartar.com",
|
||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
||||
"UserSetting": {
|
||||
"Username": "09214802813",
|
||||
"Email": "avvampier@gmail.com",
|
||||
"Password": "eF79o4P4BopCUbUK",
|
||||
"Password": "2Tsr87RWRn5T",
|
||||
"Phone": "09214802813",
|
||||
"RoleName": "RootAdmin",
|
||||
"FirstName": "همه کاره",
|
||||
"LastName": "سیستم"
|
||||
},
|
||||
"Manager": {
|
||||
"Username": "09128387004",
|
||||
"Email": "mahanmasiha6@gmail.com",
|
||||
"Password": "eF79o4P4BopCUbUK",
|
||||
"Username": "09122171024",
|
||||
"Email": "kamran_mirzayi@gmail.com",
|
||||
"Password": "YAWEheKEi7gh",
|
||||
"Phone": "09128387004",
|
||||
"RoleName": "Manager",
|
||||
"FirstName": "ماهان",
|
||||
"LastName": ""
|
||||
"FirstName": "کامران",
|
||||
"LastName": "میرزایی"
|
||||
},
|
||||
"StorageSetting": {
|
||||
"AccessKey": "979313b7-30fb-40ff-94d8-d0390d3fa876",
|
||||
"SecretKey": "d37a1cc6acfea3a6f92c538ef0f6601f1edcdc9143942b6470e5d1032aa6bfe2",
|
||||
"BucketKey": "vesmeh-content"
|
||||
"AccessKey": "de129835-b43a-4552-8ed4-865e2635ab3d",
|
||||
"SecretKey": "f00197a766336e818023f90408ba3b88b4fdc86d0e7180f74f199d9f03db7575",
|
||||
"BucketKey": "hamyan-content"
|
||||
},
|
||||
"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",
|
||||
"Issuer": "Brizco",
|
||||
"Audience": "Brizco",
|
||||
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_Co0F8AlDfth0PmBuY/0xZQX25iKGQsro5HNkm+gGto4ijSm3hJQ7SViLmR2/BtHN_YA_JADE_NASABE_MSwIOzaxUqn8awSbMx02MSwIOzaxUqn8awSbMx02_EegU4lf9LB5LOyZWXLzLCyXtAp0moUh0_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
||||
"Issuer": "Hamyan",
|
||||
"Audience": "Hamyan",
|
||||
"ExpireAddDay": "15"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
"TaxesFee": 9
|
||||
},
|
||||
"SiteSettings": {
|
||||
"BaseUrl": "http://192.168.1.12:32770",
|
||||
"WebSiteUrl": "https://hamyanedalat.com",
|
||||
"AdminPanelBaseUrl": "https://admin.hamyanedalat.com",
|
||||
"StorageBaseUrl": "https://storage.hamyanedalat.com",
|
||||
"BaseUrl": "https://api.hamyan.visabartar.com",
|
||||
"WebSiteUrl": "https://hamyan.visabartar.com",
|
||||
"AdminPanelBaseUrl": "https://admin.hamyan.visabartar.com",
|
||||
"StorageBaseUrl": "https://storage.visabartar.com",
|
||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
||||
"UserSetting": {
|
||||
"Username": "09214802813",
|
||||
"Email": "avvampier@gmail.com",
|
||||
"Password": "eF79o4P4BopCUbUK",
|
||||
"Password": "2Tsr87RWRn5T",
|
||||
"Phone": "09214802813",
|
||||
"RoleName": "RootAdmin",
|
||||
"FirstName": "همه کاره",
|
||||
|
@ -33,9 +33,9 @@
|
|||
},
|
||||
"Manager": {
|
||||
"Username": "09122171024",
|
||||
"Email": "info@hamyanedalat.com",
|
||||
"Password": "eF79o4P4BopCUbUK",
|
||||
"Phone": "09122171024",
|
||||
"Email": "kamran_mirzayi@gmail.com",
|
||||
"Password": "YAWEheKEi7gh",
|
||||
"Phone": "09128387004",
|
||||
"RoleName": "Manager",
|
||||
"FirstName": "کامران",
|
||||
"LastName": "میرزایی"
|
||||
|
@ -46,9 +46,9 @@
|
|||
"BucketKey": "hamyan-content"
|
||||
},
|
||||
"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",
|
||||
"Issuer": "HamaynEdalat",
|
||||
"Audience": "HamaynEdalat",
|
||||
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_Co0F8AlDfth0PmBuY/0xZQX25iKGQsro5HNkm+gGto4ijSm3hJQ7SViLmR2/BtHN_YA_JADE_NASABE_MSwIOzaxUqn8awSbMx02MSwIOzaxUqn8awSbMx02_EegU4lf9LB5LOyZWXLzLCyXtAp0moUh0_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
|
||||
"Issuer": "Hamyan",
|
||||
"Audience": "Hamyan",
|
||||
"ExpireAddDay": "15"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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",
|
||||
"MartenDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB;"
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ public class SeedController : ICarterModule
|
|||
.WithDisplayName("SeedBlogsAsync")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("blog/categories", SeedBlogCategoriesAsync)
|
||||
group.MapPost("blog/categories", SeedBlogCategoriesSlugAsync)
|
||||
.WithDisplayName("SeedBlogCategoriesAsync")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
@ -141,12 +141,34 @@ public class SeedController : ICarterModule
|
|||
categories.Add(0, baseCategory.Id);
|
||||
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);
|
||||
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ builder.Host.UseSerilog();
|
|||
LoggerConfig.ConfigureSerilog();
|
||||
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
|
||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
string projectName = "Hamyan";
|
||||
string projectName = "Vesmeh";
|
||||
if (builder.Environment.IsDevelopment())
|
||||
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 string GetSlug(string title)
|
||||
{
|
||||
return HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
||||
}
|
||||
public static string ToPriceWhitPriceType(this long price, string priceType)
|
||||
{
|
||||
return price.ToString("N0") + " " + priceType;
|
||||
|
|
|
@ -17,5 +17,6 @@ public class SeedBlogCategoryRequestDto
|
|||
{
|
||||
public int BaseCategoryId { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Slug { 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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
var slug = HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
||||
var slug = StringExtensions.GetSlug(title);
|
||||
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())
|
||||
slug = HttpUtility.UrlEncode(title.Replace(' ', '-'));
|
||||
if (slug.IsNullOrEmpty())
|
||||
slug = StringExtensions.GetSlug(title);
|
||||
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)
|
||||
|
@ -35,8 +34,15 @@ public partial class BlogStorageFile
|
|||
|
||||
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;
|
||||
Slug = slug;
|
||||
Description = description;
|
||||
}
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
Slug = slug;
|
||||
EnglishName = englishName;
|
||||
Description = description;
|
||||
HasSpecialPage = hasSpecialPage;
|
||||
|
@ -22,6 +23,7 @@ public partial class Brand : ApiEntity
|
|||
}
|
||||
public string PersianName { 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 bool HasSpecialPage { get; internal set; }
|
||||
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 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)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
namespace Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
[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)]
|
||||
|
@ -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;
|
||||
Slug = slug;
|
||||
Description = description;
|
||||
IsMain = isMain;
|
||||
}
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
public bool IsMain { get; set; }
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Web;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Netina.Domain.Entities.Products;
|
||||
|
||||
|
@ -14,7 +15,7 @@ public partial class Product
|
|||
Guid brandId,
|
||||
Guid categoryId)
|
||||
{
|
||||
var slug = HttpUtility.UrlEncode(persianName.Replace(' ', '-'));
|
||||
var slug = StringExtensions.GetSlug(persianName);
|
||||
return new Product(
|
||||
persianName,
|
||||
englishName,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.ScraperDtos.Response;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
|
@ -94,7 +95,8 @@ public class DigikalaScraper : IDigikalaScraper
|
|||
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,
|
||||
newSummery,
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Dtos.SmallDtos;
|
||||
using Netina.Domain.Entities.Brands;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
using Netina.Domain.Entities.Brands;
|
||||
|
||||
namespace Netina.Repository.Handlers.Brands;
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Netina.Common.Models.Exception;
|
||||
using Netina.Domain.CommandQueries.Commands;
|
||||
using Netina.Domain.Entities.Brands;
|
||||
using Netina.Repository.Repositories.Base.Contracts;
|
||||
|
||||
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
|
||||
modelBuilder
|
||||
.HasDefaultSchema("public")
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
@ -304,6 +304,10 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("BlogCategories", "public");
|
||||
|
@ -358,6 +362,10 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Brands", "public");
|
||||
|
@ -756,6 +764,10 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Web;
|
||||
using Netina.Domain.Entities.Blogs;
|
||||
using Netina.Domain.Entities.Brands;
|
||||
|
||||
namespace Netina.Repository.Services;
|
||||
|
||||
|
@ -186,21 +188,86 @@ public class DbInitializerService : IDbInitializerService
|
|||
|
||||
public async Task Refactor()
|
||||
{
|
||||
var noSlugProducts = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.Where(p => p.Slug==string.Empty)
|
||||
.ToListAsync();
|
||||
//var noSlugProducts = await _repositoryWrapper.SetRepository<Product>()
|
||||
// .TableNoTracking
|
||||
// .Where(p => p.Slug==string.Empty)
|
||||
// .ToListAsync();
|
||||
|
||||
if (noSlugProducts.Count > 0)
|
||||
{
|
||||
noSlugProducts.ForEach(p =>
|
||||
{
|
||||
var slug = HttpUtility.UrlEncode(p.PersianName.Replace(' ', '-'));
|
||||
p.Slug = slug;
|
||||
});
|
||||
_repositoryWrapper.SetRepository<Product>()
|
||||
.UpdateRange(noSlugProducts);
|
||||
await _repositoryWrapper.SaveChangesAsync();
|
||||
}
|
||||
//if (noSlugProducts.Count > 0)
|
||||
//{
|
||||
// noSlugProducts.ForEach(p =>
|
||||
// {
|
||||
// var slug = StringExtensions.GetSlug(p.PersianName);
|
||||
// p.Slug = slug;
|
||||
// });
|
||||
// _repositoryWrapper.SetRepository<Product>()
|
||||
// .UpdateRange(noSlugProducts);
|
||||
// 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(),
|
||||
Description = taxonomy.description,
|
||||
Slug = term.slug,
|
||||
Name = term.name
|
||||
});
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ foreach (var taxonomy in termTaxonomies)
|
|||
|
||||
}
|
||||
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 !");
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue