Full creation -> payment flow
This commit is contained in:
38
src/Imprink.Application/Commands/Orders/GetMyOrders.cs
Normal file
38
src/Imprink.Application/Commands/Orders/GetMyOrders.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using AutoMapper;
|
||||
using Imprink.Application.Dtos;
|
||||
using Imprink.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Imprink.Application.Commands.Orders;
|
||||
|
||||
public class GetOrdersByUserIdQuery : IRequest<IEnumerable<OrderDto>>
|
||||
{
|
||||
public string UserId { get; set; } = null!;
|
||||
public bool IncludeDetails { get; set; }
|
||||
}
|
||||
|
||||
public class GetOrdersByUserId(
|
||||
IUnitOfWork uw,
|
||||
IMapper mapper)
|
||||
: IRequestHandler<GetOrdersByUserIdQuery, IEnumerable<OrderDto>>
|
||||
{
|
||||
public async Task<IEnumerable<OrderDto>> Handle(
|
||||
GetOrdersByUserIdQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<Order> orders;
|
||||
|
||||
if (request.IncludeDetails)
|
||||
{
|
||||
orders = await uw.OrderRepository
|
||||
.GetByUserIdWithDetailsAsync(request.UserId, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
orders = await uw.OrderRepository
|
||||
.GetByUserIdAsync(request.UserId, cancellationToken);
|
||||
}
|
||||
|
||||
return mapper.Map<IEnumerable<OrderDto>>(orders);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Application.Commands.Orders;
|
||||
|
||||
public class SetOrderStatus
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Application.Commands.Orders;
|
||||
|
||||
public class SetOrderShippingStatus
|
||||
{
|
||||
|
||||
}
|
||||
6
src/Imprink.Application/Dtos/EnumValueDto.cs
Normal file
6
src/Imprink.Application/Dtos/EnumValueDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Application.Dtos;
|
||||
|
||||
public class EnumValueDto
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Imprink.Application.Dtos;
|
||||
using Imprink.Domain.Entities;
|
||||
|
||||
namespace Imprink.Application.Mappings;
|
||||
|
||||
public class OrderStatusMappingProfile : Profile
|
||||
{
|
||||
public OrderStatusMappingProfile()
|
||||
{
|
||||
CreateMap<OrderStatus, OrderStatusDto>();
|
||||
|
||||
CreateMap<OrderStatusDto, OrderStatus>();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Imprink.Application.Dtos;
|
||||
using Imprink.Domain.Entities;
|
||||
|
||||
namespace Imprink.Application.Mappings;
|
||||
|
||||
public class ShippingStatusMappingProfile : Profile
|
||||
{
|
||||
public ShippingStatusMappingProfile()
|
||||
{
|
||||
CreateMap<ShippingStatus, ShippingStatusDto>();
|
||||
|
||||
CreateMap<ShippingStatusDto, ShippingStatus>();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Imprink.Domain.Entities;
|
||||
|
||||
public class OrderStatus
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Imprink.Domain.Entities;
|
||||
|
||||
public class ShippingStatus
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||
}
|
||||
6
src/Imprink.Domain/Enums/OrderStatusEnum.cs
Normal file
6
src/Imprink.Domain/Enums/OrderStatusEnum.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Domain.Enums;
|
||||
|
||||
public enum OrderStatusEnum
|
||||
{
|
||||
|
||||
}
|
||||
6
src/Imprink.Domain/Enums/ShippingStatusEnum.cs
Normal file
6
src/Imprink.Domain/Enums/ShippingStatusEnum.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Domain.Enums;
|
||||
|
||||
public enum ShippingStatusEnum
|
||||
{
|
||||
|
||||
}
|
||||
6
src/Imprink.Domain/Extensions/StatusExtensions.cs
Normal file
6
src/Imprink.Domain/Extensions/StatusExtensions.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Imprink.Domain.Extensions;
|
||||
|
||||
public class StatusExtensions
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using Imprink.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration;
|
||||
|
||||
public class OrderStatusConfiguration : IEntityTypeConfiguration<OrderStatus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<OrderStatus> builder)
|
||||
{
|
||||
builder.HasKey(os => os.Id);
|
||||
|
||||
builder.Property(os => os.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.Property(os => os.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
builder.HasIndex(os => os.Name)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_OrderStatus_Name");
|
||||
|
||||
builder.HasData(
|
||||
new OrderStatus { Id = 0, Name = "Pending" },
|
||||
new OrderStatus { Id = 1, Name = "Processing" },
|
||||
new OrderStatus { Id = 2, Name = "Completed" },
|
||||
new OrderStatus { Id = 3, Name = "Cancelled" }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using Imprink.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration;
|
||||
|
||||
public class ShippingStatusConfiguration : IEntityTypeConfiguration<ShippingStatus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ShippingStatus> builder)
|
||||
{
|
||||
builder.HasKey(ss => ss.Id);
|
||||
|
||||
builder.Property(ss => ss.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.Property(ss => ss.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
builder.HasIndex(ss => ss.Name)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_ShippingStatus_Name");
|
||||
|
||||
builder.HasData(
|
||||
new ShippingStatus { Id = 0, Name = "Prepping" },
|
||||
new ShippingStatus { Id = 1, Name = "Packaging" },
|
||||
new ShippingStatus { Id = 2, Name = "Shipped" },
|
||||
new ShippingStatus { Id = 3, Name = "Delivered" }
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,676 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace Imprink.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialSetup : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false),
|
||||
ImageUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
SortOrder = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
|
||||
ParentCategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Categories_Categories_ParentCategoryId",
|
||||
column: x => x.ParentCategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderStatuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderStatuses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Roles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
RoleName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShippingStatuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShippingStatuses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
Nickname = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
EmailVerified = table.Column<bool>(type: "bit", nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
|
||||
BasePrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
IsCustomizable = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
|
||||
ImageUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Addresses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: false),
|
||||
AddressType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
Company = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
||||
AddressLine1 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
AddressLine2 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
||||
ApartmentNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
BuildingNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
Floor = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
State = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
PostalCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
||||
Country = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
Instructions = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
IsDefault = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Addresses", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Addresses_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserRole",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: false),
|
||||
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserRole", x => new { x.UserId, x.RoleId });
|
||||
table.ForeignKey(
|
||||
name: "FK_UserRole_Roles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "Roles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserRole_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductVariants",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Size = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
Color = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
ImageUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
Sku = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
StockQuantity = table.Column<int>(type: "int", nullable: false, defaultValue: 0),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductVariants", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductVariants_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: false),
|
||||
OrderDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
Quantity = table.Column<int>(type: "int", nullable: false, defaultValue: 1),
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ProductVariantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
OrderStatusId = table.Column<int>(type: "int", nullable: false),
|
||||
ShippingStatusId = table.Column<int>(type: "int", nullable: false),
|
||||
Notes = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
|
||||
MerchantId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
CustomizationImageUrl = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
|
||||
OriginalImageUrls = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CustomizationDescription = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_OrderStatuses_OrderStatusId",
|
||||
column: x => x.OrderStatusId,
|
||||
principalTable: "OrderStatuses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_ProductVariants_ProductVariantId",
|
||||
column: x => x.ProductVariantId,
|
||||
principalTable: "ProductVariants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_ShippingStatuses_ShippingStatusId",
|
||||
column: x => x.ShippingStatusId,
|
||||
principalTable: "ShippingStatuses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_MerchantId",
|
||||
column: x => x.MerchantId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderAddresses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
||||
OrderId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
AddressType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
LastName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
Company = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
||||
AddressLine1 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
AddressLine2 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
||||
ApartmentNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
BuildingNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
Floor = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
State = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
PostalCode = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
||||
Country = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
|
||||
Instructions = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true, defaultValueSql: "GETUTCDATE()"),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
|
||||
ModifiedBy = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderAddresses", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderAddresses_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Categories",
|
||||
columns: new[] { "Id", "CreatedAt", "CreatedBy", "Description", "ImageUrl", "IsActive", "ModifiedAt", "ModifiedBy", "Name", "ParentCategoryId", "SortOrder" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Textile and fabric-based products", null, true, new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Textile", null, 1 },
|
||||
{ new Guid("22222222-2222-2222-2222-222222222222"), new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Products for hard surface printing", null, true, new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Hard Surfaces", null, 2 },
|
||||
{ new Guid("33333333-3333-3333-3333-333333333333"), new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Paper-based printing products", null, true, new DateTime(2025, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), "system@printbase.com", "Paper", null, 3 }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "OrderStatuses",
|
||||
columns: new[] { "Id", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 0, "Pending" },
|
||||
{ 1, "Processing" },
|
||||
{ 2, "Completed" },
|
||||
{ 3, "Cancelled" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Roles",
|
||||
columns: new[] { "Id", "RoleName" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("22222222-2222-2222-2222-222222222222"), "Merchant" },
|
||||
{ new Guid("33333333-3333-3333-3333-333333333333"), "Admin" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "ShippingStatuses",
|
||||
columns: new[] { "Id", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 0, "Prepping" },
|
||||
{ 1, "Packaging" },
|
||||
{ 2, "Shipped" },
|
||||
{ 3, "Delivered" }
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_CreatedAt",
|
||||
table: "Addresses",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_CreatedBy",
|
||||
table: "Addresses",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_ModifiedAt",
|
||||
table: "Addresses",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_User_Default",
|
||||
table: "Addresses",
|
||||
columns: new[] { "UserId", "IsDefault" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_User_Type",
|
||||
table: "Addresses",
|
||||
columns: new[] { "UserId", "AddressType" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Address_UserId",
|
||||
table: "Addresses",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_Active_SortOrder",
|
||||
table: "Categories",
|
||||
columns: new[] { "IsActive", "SortOrder" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_CreatedAt",
|
||||
table: "Categories",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_CreatedBy",
|
||||
table: "Categories",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_IsActive",
|
||||
table: "Categories",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_ModifiedAt",
|
||||
table: "Categories",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_Name",
|
||||
table: "Categories",
|
||||
column: "Name");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_Parent_SortOrder",
|
||||
table: "Categories",
|
||||
columns: new[] { "ParentCategoryId", "SortOrder" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Category_ParentCategoryId",
|
||||
table: "Categories",
|
||||
column: "ParentCategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderAddress_CreatedAt",
|
||||
table: "OrderAddresses",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderAddress_CreatedBy",
|
||||
table: "OrderAddresses",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderAddress_ModifiedAt",
|
||||
table: "OrderAddresses",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderAddress_OrderId",
|
||||
table: "OrderAddresses",
|
||||
column: "OrderId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_CreatedAt",
|
||||
table: "Orders",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_CreatedBy",
|
||||
table: "Orders",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_Merchant_Date",
|
||||
table: "Orders",
|
||||
columns: new[] { "MerchantId", "OrderDate" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_MerchantId",
|
||||
table: "Orders",
|
||||
column: "MerchantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_ModifiedAt",
|
||||
table: "Orders",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_OrderDate",
|
||||
table: "Orders",
|
||||
column: "OrderDate");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_OrderStatusId",
|
||||
table: "Orders",
|
||||
column: "OrderStatusId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_Product_Date",
|
||||
table: "Orders",
|
||||
columns: new[] { "ProductId", "OrderDate" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_ProductId",
|
||||
table: "Orders",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_ProductVariantId",
|
||||
table: "Orders",
|
||||
column: "ProductVariantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_ShippingStatusId",
|
||||
table: "Orders",
|
||||
column: "ShippingStatusId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_User_Date",
|
||||
table: "Orders",
|
||||
columns: new[] { "UserId", "OrderDate" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Order_UserId",
|
||||
table: "Orders",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderStatus_Name",
|
||||
table: "OrderStatuses",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_Active_Customizable",
|
||||
table: "Products",
|
||||
columns: new[] { "IsActive", "IsCustomizable" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_Category_Active",
|
||||
table: "Products",
|
||||
columns: new[] { "CategoryId", "IsActive" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_CategoryId",
|
||||
table: "Products",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_CreatedAt",
|
||||
table: "Products",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_CreatedBy",
|
||||
table: "Products",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_IsActive",
|
||||
table: "Products",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_IsCustomizable",
|
||||
table: "Products",
|
||||
column: "IsCustomizable");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_ModifiedAt",
|
||||
table: "Products",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_Name",
|
||||
table: "Products",
|
||||
column: "Name");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_CreatedAt",
|
||||
table: "ProductVariants",
|
||||
column: "CreatedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_CreatedBy",
|
||||
table: "ProductVariants",
|
||||
column: "CreatedBy");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_IsActive",
|
||||
table: "ProductVariants",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_ModifiedAt",
|
||||
table: "ProductVariants",
|
||||
column: "ModifiedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_Product_Size_Color",
|
||||
table: "ProductVariants",
|
||||
columns: new[] { "ProductId", "Size", "Color" },
|
||||
unique: true,
|
||||
filter: "[Color] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_ProductId",
|
||||
table: "ProductVariants",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductVariant_SKU",
|
||||
table: "ProductVariants",
|
||||
column: "Sku",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Role_RoleName",
|
||||
table: "Roles",
|
||||
column: "RoleName",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShippingStatus_Name",
|
||||
table: "ShippingStatuses",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRole_RoleId",
|
||||
table: "UserRole",
|
||||
column: "RoleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRole_UserId",
|
||||
table: "UserRole",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_User_Email",
|
||||
table: "Users",
|
||||
column: "Email",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_User_IsActive",
|
||||
table: "Users",
|
||||
column: "IsActive");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Addresses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderAddresses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserRole");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Roles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderStatuses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductVariants");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShippingStatuses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user