diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs
index 9156cfa..6671570 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs
@@ -70,6 +70,7 @@ public class InvoiceController : Controller {
.Include(x => x.ShippingAddress)
.Include(x => x.LinkedAccount)
.Include(x => x.Payment)
+ .ThenInclude(x => x.BillingAddress)
.Include(x => x.Products)
.ThenInclude(y => y.Product)
.ToList());
@@ -77,6 +78,7 @@ public class InvoiceController : Controller {
.Include(x => x.ShippingAddress)
.Include(x => x.LinkedAccount)
.Include(x => x.Payment)
+ .ThenInclude(x => x.BillingAddress)
.Include(x => x.Products)
.ThenInclude(y => y.Product)
.Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList());
@@ -99,7 +101,9 @@ public class InvoiceController : Controller {
}
try {
- inv = _context.Invoices.Where(x => x.Id == id).Include("ShippingAddress").Include(x => x.Payment).First();
+ inv = _context.Invoices.Where(x => x.Id == id).Include("ShippingAddress")
+ .Include(x => x.Payment)
+ .ThenInclude(x => x.BillingAddress).First();
} catch (Exception e) {
_logger.LogError(10, e.Message);
return BadRequest();
@@ -164,9 +168,17 @@ public class InvoiceController : Controller {
// Charges!
StripeConfiguration.ApiKey = _stripeOptions.Value.SecretKey;
- ChargesModel chr;
+ AddressModel bill = new() {
+ CivicNumber = sinv.BillCivicNumber,
+ Street = sinv.BillStreet,
+ City = sinv.BillCity,
+ Appartment= sinv.BillAppartment,
+ Country= sinv.BillCountry,
+ PostalCode= sinv.BillPostalCode,
+ Province= sinv.BillProvince,
+ };
- chr = new() {
+ ChargesModel chr = new() {
Token = sinv.Token,
AmountInCents = sinv.AmountInCents,
Name = sinv.Name,
@@ -175,6 +187,7 @@ public class InvoiceController : Controller {
Description = sinv.Description,
CurrencyCode = sinv.CurrencyCode,
LastFourDigits = sinv.LastFourDigits,
+ BillingAddress = bill
};
inv.Payment = chr;
diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.Designer.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.Designer.cs
similarity index 97%
rename from GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.Designer.cs
rename to GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.Designer.cs
index dafb3de..6f1a3e4 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.Designer.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.Designer.cs
@@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GrossesMitainesAPI.Migrations
{
[DbContext(typeof(InventoryContext))]
- [Migration("20221212184710_Initial-Db")]
+ [Migration("20221212202643_Initial-Db")]
partial class InitialDb
{
///
@@ -104,7 +104,7 @@ namespace GrossesMitainesAPI.Migrations
{
Id = "ecf7503a-591c-454e-a824-048e10bd0474",
AccessFailedCount = 0,
- ConcurrencyStamp = "2ac18a08-5d70-48e8-9573-320dad586981",
+ ConcurrencyStamp = "88a1532a-3749-409e-8463-7f68f04c2225",
Email = "admin@admin.com",
EmailConfirmed = false,
FirstName = "Roger",
@@ -112,10 +112,10 @@ namespace GrossesMitainesAPI.Migrations
LockoutEnabled = false,
NormalizedEmail = "ADMIN@ADMIN.COM",
NormalizedUserName = "ADMIN",
- PasswordHash = "AQAAAAIAAYagAAAAEOGVyf1NmEyY4lQvKgz6hPT/e1tBM6OD+QhgvL+F5cl18hJd3SgTaXr68sG1R+zZ/w==",
+ PasswordHash = "AQAAAAIAAYagAAAAEOixAy1U6YTbU41EkE4Yb3isi7ZhI/6YVpmzsfcy2aC2e7olVRw52N7h+ivBX6nSVg==",
PhoneNumber = "111-111-1111",
PhoneNumberConfirmed = false,
- SecurityStamp = "f5e5a167-cf8a-49d0-a59a-c3bce8edd1b4",
+ SecurityStamp = "f1e4d7cd-ff9b-428c-9bbf-a560e4607775",
TwoFactorEnabled = false,
UserName = "Admin"
},
@@ -123,7 +123,7 @@ namespace GrossesMitainesAPI.Migrations
{
Id = "af9178c8-1a02-4ff8-bc0a-c8248dad6e09",
AccessFailedCount = 0,
- ConcurrencyStamp = "e21f342e-e51b-49bc-8e1c-e5e1850cbe7d",
+ ConcurrencyStamp = "12929beb-3cd0-4f28-a965-ecb9d0299c86",
Email = "paul@exemple.com",
EmailConfirmed = false,
FirstName = "Paul",
@@ -131,10 +131,10 @@ namespace GrossesMitainesAPI.Migrations
LockoutEnabled = false,
NormalizedEmail = "PAUL@EXEMPLE.COM",
NormalizedUserName = "PASLA",
- PasswordHash = "AQAAAAIAAYagAAAAEI1VUySaarTQ0fnHErjdFYCdY3RHc0gBsXf7beebl/gIELG9r+negBoOOflW1PlqNw==",
+ PasswordHash = "AQAAAAIAAYagAAAAEN5YIl6BfmRcgns81BzscQa5/UmHzZxkoBraDPod7EFwjxYL0KJCneEimbytwK91lQ==",
PhoneNumber = "222-222-2222",
PhoneNumberConfirmed = false,
- SecurityStamp = "2e2a1e6a-c280-458b-8378-078407c218c5",
+ SecurityStamp = "5a5c5690-7ac8-4cb6-8820-b840f5a0e4f6",
TwoFactorEnabled = false,
UserName = "PasLa"
});
@@ -235,6 +235,9 @@ namespace GrossesMitainesAPI.Migrations
b.Property("AmountInCents")
.HasColumnType("bigint");
+ b.Property("BillingAddressId")
+ .HasColumnType("int");
+
b.Property("CurrencyCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -265,6 +268,8 @@ namespace GrossesMitainesAPI.Migrations
b.HasKey("Id");
+ b.HasIndex("BillingAddressId");
+
b.ToTable("ChargesModel");
});
@@ -328,7 +333,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2559),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7175),
ShippingAddressId = 1,
Status = 0
},
@@ -340,7 +345,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2620),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7234),
ShippingAddressId = 1,
Status = 1
},
@@ -352,7 +357,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2622),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7236),
ShippingAddressId = 1,
Status = 3
},
@@ -364,7 +369,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2624),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7238),
ShippingAddressId = 1,
Status = 4
},
@@ -376,7 +381,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2626),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7240),
ShippingAddressId = 1,
Status = 5
},
@@ -387,7 +392,7 @@ namespace GrossesMitainesAPI.Migrations
FirstName = "Jérémy",
LastName = "Le Petit",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2628),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7242),
ShippingAddressId = 2,
Status = 0
},
@@ -399,7 +404,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "A.",
LinkedAccountId = "af9178c8-1a02-4ff8-bc0a-c8248dad6e09",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2657),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7259),
ShippingAddressId = 3,
Status = 3
});
@@ -1205,6 +1210,17 @@ namespace GrossesMitainesAPI.Migrations
.HasForeignKey("InventoryUserId");
});
+ modelBuilder.Entity("GrossesMitainesAPI.Models.ChargesModel", b =>
+ {
+ b.HasOne("GrossesMitainesAPI.Models.AddressModel", "BillingAddress")
+ .WithMany()
+ .HasForeignKey("BillingAddressId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("BillingAddress");
+ });
+
modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel", b =>
{
b.HasOne("GrossesMitainesAPI.Data.InventoryUser", "LinkedAccount")
diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.cs
similarity index 94%
rename from GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.cs
rename to GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.cs
index 57d56fc..66e5e97 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212184710_Initial-Db.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221212202643_Initial-Db.cs
@@ -54,26 +54,6 @@ namespace GrossesMitainesAPI.Migrations
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
- migrationBuilder.CreateTable(
- name: "ChargesModel",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Token = table.Column(type: "nvarchar(max)", nullable: false),
- Description = table.Column(type: "nvarchar(max)", nullable: false),
- AmountInCents = table.Column(type: "bigint", nullable: false),
- CurrencyCode = table.Column(type: "nvarchar(max)", nullable: false),
- Name = table.Column(type: "nvarchar(max)", nullable: false),
- Email = table.Column(type: "nvarchar(max)", nullable: false),
- Phone = table.Column(type: "nvarchar(max)", nullable: false),
- LastFourDigits = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChargesModel", x => x.Id);
- });
-
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
@@ -229,6 +209,33 @@ namespace GrossesMitainesAPI.Migrations
onDelete: ReferentialAction.Cascade);
});
+ migrationBuilder.CreateTable(
+ name: "ChargesModel",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Token = table.Column(type: "nvarchar(max)", nullable: false),
+ Description = table.Column(type: "nvarchar(max)", nullable: false),
+ AmountInCents = table.Column(type: "bigint", nullable: false),
+ CurrencyCode = table.Column(type: "nvarchar(max)", nullable: false),
+ Name = table.Column(type: "nvarchar(max)", nullable: false),
+ Email = table.Column(type: "nvarchar(max)", nullable: false),
+ Phone = table.Column(type: "nvarchar(max)", nullable: false),
+ LastFourDigits = table.Column(type: "nvarchar(max)", nullable: false),
+ BillingAddressId = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ChargesModel", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ChargesModel_Addresses_BillingAddressId",
+ column: x => x.BillingAddressId,
+ principalTable: "Addresses",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
migrationBuilder.CreateTable(
name: "Invoices",
columns: table => new
@@ -311,8 +318,8 @@ namespace GrossesMitainesAPI.Migrations
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FirstName", "LastName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" },
values: new object[,]
{
- { "af9178c8-1a02-4ff8-bc0a-c8248dad6e09", 0, "e21f342e-e51b-49bc-8e1c-e5e1850cbe7d", "paul@exemple.com", false, "Paul", "A.", false, null, "PAUL@EXEMPLE.COM", "PASLA", "AQAAAAIAAYagAAAAEI1VUySaarTQ0fnHErjdFYCdY3RHc0gBsXf7beebl/gIELG9r+negBoOOflW1PlqNw==", "222-222-2222", false, "2e2a1e6a-c280-458b-8378-078407c218c5", false, "PasLa" },
- { "ecf7503a-591c-454e-a824-048e10bd0474", 0, "2ac18a08-5d70-48e8-9573-320dad586981", "admin@admin.com", false, "Roger", "Admin", false, null, "ADMIN@ADMIN.COM", "ADMIN", "AQAAAAIAAYagAAAAEOGVyf1NmEyY4lQvKgz6hPT/e1tBM6OD+QhgvL+F5cl18hJd3SgTaXr68sG1R+zZ/w==", "111-111-1111", false, "f5e5a167-cf8a-49d0-a59a-c3bce8edd1b4", false, "Admin" }
+ { "af9178c8-1a02-4ff8-bc0a-c8248dad6e09", 0, "12929beb-3cd0-4f28-a965-ecb9d0299c86", "paul@exemple.com", false, "Paul", "A.", false, null, "PAUL@EXEMPLE.COM", "PASLA", "AQAAAAIAAYagAAAAEN5YIl6BfmRcgns81BzscQa5/UmHzZxkoBraDPod7EFwjxYL0KJCneEimbytwK91lQ==", "222-222-2222", false, "5a5c5690-7ac8-4cb6-8820-b840f5a0e4f6", false, "PasLa" },
+ { "ecf7503a-591c-454e-a824-048e10bd0474", 0, "88a1532a-3749-409e-8463-7f68f04c2225", "admin@admin.com", false, "Roger", "Admin", false, null, "ADMIN@ADMIN.COM", "ADMIN", "AQAAAAIAAYagAAAAEOixAy1U6YTbU41EkE4Yb3isi7ZhI/6YVpmzsfcy2aC2e7olVRw52N7h+ivBX6nSVg==", "111-111-1111", false, "f1e4d7cd-ff9b-428c-9bbf-a560e4607775", false, "Admin" }
});
migrationBuilder.InsertData(
@@ -376,13 +383,13 @@ namespace GrossesMitainesAPI.Migrations
columns: new[] { "Id", "EmailAddress", "FirstName", "LastName", "LinkedAccountId", "PaymentId", "PhoneNumber", "PurchaseDate", "ShippingAddressId", "Status" },
values: new object[,]
{
- { 6, "test@admin.com", "Jérémy", "Le Petit", null, null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2628), 2, 0 },
- { 1, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2559), 1, 0 },
- { 2, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2620), 1, 1 },
- { 3, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2622), 1, 3 },
- { 4, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2624), 1, 4 },
- { 5, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2626), 1, 5 },
- { 7, "paul@exemple.com", "Paul", "A.", "af9178c8-1a02-4ff8-bc0a-c8248dad6e09", null, "111-111-1111", new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2657), 3, 3 }
+ { 6, "test@admin.com", "Jérémy", "Le Petit", null, null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7242), 2, 0 },
+ { 1, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7175), 1, 0 },
+ { 2, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7234), 1, 1 },
+ { 3, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7236), 1, 3 },
+ { 4, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7238), 1, 4 },
+ { 5, "admin@admin.com", "Roger", "Admin", "ecf7503a-591c-454e-a824-048e10bd0474", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7240), 1, 5 },
+ { 7, "paul@exemple.com", "Paul", "A.", "af9178c8-1a02-4ff8-bc0a-c8248dad6e09", null, "111-111-1111", new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7259), 3, 3 }
});
migrationBuilder.InsertData(
@@ -454,6 +461,11 @@ namespace GrossesMitainesAPI.Migrations
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
+ migrationBuilder.CreateIndex(
+ name: "IX_ChargesModel_BillingAddressId",
+ table: "ChargesModel",
+ column: "BillingAddressId");
+
migrationBuilder.CreateIndex(
name: "IX_Invoices_LinkedAccountId",
table: "Invoices",
@@ -511,10 +523,10 @@ namespace GrossesMitainesAPI.Migrations
name: "Products");
migrationBuilder.DropTable(
- name: "Addresses");
+ name: "ChargesModel");
migrationBuilder.DropTable(
- name: "ChargesModel");
+ name: "Addresses");
migrationBuilder.DropTable(
name: "AspNetUsers");
diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs
index aa6685e..85adca2 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs
@@ -101,7 +101,7 @@ namespace GrossesMitainesAPI.Migrations
{
Id = "ecf7503a-591c-454e-a824-048e10bd0474",
AccessFailedCount = 0,
- ConcurrencyStamp = "2ac18a08-5d70-48e8-9573-320dad586981",
+ ConcurrencyStamp = "88a1532a-3749-409e-8463-7f68f04c2225",
Email = "admin@admin.com",
EmailConfirmed = false,
FirstName = "Roger",
@@ -109,10 +109,10 @@ namespace GrossesMitainesAPI.Migrations
LockoutEnabled = false,
NormalizedEmail = "ADMIN@ADMIN.COM",
NormalizedUserName = "ADMIN",
- PasswordHash = "AQAAAAIAAYagAAAAEOGVyf1NmEyY4lQvKgz6hPT/e1tBM6OD+QhgvL+F5cl18hJd3SgTaXr68sG1R+zZ/w==",
+ PasswordHash = "AQAAAAIAAYagAAAAEOixAy1U6YTbU41EkE4Yb3isi7ZhI/6YVpmzsfcy2aC2e7olVRw52N7h+ivBX6nSVg==",
PhoneNumber = "111-111-1111",
PhoneNumberConfirmed = false,
- SecurityStamp = "f5e5a167-cf8a-49d0-a59a-c3bce8edd1b4",
+ SecurityStamp = "f1e4d7cd-ff9b-428c-9bbf-a560e4607775",
TwoFactorEnabled = false,
UserName = "Admin"
},
@@ -120,7 +120,7 @@ namespace GrossesMitainesAPI.Migrations
{
Id = "af9178c8-1a02-4ff8-bc0a-c8248dad6e09",
AccessFailedCount = 0,
- ConcurrencyStamp = "e21f342e-e51b-49bc-8e1c-e5e1850cbe7d",
+ ConcurrencyStamp = "12929beb-3cd0-4f28-a965-ecb9d0299c86",
Email = "paul@exemple.com",
EmailConfirmed = false,
FirstName = "Paul",
@@ -128,10 +128,10 @@ namespace GrossesMitainesAPI.Migrations
LockoutEnabled = false,
NormalizedEmail = "PAUL@EXEMPLE.COM",
NormalizedUserName = "PASLA",
- PasswordHash = "AQAAAAIAAYagAAAAEI1VUySaarTQ0fnHErjdFYCdY3RHc0gBsXf7beebl/gIELG9r+negBoOOflW1PlqNw==",
+ PasswordHash = "AQAAAAIAAYagAAAAEN5YIl6BfmRcgns81BzscQa5/UmHzZxkoBraDPod7EFwjxYL0KJCneEimbytwK91lQ==",
PhoneNumber = "222-222-2222",
PhoneNumberConfirmed = false,
- SecurityStamp = "2e2a1e6a-c280-458b-8378-078407c218c5",
+ SecurityStamp = "5a5c5690-7ac8-4cb6-8820-b840f5a0e4f6",
TwoFactorEnabled = false,
UserName = "PasLa"
});
@@ -232,6 +232,9 @@ namespace GrossesMitainesAPI.Migrations
b.Property("AmountInCents")
.HasColumnType("bigint");
+ b.Property("BillingAddressId")
+ .HasColumnType("int");
+
b.Property("CurrencyCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -262,6 +265,8 @@ namespace GrossesMitainesAPI.Migrations
b.HasKey("Id");
+ b.HasIndex("BillingAddressId");
+
b.ToTable("ChargesModel");
});
@@ -325,7 +330,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2559),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7175),
ShippingAddressId = 1,
Status = 0
},
@@ -337,7 +342,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2620),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7234),
ShippingAddressId = 1,
Status = 1
},
@@ -349,7 +354,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2622),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7236),
ShippingAddressId = 1,
Status = 3
},
@@ -361,7 +366,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2624),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7238),
ShippingAddressId = 1,
Status = 4
},
@@ -373,7 +378,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "Admin",
LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2626),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7240),
ShippingAddressId = 1,
Status = 5
},
@@ -384,7 +389,7 @@ namespace GrossesMitainesAPI.Migrations
FirstName = "Jérémy",
LastName = "Le Petit",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2628),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7242),
ShippingAddressId = 2,
Status = 0
},
@@ -396,7 +401,7 @@ namespace GrossesMitainesAPI.Migrations
LastName = "A.",
LinkedAccountId = "af9178c8-1a02-4ff8-bc0a-c8248dad6e09",
PhoneNumber = "111-111-1111",
- PurchaseDate = new DateTime(2022, 12, 12, 10, 47, 9, 782, DateTimeKind.Local).AddTicks(2657),
+ PurchaseDate = new DateTime(2022, 12, 12, 12, 26, 42, 867, DateTimeKind.Local).AddTicks(7259),
ShippingAddressId = 3,
Status = 3
});
@@ -1202,6 +1207,17 @@ namespace GrossesMitainesAPI.Migrations
.HasForeignKey("InventoryUserId");
});
+ modelBuilder.Entity("GrossesMitainesAPI.Models.ChargesModel", b =>
+ {
+ b.HasOne("GrossesMitainesAPI.Models.AddressModel", "BillingAddress")
+ .WithMany()
+ .HasForeignKey("BillingAddressId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("BillingAddress");
+ });
+
modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel", b =>
{
b.HasOne("GrossesMitainesAPI.Data.InventoryUser", "LinkedAccount")
diff --git a/GrossesMitaines/GrossesMitainesAPI/Models/ChargeReturnModel.cs b/GrossesMitaines/GrossesMitainesAPI/Models/ChargeReturnModel.cs
index 17f9824..441a87d 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Models/ChargeReturnModel.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Models/ChargeReturnModel.cs
@@ -1,4 +1,6 @@
-namespace GrossesMitainesAPI.Models;
+using System.ComponentModel.DataAnnotations;
+
+namespace GrossesMitainesAPI.Models;
public class ChargeReturnModel {
public string Token { get; set; }
public string Description { get; set; }
@@ -9,4 +11,5 @@ public class ChargeReturnModel {
public string Phone { get; set; }
public int Invoice { get; set; }
public string LastFourDigits { get; set; }
+ public AddressModel ShippingAddress { get; set; }
}
diff --git a/GrossesMitaines/GrossesMitainesAPI/Models/ChargesModel.cs b/GrossesMitaines/GrossesMitainesAPI/Models/ChargesModel.cs
index 23717a5..24a2b63 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Models/ChargesModel.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Models/ChargesModel.cs
@@ -12,4 +12,5 @@ public class ChargesModel {
public string Email { get; set; }
public string Phone { get; set; }
public string LastFourDigits { get; set; }
+ public AddressModel BillingAddress { get; set; }
}
diff --git a/GrossesMitaines/GrossesMitainesAPI/Models/SendInvoiceModel.cs b/GrossesMitaines/GrossesMitainesAPI/Models/SendInvoiceModel.cs
index a5c8988..4eaf1a9 100644
--- a/GrossesMitaines/GrossesMitainesAPI/Models/SendInvoiceModel.cs
+++ b/GrossesMitaines/GrossesMitainesAPI/Models/SendInvoiceModel.cs
@@ -36,4 +36,20 @@ namespace GrossesMitainesAPI.Models;
public string Email { get; set; }
public string Phone { get; set; }
public string LastFourDigits { get; set; }
+
+
+ [Required, Range(1, int.MaxValue)]
+ public int BillCivicNumber { get; set; }
+ public string? BillAppartment { get; set; }
+ [Required, MinLength(3), MaxLength(50)]
+ public string BillStreet { get; set; }
+ [Required, MinLength(4), MaxLength(50)]
+ public string BillCity { get; set; }
+ [Required, MaxLength(3)]
+ public string BillProvince { get; set; }
+ [Required, MinLength(4), MaxLength(30)]
+ public string BillCountry { get; set; }
+ // Source pour regex: https://stackoverflow.com/questions/15774555/efficient-regex-for-canadian-postal-code-function
+ //[Required, RegularExpression(@"/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i")]
+ public string BillPostalCode { get; set; }
}
\ No newline at end of file