edit products and ordering

release
Amir Hossein Khademi 2024-02-08 18:56:56 +03:30
parent 5355d416bf
commit 70e667468d
27 changed files with 7824 additions and 210 deletions

View File

@ -32,8 +32,8 @@ public class ProductController : ICarterModule
}
// GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery]string? productName, [FromQuery] QuerySortBy? sortBy,[FromQuery] Guid? categoryId , [FromQuery] Guid[]? brandIds , [FromQuery]double? minPrice , [FromQuery] double? maxPrice, [FromQuery]bool? isActive, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetProductsQuery(Page: page,SortBy: sortBy ?? 0 ,ProductName: productName, CategoryId: categoryId ?? default , BrandIds: brandIds , MinPrice: minPrice ?? -1 , MaxPrice:maxPrice ?? 0,IsActive:isActive),cancellationToken));
public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery]string? productName, [FromQuery] QuerySortBy? sortBy, [FromQuery] Guid? categoryId, [FromQuery] bool? specialOffer, [FromQuery] Guid[]? brandIds , [FromQuery]double? minPrice , [FromQuery] double? maxPrice, [FromQuery]bool? isActive, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetProductsQuery(Page: page, SpecialOffer: specialOffer, SortBy: sortBy ?? 0 ,ProductName: productName, CategoryId: categoryId ?? default , BrandIds: brandIds , MinPrice: minPrice ?? -1 , MaxPrice:maxPrice ?? 0,IsActive:isActive),cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IMediator mediator,CancellationToken cancellationToken)

View File

@ -47,7 +47,7 @@ public class RoleController : ICarterModule
// PUT:Update Entity
public async Task<IResult> Put([FromBody] RoleActionRequestDto request, IUserService userService, CancellationToken cancellationToken)
=> TypedResults.Ok(await userService.CreateRoleAsync(request, cancellationToken));
=> TypedResults.Ok(await userService.EditRoleAsync(request, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IUserService userService, CancellationToken cancellationToken)

View File

@ -73,6 +73,11 @@ builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
.WithAllOpenGenericHandlerTypesRegistered()
.Build());
builder.RegisterMediatR(MediatRConfigurationBuilder
.Create(typeof(CoreConfig).Assembly)
.WithAllOpenGenericHandlerTypesRegistered()
.Build());
builder.RegisterMediatR(MediatRConfigurationBuilder
.Create(typeof(DomainConfig).Assembly)
.WithAllOpenGenericHandlerTypesRegistered()

View File

@ -1,4 +1,5 @@
using NetinaShop.Repository.Abstracts;
using System.Security.Cryptography;
using NetinaShop.Repository.Abstracts;
namespace NetinaShop.Api.Services;
@ -14,5 +15,36 @@ public class CurrentUserService : ICurrentUserService
public string? UserId => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier);
public string? RoleName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role);
public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name);
public string? DeviceId => GetDeviceId(_httpContextAccessor.HttpContext);
public bool IsAuthorized => GetAuthorized();
public List<string>? Permissions => _httpContextAccessor.HttpContext?.User?.FindAll("Permission")?.Select(c => c.Value)?.ToList();
private string? GetDeviceId(HttpContext? context)
{
if (context?.Request?.Headers == null)
return null;
string? userAgent = context.Request.Headers["User-Agent"];
string? ipAddress = context.Connection.RemoteIpAddress?.ToString();
string? origin = context.Request.Headers["Origin"];
string input = userAgent + "_" + ipAddress;
using SHA256 sha256Hash = SHA256.Create();
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
var uniqueId = builder.ToString();
return uniqueId;
}
private bool GetAuthorized()
{
if (_httpContextAccessor.HttpContext?.User.Identity == null)
return false;
return _httpContextAccessor.HttpContext.User.Identity.IsAuthenticated;
}
}

View File

@ -13,7 +13,7 @@ public static class LoggerConfig
o.MinimumEventLevel = LogEventLevel.Error;
o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7";
})
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.CreateLogger();
}
}

View File

@ -1,4 +1,7 @@
namespace NetinaShop.Api.WebFramework.MiddleWares;
using System.Security.Cryptography;
using NetinaShop.Repository.Migrations;
namespace NetinaShop.Api.WebFramework.MiddleWares;
public static class ExceptionHandlerMiddlewareExtensions
{

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -12,9 +12,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
</ItemGroup>-->
</ItemGroup>
<PropertyGroup>
<!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
@ -25,7 +25,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
</ItemGroup>
</ItemGroup>-->
<ItemGroup>
<Using Include="MD.PersianDateTime.Standard" />

View File

@ -1,4 +1,5 @@
using StackExchange.Redis;
using System.Security.Claims;
namespace NetinaShop.Core.EntityServices;
@ -60,12 +61,13 @@ public class UserService : IUserService
if (phoneNumber == null || phoneNumber.IsNullOrEmpty())
users = await _userManager.Users
.Where(u=>u.UserName!= "09214802813")
.Skip(page * 15).Take(15)
.Select(ApplicationUserMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
else
users = await _userManager.Users
.Where(a => a.PhoneNumber == phoneNumber)
.Where(a => a.PhoneNumber == phoneNumber && a.UserName!= "09214802813")
.Skip(page * 15).Take(15)
.Select(ApplicationUserMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
@ -249,6 +251,7 @@ public class UserService : IUserService
public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default)
{
var roles = await _roleManager.Roles
.Where(r=>r.Name != "RootAdmin")
.Skip(page * 15)
.Take(15)
.ToListAsync(cancellationToken);
@ -310,11 +313,12 @@ public class UserService : IUserService
var roleClaims = (await _roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList();
foreach (var roleClaim in roleClaims.ToList())
{
if (request.Permissions.Contains(roleClaim.Value))
{
roleClaims.Remove(roleClaim);
request.Permissions.Remove(roleClaim.Value);
}
await _roleManager.RemoveClaimAsync(applicationRole,roleClaim);
//if (request.Permissions.Contains(roleClaim.Value))
//{
// roleClaims.Remove(roleClaim);
// request.Permissions.Remove(roleClaim.Value);
//}
}
foreach (var claim in request.Permissions)

View File

@ -5,6 +5,7 @@ public sealed record GetProductQuery(Guid Id) : IRequest<ProductLDto>;
public sealed record GetProductsQuery(
Guid[]? BrandIds,
bool? IsActive,
bool? SpecialOffer,
int Page = 0 ,
string? ProductName = default,
QuerySortBy SortBy = QuerySortBy.None ,

View File

@ -1,8 +1,10 @@
using NetinaShop.Domain.Entities.ProductCategories;
using System.ComponentModel.DataAnnotations.Schema;
using NetinaShop.Domain.Entities.ProductCategories;
namespace NetinaShop.Domain.Entities.Products;
[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 | MapType.Projection)]
[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)]
[GenerateMapper]
public partial class Product : ApiEntity
@ -56,11 +58,10 @@ public partial class Product : ApiEntity
public bool HasExpressDelivery { get; internal set; }
public int MaxOrderCount { get; internal set; }
public Guid? BrandId { get; internal set; }
public Guid BrandId { get; internal set; }
public Brand? Brand { get; internal set; }
public Guid? CategoryId { get; internal set; }
public Guid CategoryId { get; internal set; }
public ProductCategory? Category { get; internal set; }
public List<Specification> Specifications { get; internal set; } = new();

View File

@ -66,7 +66,7 @@ namespace NetinaShop.Domain.Mappers
return result;
}
public static Expression<Func<ProductLDto, Product>> ProjectLDtoToProduct => p13 => new Product()
public static Expression<Func<ProductLDto, Product>> ProjectToProduct => p13 => new Product()
{
PersianName = p13.PersianName,
EnglishName = p13.EnglishName,
@ -289,112 +289,103 @@ namespace NetinaShop.Domain.Mappers
return result;
}
public static Expression<Func<ProductSDto, Product>> ProjectToProduct => p40 => new Product()
public static ProductSDto AdaptToSDto(this Product p40)
{
PersianName = p40.PersianName,
EnglishName = p40.EnglishName,
Summery = p40.Summery,
ExpertCheck = p40.ExpertCheck,
Tags = p40.Tags,
Warranty = p40.Warranty,
Cost = p40.Cost,
IsEnable = p40.IsEnable,
BeDisplayed = p40.BeDisplayed,
PackingCost = p40.PackingCost,
Rate = p40.Rate,
ReviewCount = p40.ReviewCount,
Viewed = p40.Viewed,
BrandId = p40.BrandId,
Brand = new Brand()
{
Name = p40.BrandName,
Id = p40.BrandId
},
CategoryId = p40.CategoryId,
Category = new ProductCategory()
{
Name = p40.CategoryName,
Id = p40.CategoryId
},
Id = p40.Id,
CreatedAt = p40.CreatedAt
};
public static ProductSDto AdaptToSDto(this Product p41)
{
return p41 == null ? null : new ProductSDto()
{
PersianName = p41.PersianName,
EnglishName = p41.EnglishName,
Summery = p41.Summery,
ExpertCheck = p41.ExpertCheck,
Tags = p41.Tags,
Warranty = p41.Warranty,
Cost = p41.Cost,
IsEnable = p41.IsEnable,
BeDisplayed = p41.BeDisplayed,
PackingCost = p41.PackingCost,
Rate = p41.Rate,
ReviewCount = p41.ReviewCount,
Viewed = p41.Viewed,
CategoryId = p41.CategoryId,
BrandId = p41.BrandId,
BrandName = p41.Brand != null ? p41.Brand.Name : string.Empty,
CategoryName = p41.Category != null ? p41.Category.Name : string.Empty,
Id = p41.Id,
CreatedAt = p41.CreatedAt
};
}
public static ProductSDto AdaptTo(this Product p42, ProductSDto p43)
{
if (p42 == null)
if (p40 == null)
{
return null;
}
ProductSDto result = p43 ?? new ProductSDto();
ProductSDto result = new ProductSDto();
result.PersianName = p42.PersianName;
result.EnglishName = p42.EnglishName;
result.Summery = p42.Summery;
result.ExpertCheck = p42.ExpertCheck;
result.Tags = p42.Tags;
result.Warranty = p42.Warranty;
result.Cost = p42.Cost;
result.IsEnable = p42.IsEnable;
result.BeDisplayed = p42.BeDisplayed;
result.PackingCost = p42.PackingCost;
result.Rate = p42.Rate;
result.ReviewCount = p42.ReviewCount;
result.Viewed = p42.Viewed;
result.CategoryId = p42.CategoryId;
result.BrandId = p42.BrandId;
result.BrandName = p42.Brand != null ? p42.Brand.Name : string.Empty;
result.CategoryName = p42.Category != null ? p42.Category.Name : string.Empty;
result.Id = p42.Id;
result.CreatedAt = p42.CreatedAt;
result.PersianName = p40.PersianName;
result.EnglishName = p40.EnglishName;
result.Summery = p40.Summery;
result.ExpertCheck = p40.ExpertCheck;
result.Tags = p40.Tags;
result.Warranty = p40.Warranty;
result.Cost = p40.Cost;
result.IsEnable = p40.IsEnable;
result.BeDisplayed = p40.BeDisplayed;
result.PackingCost = p40.PackingCost;
result.Rate = p40.Rate;
result.ReviewCount = p40.ReviewCount;
result.Viewed = p40.Viewed;
result.CategoryId = p40.CategoryId;
result.BrandId = p40.BrandId;
result.Id = p40.Id;
result.CreatedAt = p40.CreatedAt;
if (!(p40.Brand == null))
{
result.BrandName = p40.Brand == null ? null : p40.Brand.Name;
}
if (!(p40.Category == null))
{
result.CategoryName = p40.Category == null ? null : p40.Category.Name;
}
return result;
}
public static Expression<Func<Product, ProductSDto>> ProjectToSDto => p44 => new ProductSDto()
public static ProductSDto AdaptTo(this Product p41, ProductSDto p42)
{
PersianName = p44.PersianName,
EnglishName = p44.EnglishName,
Summery = p44.Summery,
ExpertCheck = p44.ExpertCheck,
Tags = p44.Tags,
Warranty = p44.Warranty,
Cost = p44.Cost,
IsEnable = p44.IsEnable,
BeDisplayed = p44.BeDisplayed,
PackingCost = p44.PackingCost,
Rate = p44.Rate,
ReviewCount = p44.ReviewCount,
Viewed = p44.Viewed,
CategoryId = p44.CategoryId,
BrandId = p44.BrandId,
BrandName = p44.Brand != null ? p44.Brand.Name : string.Empty,
CategoryName = p44.Category != null ? p44.Category.Name : string.Empty,
Id = p44.Id,
CreatedAt = p44.CreatedAt
if (p41 == null)
{
return null;
}
ProductSDto result = p42 ?? new ProductSDto();
result.PersianName = p41.PersianName;
result.EnglishName = p41.EnglishName;
result.Summery = p41.Summery;
result.ExpertCheck = p41.ExpertCheck;
result.Tags = p41.Tags;
result.Warranty = p41.Warranty;
result.Cost = p41.Cost;
result.IsEnable = p41.IsEnable;
result.BeDisplayed = p41.BeDisplayed;
result.PackingCost = p41.PackingCost;
result.Rate = p41.Rate;
result.ReviewCount = p41.ReviewCount;
result.Viewed = p41.Viewed;
result.CategoryId = p41.CategoryId;
result.BrandId = p41.BrandId;
result.Id = p41.Id;
result.CreatedAt = p41.CreatedAt;
if (!(p41.Brand == null))
{
result.BrandName = p41.Brand == null ? null : p41.Brand.Name;
}
if (!(p41.Category == null))
{
result.CategoryName = p41.Category == null ? null : p41.Category.Name;
}
return result;
}
public static Expression<Func<Product, ProductSDto>> ProjectToSDto => p43 => new ProductSDto()
{
PersianName = p43.PersianName,
EnglishName = p43.EnglishName,
Summery = p43.Summery,
ExpertCheck = p43.ExpertCheck,
Tags = p43.Tags,
Warranty = p43.Warranty,
Cost = p43.Cost,
IsEnable = p43.IsEnable,
BeDisplayed = p43.BeDisplayed,
PackingCost = p43.PackingCost,
Rate = p43.Rate,
ReviewCount = p43.ReviewCount,
Viewed = p43.Viewed,
CategoryId = p43.CategoryId,
BrandId = p43.BrandId,
BrandName = p43.Brand == null ? null : p43.Brand.Name,
CategoryName = p43.Category == null ? null : p43.Category.Name,
Id = p43.Id,
CreatedAt = p43.CreatedAt
};
private static List<Specification> funcMain1(List<SpecificationSDto> p2)

View File

@ -17,8 +17,8 @@ public class MapsterRegister : IRegister
.TwoWays();
config.NewConfig<Product, ProductSDto>()
.Map("CategoryName", o => o.Category != null ? o.Category.Name : string.Empty)
.Map("BrandName", o => o.Brand != null ? o.Brand.Name : string.Empty)
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
.Map("BrandName", o => o.Brand == null ? null : o.Brand.Name)
.IgnoreNullValues(false)
.TwoWays();

View File

@ -7,146 +7,173 @@ public static class ApplicationClaims
public static ClaimDto ManageBlogs { get; } = new ClaimDto
{
Title = "مدیریت بلاگ ها",
Type = CustomClaimType.Permission,
Value = ApplicationPermission.ManageBlogs,
};
public static ClaimDto ViewBlogs { get; } = new ClaimDto
{
Title = "مشاهده بلاگ ها",
Type = CustomClaimType.Permission,
Value = ApplicationPermission.ViewBlogs,
};
public static ClaimDto ManageBrands { get; } = new ClaimDto
{
Title = "مدیریت برند ها",
Type = CustomClaimType.Permission,
Value = ApplicationPermission.ManageBrands,
};
public static ClaimDto ViewBrands { get; } = new ClaimDto
{
Title = "مشاهده برند ها",
Type = CustomClaimType.Permission,
Value = ApplicationPermission.ViewBrands,
};
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,
};

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -14,9 +14,9 @@
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>-->
</ItemGroup>
<PropertyGroup>
<!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
@ -32,7 +32,7 @@
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>
</ItemGroup>-->
<ItemGroup>

View File

@ -5,5 +5,7 @@ public interface ICurrentUserService : IScopedDependency
string? UserId { get; }
string? RoleName { get; }
string? UserName { get; }
string? DeviceId { get; }
bool IsAuthorized { get; }
public List<string>? Permissions { get; }
}

View File

@ -79,7 +79,10 @@ public static class ModelBuilderExtensions
.SelectMany(t => t.GetForeignKeys())
.Where(fk => !fk.IsOwnership && fk.DeleteBehavior == DeleteBehavior.Cascade);
foreach (var fk in cascadeFKs)
{
fk.DeleteBehavior = DeleteBehavior.Restrict;
fk.IsRequired = false;
}
}
/// <summary>
@ -97,13 +100,13 @@ public static class ModelBuilderExtensions
.Where(c => c.IsClass && !c.IsAbstract && c.IsPublic);
foreach (var type in types)
foreach (var iface in type.GetInterfaces())
if (iface.IsConstructedGenericType &&
iface.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))
{
var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(iface.GenericTypeArguments[0]);
applyConcreteMethod.Invoke(modelBuilder, new[] { Activator.CreateInstance(type) });
}
foreach (var iface in type.GetInterfaces())
if (iface.IsConstructedGenericType &&
iface.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))
{
var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(iface.GenericTypeArguments[0]);
applyConcreteMethod.Invoke(modelBuilder, new[] { Activator.CreateInstance(type) });
}
}
@ -137,11 +140,8 @@ public static class ModelBuilderExtensions
var builderQueryFilter = new ModelBuilderQueryFilter();
foreach (var type in types)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
modelBuilder.Entity(type);
builderQueryFilter.AddQueryFilterToModelBuilder(modelBuilder, type);
stopwatch.Stop();
}
}
@ -166,7 +166,7 @@ public static class ModelBuilderExtensions
var onModelCreatingMethod =
type.GetMethods().FirstOrDefault(x => x.Name == "OnModelCreating");
if (onModelCreatingMethod != null)
if (onModelCreatingMethod != null)
onModelCreatingMethod.Invoke(type, new object[] { builder });
else
{
@ -176,7 +176,7 @@ public static class ModelBuilderExtensions
var baseOnModelCreatingMethod = type.BaseType.GetMethods()
.FirstOrDefault(x => x.Name == "OnModelCreating");
if (baseOnModelCreatingMethod == null)
if (baseOnModelCreatingMethod == null)
continue;
baseOnModelCreatingMethod.Invoke(typeof(BaseType), new object[] { builder });

View File

@ -18,7 +18,7 @@ public class GetBrandsQueryHandler : IRequestHandler<GetBrandsQuery, List<BrandS
List<BrandSDto> brands = new List<BrandSDto>();
if (request.CategoryId != default)
{
var products = await _mediator.Send(new GetProductsQuery(BrandIds: null, Page:0, SortBy: QuerySortBy.None,CategoryId: request.CategoryId, IsActive : null),
var products = await _mediator.Send(new GetProductsQuery(BrandIds: null,SpecialOffer: null, Page:0, SortBy: QuerySortBy.None,CategoryId: request.CategoryId, IsActive : null),
cancellationToken);
var brandGrouped = products.GroupBy(p => p.BrandId);
foreach (var grouping in brandGrouped)

View File

@ -1,11 +1,14 @@
namespace NetinaShop.Repository.Handlers.Products;
using Microsoft.EntityFrameworkCore.Internal;
using NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Repository.Handlers.Products;
public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<ProductSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly IMediator _mediator;
public GetProductsQueryHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator)
public GetProductsQueryHandler(IRepositoryWrapper repositoryWrapper, IMediator mediator)
{
_repositoryWrapper = repositoryWrapper;
_mediator = mediator;
@ -14,7 +17,7 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<Pr
{
var products = _repositoryWrapper.SetRepository<Product>().TableNoTracking;
if (request.IsActive != null)
products = products.Where(p => p.IsEnable == request.IsActive );
products = products.Where(p => p.IsEnable == request.IsActive);
if (request.ProductName != null)
products = products.Where(p => p.PersianName.ToLower().Trim().Contains(request.ProductName.ToLower().Trim()));
if (request.CategoryId != default)
@ -44,32 +47,33 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<Pr
products = products.OrderByDescending(p => p.CreatedAt);
}
if (request.SpecialOffer != null)
{
if (request.SpecialOffer.Value)
{
var productDiscount = await _repositoryWrapper.SetRepository<ProductDiscount>()
.TableNoTracking
.Where(d => d.HasCode == false && d.IsSpecialOffer && d.ExpireDate.Date >= DateTime.Today.Date)
.OrderByDescending(d => d.CreatedAt)
.Select(d => d.ProductId)
.ToListAsync(cancellationToken);
products = products.Where(p => productDiscount.Contains(p.Id));
}
}
List<ProductSDto> productSDtos = await products
.Skip(request.Page * 20)
.Take(20)
.Select(ProductMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
var ptps = await products
.Skip(request.Page * 20)
.Take(20)
.ToListAsync(cancellationToken);
foreach (var product in ptps)
{
if(productSDtos.FirstOrDefault(f=>f.Id==product.Id)==null)
{
}
}
foreach (var productSDto in productSDtos)
{
double discountPrice = 0;
productSDto.CostWithDiscount = productSDto.Cost;
var categoryDiscount = await _repositoryWrapper.SetRepository<CategoryDiscount>()
.TableNoTracking
.FirstOrDefaultAsync(d => d.CategoryId == productSDto.CategoryId && d.HasCode == false && d.ExpireDate.Date > DateTime.Today.Date, cancellationToken);
.FirstOrDefaultAsync(d => d.CategoryId == productSDto.CategoryId && d.HasCode == false && d.ExpireDate.Date >= DateTime.Today.Date, cancellationToken);
if (categoryDiscount != null && !categoryDiscount.IsExpired())
{
@ -83,7 +87,7 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<Pr
var productDiscount = await _repositoryWrapper.SetRepository<ProductDiscount>()
.TableNoTracking
.Where(d => d.HasCode == false && d.ProductId == productSDto.Id && d.ExpireDate.Date > DateTime.Today.Date)
.Where(d => d.HasCode == false && d.ProductId == productSDto.Id && d.ExpireDate.Date >= DateTime.Today.Date)
.OrderByDescending(d => d.CreatedAt)
.FirstOrDefaultAsync(cancellationToken);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,918 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class EditForeigenKeies : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "UserFavoriteProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "UserAddresses",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "StorageFiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Specifications",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Shippings",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Reviews",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "ProductCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Orders",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "OrderProducts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "OrderDeliveries",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Discounts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Brands",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "Blogs",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "RemovedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "ModifiedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "public",
table: "BlogCategories",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class EditOrderAddDeviceId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DeviceId",
schema: "public",
table: "Orders",
type: "text",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DeviceId",
schema: "public",
table: "Orders");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,68 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class EditOrderNullUserId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders");
migrationBuilder.AlterColumn<Guid>(
name: "UserId",
schema: "public",
table: "Orders",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders",
column: "UserId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders");
migrationBuilder.AlterColumn<Guid>(
name: "UserId",
schema: "public",
table: "Orders",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders",
column: "UserId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class EditOrderUserId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders");
migrationBuilder.DropColumn(
name: "DeviceId",
schema: "public",
table: "Orders");
migrationBuilder.AlterColumn<Guid>(
name: "UserId",
schema: "public",
table: "Orders",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders",
column: "UserId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders");
migrationBuilder.AlterColumn<Guid>(
name: "UserId",
schema: "public",
table: "Orders",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn<string>(
name: "DeviceId",
schema: "public",
table: "Orders",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Users_UserId",
schema: "public",
table: "Orders",
column: "UserId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id");
}
}
}

View File

@ -18,7 +18,7 @@ namespace NetinaShop.Repository.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("public")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -143,6 +143,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -155,6 +156,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ReadingTime")
@ -164,6 +166,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summery")
@ -195,6 +198,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -208,6 +212,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -218,6 +223,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -235,6 +241,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -251,6 +258,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -265,6 +273,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -292,6 +301,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("DiscountAmount")
@ -333,6 +343,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("PriceCeiling")
@ -345,6 +356,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
@ -375,6 +387,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DeliveryPrice")
@ -403,6 +416,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("OrderAt")
@ -427,6 +441,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("ServicePrice")
@ -467,6 +482,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DeliveryCost")
@ -479,6 +495,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -500,6 +517,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShippingId")
@ -527,6 +545,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -536,6 +555,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -566,6 +586,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -587,6 +608,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -603,6 +625,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -616,6 +639,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -647,6 +671,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
@ -673,6 +698,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PackingCost")
@ -689,6 +715,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ReviewCount")
@ -732,6 +759,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsBuyer")
@ -747,6 +775,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -759,6 +788,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
@ -787,6 +817,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
@ -803,6 +834,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("ParentId")
@ -815,6 +847,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
@ -844,6 +877,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Discriminator")
@ -875,6 +909,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -885,6 +920,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -1035,6 +1071,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1050,6 +1087,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PostalCode")
@ -1068,6 +1106,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1090,6 +1129,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1099,6 +1139,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -1108,6 +1149,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1132,6 +1174,7 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DeliveryCost")
@ -1153,12 +1196,14 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
@ -1251,8 +1296,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
@ -1260,8 +1304,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
@ -1269,8 +1312,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
@ -1278,14 +1320,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
@ -1293,8 +1333,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b =>
@ -1302,8 +1341,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category")
.WithMany("Blogs")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Category");
});
@ -1317,8 +1355,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("User");
});
@ -1328,14 +1365,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
.WithMany("OrderDeliveries")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
.WithMany()
.HasForeignKey("ShippingId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Order");
@ -1347,14 +1382,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
.WithMany("OrderProducts")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("OrderProducts")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Order");
@ -1375,14 +1408,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand")
.WithMany("Products")
.HasForeignKey("BrandId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category")
.WithMany("Products")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Brand");
@ -1394,14 +1425,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("Reviews")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
@ -1417,8 +1446,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("Specifications")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
@ -1430,8 +1458,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany("Addresses")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("User");
});
@ -1441,14 +1468,12 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
@ -1460,8 +1485,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Category");
});
@ -1471,8 +1495,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
});
@ -1482,8 +1505,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog")
.WithMany("Files")
.HasForeignKey("BlogId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Blog");
});
@ -1493,8 +1515,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand")
.WithMany("Files")
.HasForeignKey("BrandId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Brand");
});
@ -1504,8 +1525,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category")
.WithMany("Files")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Category");
});
@ -1515,8 +1535,7 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("Files")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
});