diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index 4a999c8..931a949 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -28,11 +28,11 @@ public class InvoiceController : Controller { #endregion #region Ctor - public InvoiceController(ILogger logger, - InventoryContext context, + public InvoiceController(ILogger logger, + InventoryContext context, DatabaseCacheService cache, SignInManager signInMan, - Microsoft.AspNetCore.Identity.UserManager userMan) { + Microsoft.AspNetCore.Identity.UserManager userMan) { _logger = logger; _context = context; _cache = cache; @@ -50,7 +50,8 @@ public class InvoiceController : Controller { try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver. var user = await _userMan.GetUserAsync(_signInMan.Context.User); roles = await _userMan.GetRolesAsync(user); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(10, e.Message); roles = new List(); } @@ -58,10 +59,20 @@ public class InvoiceController : Controller { try { id = _signInMan.Context.User.Identity.GetUserId(); if (all is not null && all == true && roles.Contains("Administrateur")) - return Ok(_context.Invoices.ToList()); - else return Ok(_context.Invoices.Include("ShippingAddress").Where(x => x.LinkedAccount != null && - x.LinkedAccount.Id == id).ToList()); - } catch (Exception e) { + return Ok(_context.Invoices + .Include("ShippingAddress") + .Include(x => x.Products) + .ThenInclude(y => y.Product) + .ToList()); + + else + return Ok(_context.Invoices + .Include("ShippingAddress") + .Include(x => x.Products) + .ThenInclude(y => y.Product) + .Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList()); + } + catch (Exception e) { _logger.LogError(10, e.Message); return BadRequest(); } @@ -74,14 +85,16 @@ public class InvoiceController : Controller { try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver. roles = await _userMan.GetRolesAsync(await _userMan.GetUserAsync(_signInMan.Context.User)); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(10, e.Message); roles = new List(); } try { inv = _context.Invoices.Where(x => x.Id == id).Include("ShippingAddress").First(); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(10, e.Message); return BadRequest(); } @@ -97,9 +110,9 @@ public class InvoiceController : Controller { public async Task> Post(SendInvoiceModel sinv) { var user = await _userMan.GetUserAsync(_signInMan.Context.User); var prodcom = sinv.ProdQuant; - Dictionary badprods = new(); + Dictionary badprods = new(); List prods; - InvoiceModel inv = new() { + InvoiceModel inv = new() { FirstName = sinv.FirstName, LastName = sinv.LastName, EmailAddress = sinv.EmailAddress, @@ -112,7 +125,7 @@ public class InvoiceController : Controller { x.City == sinv.City && x.Province == sinv.Province && x.Country == sinv.Country) ?? - new() { + new() { CivicNumber = sinv.CivicNumber, Appartment = sinv.Appartment, Street = sinv.Street, @@ -127,7 +140,8 @@ public class InvoiceController : Controller { try { prods = _context.Products.Where(x => sinv.ProdQuant.Select(x => x.Key).Contains(x.Id)).ToList(); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(8, e.Message); return BadRequest(); } @@ -144,20 +158,22 @@ public class InvoiceController : Controller { inventProd.Status = inventProd.Status == ProductModel.States.Clearance ? ProductModel.States.Discontinued : ProductModel.States.BackOrder; - } else inventProd.Quantity -= prod.Value; + } + else inventProd.Quantity -= prod.Value; inventProd.LastSale = DateTime.Now; inventProd.Sales += prod.Value; } if (badprods.Count > 0) // Retour des produits non-achetable avec l'inventaire restant. return BadRequest(badprods.ToArray()); - + try { // Faire les updates dans la BD. _context.Addresses.Add(ad); _context.Invoices.Add(inv); _context.Products.UpdateRange(prods); _context.SaveChanges(); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(8, e.Message); return BadRequest(e.InnerException.Message); } @@ -167,27 +183,29 @@ public class InvoiceController : Controller { } [HttpPost("Cancel/{id}"), Authorize(Roles = "Client, Administrateur")] - public async Task> Cancel(int id) { + public async Task> Cancel(int id) { InvoiceModel inv; IList roles; try { // Trouver la commande. inv = _context.Invoices.Where(x => x.Id == id) .Include("Product").First(); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(8, e.Message); return BadRequest(); } try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver. roles = await _userMan.GetRolesAsync(await _userMan.GetUserAsync(_signInMan.Context.User)); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(10, e.Message); roles = new List(); } // Pour ne pas pouvoir arbitrairement annuler la commande d'un autre client en tant que client. - if (!((inv.LinkedAccount is not null && + if (!((inv.LinkedAccount is not null && inv.LinkedAccount.Id == _signInMan.Context.User.Identity.GetUserId()) || roles.Contains("Administrateur"))) return Unauthorized(); @@ -208,12 +226,13 @@ public class InvoiceController : Controller { else prod.Product.Status = ProductModel.States.Available; prod.Product.Quantity = prod.Product.Quantity + prod.Quantity; prod.Product.Sales -= prod.Quantity; - } + } try { _context.Update(inv); _context.SaveChanges(); - } catch (Exception e) { + } + catch (Exception e) { _logger.LogError(8, e.Message); return BadRequest(); } diff --git a/GrossesMitaines/GrossesMitainesAPI/Data/InventoryContext.cs b/GrossesMitaines/GrossesMitainesAPI/Data/InventoryContext.cs index 964bb62..dfcaaf2 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Data/InventoryContext.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Data/InventoryContext.cs @@ -414,6 +414,15 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl Province = "QC", Country = "Canada", InventoryUserId = AdminID, + }, + new { + Id = 2, + CivicNumber = 420, + Street = "Rue MikeWard", + City = "Saint-Jérôme", + PostalCode = "H0H0H0", + Province = "QC", + Country = "Canada", } ); #endregion @@ -476,6 +485,16 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl PurchaseDate = DateTime.Now, ShippingAddressId = 1, Status = InvoiceModel.InStates.Returned, + }, + new { + Id = 6, + EmailAddress = "test@admin.com", + FirstName = "Jérémy", + LastName = "Le Petit", + PhoneNumber = "111-111-1111", + PurchaseDate = DateTime.Now, + ShippingAddressId = 2, + Status = InvoiceModel.InStates.Confirmed, } ); @@ -578,6 +597,14 @@ Pikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumbl ProductId = 15, Quantity = (uint)2, InvoiceModelId = 5 + }, + + // invoice 6 + new { + Id = 16, + ProductId = 20, + Quantity = (uint)4, + InvoiceModelId = 6 } ); #endregion diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.Designer.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.Designer.cs new file mode 100644 index 0000000..00b5826 --- /dev/null +++ b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.Designer.cs @@ -0,0 +1,1192 @@ +// +using System; +using GrossesMitainesAPI.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace GrossesMitainesAPI.Migrations +{ + [DbContext(typeof(InventoryContext))] + [Migration("20221108033526_nonUserInvoice")] + partial class nonUserInvoice + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("GrossesMitainesAPI.Data.InventoryUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + + b.HasData( + new + { + Id = "ecf7503a-591c-454e-a824-048e10bd0474", + AccessFailedCount = 0, + ConcurrencyStamp = "af3a641d-8fe8-45c3-8e36-fdfbef10659a", + Email = "admin@admin.com", + EmailConfirmed = false, + FirstName = "Roger", + LastName = "Admin", + LockoutEnabled = false, + NormalizedEmail = "ADMIN@ADMIN.COM", + NormalizedUserName = "ADMIN", + PasswordHash = "AQAAAAEAACcQAAAAEL/k0+c61dX1YPgqHrr6wmVSZNJzoqveJzr8IxjVSSL3W+GSsqOXft+hVLXozCnqVg==", + PhoneNumberConfirmed = false, + SecurityStamp = "8ac35276-f8dc-4de4-826f-ea2996e09f2c", + TwoFactorEnabled = false, + UserName = "Admin" + }); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.AddressModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Appartment") + .HasColumnType("nvarchar(max)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CivicNumber") + .HasColumnType("int"); + + b.Property("Country") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("InventoryUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Province") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("Street") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("InventoryUserId"); + + b.ToTable("Addresses"); + + b.HasData( + new + { + Id = 1, + Appartment = "B", + City = "Saint-Chrysostome", + CivicNumber = 1234, + Country = "Canada", + InventoryUserId = "ecf7503a-591c-454e-a824-048e10bd0474", + PostalCode = "H0H0H0", + Province = "QC", + Street = "Rue Pierre-Falardeau" + }, + new + { + Id = 2, + City = "Saint-Jérôme", + CivicNumber = 420, + Country = "Canada", + PostalCode = "H0H0H0", + Province = "QC", + Street = "Rue MikeWard" + }); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("LinkedAccountId") + .HasColumnType("nvarchar(450)"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PurchaseDate") + .HasColumnType("datetime2"); + + b.Property("ShippingAddressId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LinkedAccountId"); + + b.HasIndex("ShippingAddressId"); + + b.ToTable("Invoices"); + + b.HasData( + new + { + Id = 1, + EmailAddress = "admin@admin.com", + FirstName = "Roger", + LastName = "Admin", + LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6619), + ShippingAddressId = 1, + Status = 0 + }, + new + { + Id = 2, + EmailAddress = "admin@admin.com", + FirstName = "Roger", + LastName = "Admin", + LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6655), + ShippingAddressId = 1, + Status = 1 + }, + new + { + Id = 3, + EmailAddress = "admin@admin.com", + FirstName = "Roger", + LastName = "Admin", + LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6658), + ShippingAddressId = 1, + Status = 3 + }, + new + { + Id = 4, + EmailAddress = "admin@admin.com", + FirstName = "Roger", + LastName = "Admin", + LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6659), + ShippingAddressId = 1, + Status = 4 + }, + new + { + Id = 5, + EmailAddress = "admin@admin.com", + FirstName = "Roger", + LastName = "Admin", + LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6661), + ShippingAddressId = 1, + Status = 5 + }, + new + { + Id = 6, + EmailAddress = "test@admin.com", + FirstName = "Jérémy", + LastName = "Le Petit", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6663), + ShippingAddressId = 2, + Status = 0 + }); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel+ProductInvoice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("InvoiceModelId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("InvoiceModelId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductInvoice"); + + b.HasData( + new + { + Id = 1, + InvoiceModelId = 1, + ProductId = 1, + Quantity = 2L + }, + new + { + Id = 2, + InvoiceModelId = 1, + ProductId = 4, + Quantity = 5L + }, + new + { + Id = 3, + InvoiceModelId = 2, + ProductId = 3, + Quantity = 1L + }, + new + { + Id = 4, + InvoiceModelId = 2, + ProductId = 5, + Quantity = 2L + }, + new + { + Id = 5, + InvoiceModelId = 2, + ProductId = 7, + Quantity = 1L + }, + new + { + Id = 6, + InvoiceModelId = 3, + ProductId = 9, + Quantity = 1L + }, + new + { + Id = 7, + InvoiceModelId = 3, + ProductId = 11, + Quantity = 1L + }, + new + { + Id = 8, + InvoiceModelId = 4, + ProductId = 14, + Quantity = 1L + }, + new + { + Id = 9, + InvoiceModelId = 4, + ProductId = 13, + Quantity = 1L + }, + new + { + Id = 10, + InvoiceModelId = 4, + ProductId = 16, + Quantity = 1L + }, + new + { + Id = 11, + InvoiceModelId = 4, + ProductId = 24, + Quantity = 25L + }, + new + { + Id = 12, + InvoiceModelId = 5, + ProductId = 25, + Quantity = 1L + }, + new + { + Id = 13, + InvoiceModelId = 5, + ProductId = 29, + Quantity = 1L + }, + new + { + Id = 14, + InvoiceModelId = 5, + ProductId = 30, + Quantity = 1L + }, + new + { + Id = 15, + InvoiceModelId = 5, + ProductId = 15, + Quantity = 2L + }, + new + { + Id = 16, + InvoiceModelId = 6, + ProductId = 20, + Quantity = 4L + }); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.ProductModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hits") + .HasColumnType("bigint"); + + b.Property("ImageName") + .HasColumnType("nvarchar(max)"); + + b.Property("LastHit") + .HasColumnType("datetime2"); + + b.Property("LastSale") + .HasColumnType("datetime2"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PromoPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Quantity") + .HasColumnType("bigint"); + + b.Property("Sales") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Products"); + + b.HasData( + new + { + Id = 1, + Category = "Linge", + Description = "Pour faire votre propre bonhomme de 1837, comme dans le bon vieux temps.", + Hits = 0L, + ImageName = "$ceintureflechee.jpg", + Price = 85.86m, + PromoPrice = 29.99m, + Quantity = 1L, + Sales = 0L, + Status = 4, + Title = "Ceinture flèchée" + }, + new + { + Id = 2, + Category = "Linge", + Description = "Parce que ça sent la coupe!", + Hits = 0L, + ImageName = "$pantouflesCH.jpg", + Price = 15.64m, + PromoPrice = 9.99m, + Quantity = 54L, + Sales = 0L, + Status = 0, + Title = "Pantoufles du Canadien en Phentex" + }, + new + { + Id = 3, + Category = "Homme", + Description = "On ne lui ferait pas mal, en tout cas!!", + Hits = 0L, + ImageName = "$jeanlucmongrain.jpg", + Price = 1453.12m, + PromoPrice = 999.99m, + Quantity = 1L, + Sales = 0L, + Status = 3, + Title = "Jean-Luc Mongrain" + }, + new + { + Id = 4, + Category = "Linge", + Description = "Tellement simple et comfortable.", + Hits = 0L, + ImageName = "$tshirt.jpg", + Price = 12.12m, + PromoPrice = 9.99m, + Quantity = 143L, + Sales = 0L, + Status = 0, + Title = "T-Shirt" + }, + new + { + Id = 5, + Category = "Vêtement d'extérieur", + Description = "Deux pour un!", + Hits = 0L, + ImageName = "$mitaines.jpg", + Price = 8.18m, + PromoPrice = 6.99m, + Quantity = 1423L, + Sales = 0L, + Status = 0, + Title = "Mitaines" + }, + new + { + Id = 6, + Category = "Vêtement d'extérieur", + Description = "Deux pour un!", + Hits = 0L, + ImageName = "$foulard.jpg", + Price = 10.56m, + PromoPrice = 8.99m, + Quantity = 14L, + Sales = 0L, + Status = 4, + Title = "Foulard" + }, + new + { + Id = 7, + Category = "Sous-Vêtement", + Description = "Pour garder le p'tit bout au chaud.", + Hits = 0L, + ImageName = "$kokin.jpg", + Price = 15.45m, + PromoPrice = 12.99m, + Quantity = 144L, + Sales = 0L, + Status = 4, + Title = "Jock-Strap en phentex" + }, + new + { + Id = 8, + Category = "Sous-Vêtement", + Description = "Pour garder l'absence de p'tit bout au chaud.", + Hits = 0L, + ImageName = "$kokinfemme.jpg", + Price = 15.45m, + PromoPrice = 12.99m, + Quantity = 224L, + Sales = 0L, + Status = 4, + Title = "Jock-Strap féminin en phentex" + }, + new + { + Id = 9, + Category = "Alien", + Description = "En chiffon.", + Hits = 0L, + ImageName = "$bibi.jpg", + Price = 1045.45m, + PromoPrice = 1023.99m, + Quantity = 1L, + Sales = 0L, + Status = 3, + Title = "Bibi" + }, + new + { + Id = 10, + Category = "Vêtement d'extérieur", + Description = "En chiffon.", + Hits = 0L, + ImageName = "$tuque.jpg", + Price = 15.45m, + PromoPrice = 12.99m, + Quantity = 1L, + Sales = 0L, + Status = 0, + Title = "Tuque en laine" + }, + new + { + Id = 11, + Category = "Vêtement d'extérieur", + Description = "Pour se faire taper dessus avec une poêle à frire tout en restant au chaud.", + Hits = 0L, + ImageName = "$bonhomme.jpg", + Price = 145.45m, + PromoPrice = 123.99m, + Quantity = 1L, + Sales = 0L, + Status = 4, + Title = "Habit de Bonhomme Carnaval" + }, + new + { + Id = 12, + Category = "Autre", + Description = "Pour se pêter la fiole avec style.", + Hits = 0L, + ImageName = "$gauze.jpg", + Price = 145.45m, + PromoPrice = 123.99m, + Quantity = 0L, + Sales = 0L, + Status = 1, + Title = "Gauze en phentex" + }, + new + { + Id = 13, + Category = "Homme", + Description = "En chiffon.", + Hits = 0L, + ImageName = "$jesus.jpg", + Price = 145.45m, + PromoPrice = 123.99m, + Quantity = 1L, + Sales = 0L, + Status = 3, + Title = "Petit Jésus de plâtre" + }, + new + { + Id = 14, + Category = "Autre", + Description = "À écouter dans l'habit de Bonhomme Carnaval tant que possible.", + Hits = 0L, + ImageName = "$vhs.jpg", + Price = 3.45m, + PromoPrice = 1.99m, + Quantity = 164363L, + Sales = 0L, + Status = 3, + Title = "VHS de la Guerre des Tuques" + }, + new + { + Id = 15, + Category = "Linge", + Description = "(N'est pas réellement pare-balle).", + Hits = 0L, + ImageName = "$chandailquetaine.jpg", + Price = 1435.45m, + PromoPrice = 1223.99m, + Quantity = 18L, + Sales = 0L, + Status = 3, + Title = "Gilet pare-balle en laine" + }, + new + { + Id = 16, + Category = "Autre", + Description = "Pour s'éffoirer le nez dedans.", + Hits = 0L, + ImageName = "$doudou.jpg", + Price = 14.45m, + PromoPrice = 13.99m, + Quantity = 14L, + Sales = 0L, + Status = 0, + Title = "Doudou" + }, + new + { + Id = 17, + Category = "Vêtements d'extérieur", + Description = "Pour avoir l'air thug en hiver.", + Hits = 0L, + ImageName = "$mitaines2.jpg", + Price = 9.45m, + PromoPrice = 8.99m, + Quantity = 16L, + Sales = 0L, + Status = 0, + Title = "Mitaines pas de doigts" + }, + new + { + Id = 18, + Category = "Vêtements d'extérieur", + Description = "Pour avoir plus l'air thug en hiver.", + Hits = 0L, + ImageName = "$longmitaines.jpg", + Price = 10.45m, + PromoPrice = 9.99m, + Quantity = 10L, + Sales = 0L, + Status = 5, + Title = "Longues mitaines pas de doigts" + }, + new + { + Id = 19, + Category = "Linge", + Description = "Pour les journées bs", + Hits = 0L, + ImageName = "$pantalon.jpg", + Price = 69.99m, + PromoPrice = 49.99m, + Quantity = 0L, + Sales = 0L, + Status = 1, + Title = "Pantalons slacks" + }, + new + { + Id = 20, + Category = "Linge", + Description = "Pour commencer à apprendre rust et utiliser linux", + Hits = 0L, + ImageName = "$thighs.jpg", + Price = 23.50m, + PromoPrice = 19.99m, + Quantity = 3L, + Sales = 0L, + Status = 4, + Title = "Programmer Socks" + }, + new + { + Id = 21, + Category = "Linge", + Description = "Show off que t'habites su'l plateau", + Hits = 0L, + ImageName = "$plateau.png", + Price = 149.99m, + PromoPrice = 99.99m, + Quantity = 14L, + Sales = 0L, + Status = 0, + Title = "Col-roulé" + }, + new + { + Id = 22, + Category = "Linge", + Description = "Ben oui je vais à l'UQAM comment t'as d'viné", + Hits = 0L, + ImageName = "$uqam.jpg", + Price = 149.99m, + PromoPrice = 99.99m, + Quantity = 4L, + Sales = 0L, + Status = 3, + Title = "Gros col-roulé" + }, + new + { + Id = 23, + Category = "Établissement", + Description = "Oui oui, une SAQ au complete", + Hits = 0L, + ImageName = "$saq.jpg", + Price = 1000000.99m, + PromoPrice = 999999.99m, + Quantity = 1L, + Sales = 0L, + Status = 0, + Title = "SAQ" + }, + new + { + Id = 24, + Category = "Texte", + Description = "Lorem ipsum dolor sit amet, \r\nconsectetur adipiscing elit. Vivamus sapien ipsum, \r\nconvallis quis justo ac, congue sollicitudin metus. \r\nVestibulum nec libero nulla. Integer a pretium dolor. \r\nPhasellus vulputate iaculis ligula, sit amet suscipit \r\ndiam condimentum eu. Suspendisse blandit ipsum sed porttitor volutpat.\r\nDuis iaculis mauris a dapibus bibendum. Integer sollicitudin nunc et neque\r\negestas sagittis. Etiam vitae ornare ex.", + Hits = 0L, + ImageName = "$lorem.jpg", + Price = 0.99m, + PromoPrice = 0.69m, + Quantity = 99L, + Sales = 0L, + Status = 4, + Title = "Lorem" + }, + new + { + Id = 25, + Category = "Homme", + Description = "Quand un vrai coûte trop cher", + Hits = 0L, + ImageName = "$bebe.jpg", + Price = 10.99m, + PromoPrice = 5.99m, + Quantity = 15L, + Sales = 0L, + Status = 0, + Title = "Bébé de laine" + }, + new + { + Id = 26, + Category = "Linge", + Description = "Un beau petit kit pas cher quand vous avez oublié le cadeau pour le shower qui s'en vient", + Hits = 0L, + ImageName = "$kitbebe.jpg", + Price = 39.99m, + PromoPrice = 29.99m, + Quantity = 10L, + Sales = 0L, + Status = 3, + Title = "Kit pour bébé" + }, + new + { + Id = 27, + Category = "Linge", + Description = "Chris Pratt aime ben sauter dessus", + Hits = 0L, + ImageName = "$koopa.jpg", + Price = 29.99m, + PromoPrice = 9.99m, + Quantity = 0L, + Sales = 0L, + Status = 5, + Title = "TORTUE" + }, + new + { + Id = 28, + Category = "Nourriture", + Description = "*ne pa manger", + Hits = 0L, + ImageName = "$potato.jpg", + Price = 1.99m, + PromoPrice = 0.99m, + Quantity = 58L, + Sales = 0L, + Status = 0, + Title = "Patate de laine" + }, + new + { + Id = 29, + Category = "Animal", + Description = "Les singes sont des mammifères de l'ordre des primates, généralement arboricoles, à la face souvent glabre et caractérisés par un encéphale développé et de longs membres terminés par des doigts. Bien que leur ressemblance avec l'Homme ait toujours frappé les esprits, la science a mis de nombreux siècles à prouver le lien étroit qui existe entre ceux-ci et l'espèce humaine.\r\n\r\nAu sein des primates, les singes forment un infra-ordre monophylétique, si l'on y inclut le genre Homo, nommé Simiiformes et qui se divise entre les Platyrhiniens (singes du Nouveau Monde : Amérique centrale et méridionale) et les Catarhiniens (singes de l'Ancien Monde : Afrique et Asie tropicales). Ces derniers comprennent les hominoïdes, également appelés « grands singes », dont fait partie Homo sapiens et ses ancêtres les plus proches.\r\n\r\nMême s'il ne fait plus de doute aujourd'hui que « l'Homme est un singe comme les autres », l'expression est majoritairement utilisée pour parler des animaux sauvages, et évoque un référentiel culturel, littéraire et artistique qui exclut l'espèce humaine.", + Hits = 0L, + ImageName = "$monke.png", + Price = 299.99m, + PromoPrice = 99.99m, + Quantity = 58L, + Sales = 0L, + Status = 0, + Title = "Monke :)" + }, + new + { + Id = 30, + Category = "Pokemon", + Description = "It evolves from Pichu when leveled up with high friendship and evolves into Raichu when exposed to a Thunder Stone.\r\n\r\nIn Alola, Pikachu will evolve into Alolan Raichu when exposed to a Thunder Stone.\r\n\r\nPikachu has a Gigantamax form. Pikachu with the Gigantamax Factor cannot evolve.\r\n\r\nIn Pokémon Yellow, the starter Pikachu will refuse to evolve into Raichu unless it is traded and evolved on another save file. In Pokémon: Let's Go, Pikachu!, the player's starter Pikachu also will not evolve, but cannot be traded to become a Raichu.\r\n\r\nPikachu is popularly known as the mascot of the Pokémon franchise and one of Nintendo's major mascots.\r\n\r\nIt is also the game mascot and starter Pokémon of Pokémon Yellow and Let's Go, Pikachu!. It has made numerous appearances on the boxes of spin-off titles.\r\n\r\nPikachu is also the starter Pokémon of Pokémon Rumble Blast and Pokémon Rumble World.", + Hits = 0L, + ImageName = "$pika.png", + Price = 3.99m, + PromoPrice = 2.99m, + Quantity = 69L, + Sales = 0L, + Status = 5, + Title = "Phat Pikachu" + }); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + + b.HasData( + new + { + Id = "c9e08b20-d8a5-473f-9f52-572eb23c12af", + ConcurrencyStamp = "e5b77c04-830f-4c19-ad44-6c9e5a508efb", + Name = "Administrateur", + NormalizedName = "ADMINISTRATEUR" + }, + new + { + Id = "1b7b9c55-c746-493a-a24f-3d5ca937298e", + ConcurrencyStamp = "8b05058e-1c97-4021-a485-6987e774c877", + Name = "Client", + NormalizedName = "CLIENT" + }); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + + b.HasData( + new + { + UserId = "ecf7503a-591c-454e-a824-048e10bd0474", + RoleId = "c9e08b20-d8a5-473f-9f52-572eb23c12af" + }, + new + { + UserId = "ecf7503a-591c-454e-a824-048e10bd0474", + RoleId = "1b7b9c55-c746-493a-a24f-3d5ca937298e" + }); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.AddressModel", b => + { + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", null) + .WithMany("Adresses") + .HasForeignKey("InventoryUserId"); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel", b => + { + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", "LinkedAccount") + .WithMany() + .HasForeignKey("LinkedAccountId"); + + b.HasOne("GrossesMitainesAPI.Models.AddressModel", "ShippingAddress") + .WithMany() + .HasForeignKey("ShippingAddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LinkedAccount"); + + b.Navigation("ShippingAddress"); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel+ProductInvoice", b => + { + b.HasOne("GrossesMitainesAPI.Models.InvoiceModel", null) + .WithMany("Products") + .HasForeignKey("InvoiceModelId"); + + b.HasOne("GrossesMitainesAPI.Models.ProductModel", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("GrossesMitainesAPI.Data.InventoryUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Data.InventoryUser", b => + { + b.Navigation("Adresses"); + }); + + modelBuilder.Entity("GrossesMitainesAPI.Models.InvoiceModel", b => + { + b.Navigation("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.cs new file mode 100644 index 0000000..19fad20 --- /dev/null +++ b/GrossesMitaines/GrossesMitainesAPI/Migrations/20221108033526_nonUserInvoice.cs @@ -0,0 +1,158 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GrossesMitainesAPI.Migrations +{ + public partial class nonUserInvoice : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.InsertData( + table: "Addresses", + columns: new[] { "Id", "Appartment", "City", "CivicNumber", "Country", "InventoryUserId", "PostalCode", "Province", "Street" }, + values: new object[] { 2, null, "Saint-Jérôme", 420, "Canada", null, "H0H0H0", "QC", "Rue MikeWard" }); + + migrationBuilder.UpdateData( + table: "AspNetRoles", + keyColumn: "Id", + keyValue: "1b7b9c55-c746-493a-a24f-3d5ca937298e", + column: "ConcurrencyStamp", + value: "8b05058e-1c97-4021-a485-6987e774c877"); + + migrationBuilder.UpdateData( + table: "AspNetRoles", + keyColumn: "Id", + keyValue: "c9e08b20-d8a5-473f-9f52-572eb23c12af", + column: "ConcurrencyStamp", + value: "e5b77c04-830f-4c19-ad44-6c9e5a508efb"); + + migrationBuilder.UpdateData( + table: "AspNetUsers", + keyColumn: "Id", + keyValue: "ecf7503a-591c-454e-a824-048e10bd0474", + columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" }, + values: new object[] { "af3a641d-8fe8-45c3-8e36-fdfbef10659a", "AQAAAAEAACcQAAAAEL/k0+c61dX1YPgqHrr6wmVSZNJzoqveJzr8IxjVSSL3W+GSsqOXft+hVLXozCnqVg==", "8ac35276-f8dc-4de4-826f-ea2996e09f2c" }); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 1, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6619)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 2, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6655)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 3, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6658)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 4, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6659)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 5, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6661)); + + migrationBuilder.InsertData( + table: "Invoices", + columns: new[] { "Id", "EmailAddress", "FirstName", "LastName", "LinkedAccountId", "PhoneNumber", "PurchaseDate", "ShippingAddressId", "Status" }, + values: new object[] { 6, "test@admin.com", "Jérémy", "Le Petit", null, "111-111-1111", new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6663), 2, 0 }); + + migrationBuilder.InsertData( + table: "ProductInvoice", + columns: new[] { "Id", "InvoiceModelId", "ProductId", "Quantity" }, + values: new object[] { 16, 6, 20, 4L }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "ProductInvoice", + keyColumn: "Id", + keyValue: 16); + + migrationBuilder.DeleteData( + table: "Invoices", + keyColumn: "Id", + keyValue: 6); + + migrationBuilder.DeleteData( + table: "Addresses", + keyColumn: "Id", + keyValue: 2); + + migrationBuilder.UpdateData( + table: "AspNetRoles", + keyColumn: "Id", + keyValue: "1b7b9c55-c746-493a-a24f-3d5ca937298e", + column: "ConcurrencyStamp", + value: "664e61a9-f77d-46ee-805c-98084e8b2fcb"); + + migrationBuilder.UpdateData( + table: "AspNetRoles", + keyColumn: "Id", + keyValue: "c9e08b20-d8a5-473f-9f52-572eb23c12af", + column: "ConcurrencyStamp", + value: "3b41186e-cc4b-49c0-b172-4c2b9be614d2"); + + migrationBuilder.UpdateData( + table: "AspNetUsers", + keyColumn: "Id", + keyValue: "ecf7503a-591c-454e-a824-048e10bd0474", + columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" }, + values: new object[] { "55f4780c-49dd-44ea-b566-30d058c0005b", "AQAAAAEAACcQAAAAEK/n6j8ui+ZivXKUi2Lv6Jr7wXBJQdOdXawkvVDBlr4Rnxc7DxsuWwaaX5vN3YSjmQ==", "e3f2e569-fb52-49af-b9bc-10bf8df2b778" }); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 1, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1206)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 2, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1244)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 3, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1247)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 4, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1249)); + + migrationBuilder.UpdateData( + table: "Invoices", + keyColumn: "Id", + keyValue: 5, + column: "PurchaseDate", + value: new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1251)); + } + } +} diff --git a/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs b/GrossesMitaines/GrossesMitainesAPI/Migrations/InventoryContextModelSnapshot.cs index 55436a3..8b32c48 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 = "55f4780c-49dd-44ea-b566-30d058c0005b", + ConcurrencyStamp = "af3a641d-8fe8-45c3-8e36-fdfbef10659a", Email = "admin@admin.com", EmailConfirmed = false, FirstName = "Roger", @@ -109,9 +109,9 @@ namespace GrossesMitainesAPI.Migrations LockoutEnabled = false, NormalizedEmail = "ADMIN@ADMIN.COM", NormalizedUserName = "ADMIN", - PasswordHash = "AQAAAAEAACcQAAAAEK/n6j8ui+ZivXKUi2Lv6Jr7wXBJQdOdXawkvVDBlr4Rnxc7DxsuWwaaX5vN3YSjmQ==", + PasswordHash = "AQAAAAEAACcQAAAAEL/k0+c61dX1YPgqHrr6wmVSZNJzoqveJzr8IxjVSSL3W+GSsqOXft+hVLXozCnqVg==", PhoneNumberConfirmed = false, - SecurityStamp = "e3f2e569-fb52-49af-b9bc-10bf8df2b778", + SecurityStamp = "8ac35276-f8dc-4de4-826f-ea2996e09f2c", TwoFactorEnabled = false, UserName = "Admin" }); @@ -176,6 +176,16 @@ namespace GrossesMitainesAPI.Migrations PostalCode = "H0H0H0", Province = "QC", Street = "Rue Pierre-Falardeau" + }, + new + { + Id = 2, + City = "Saint-Jérôme", + CivicNumber = 420, + Country = "Canada", + PostalCode = "H0H0H0", + Province = "QC", + Street = "Rue MikeWard" }); }); @@ -234,7 +244,7 @@ namespace GrossesMitainesAPI.Migrations LastName = "Admin", LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", PhoneNumber = "111-111-1111", - PurchaseDate = new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1206), + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6619), ShippingAddressId = 1, Status = 0 }, @@ -246,7 +256,7 @@ namespace GrossesMitainesAPI.Migrations LastName = "Admin", LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", PhoneNumber = "111-111-1111", - PurchaseDate = new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1244), + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6655), ShippingAddressId = 1, Status = 1 }, @@ -258,7 +268,7 @@ namespace GrossesMitainesAPI.Migrations LastName = "Admin", LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", PhoneNumber = "111-111-1111", - PurchaseDate = new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1247), + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6658), ShippingAddressId = 1, Status = 3 }, @@ -270,7 +280,7 @@ namespace GrossesMitainesAPI.Migrations LastName = "Admin", LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", PhoneNumber = "111-111-1111", - PurchaseDate = new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1249), + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6659), ShippingAddressId = 1, Status = 4 }, @@ -282,9 +292,20 @@ namespace GrossesMitainesAPI.Migrations LastName = "Admin", LinkedAccountId = "ecf7503a-591c-454e-a824-048e10bd0474", PhoneNumber = "111-111-1111", - PurchaseDate = new DateTime(2022, 11, 7, 22, 8, 27, 792, DateTimeKind.Local).AddTicks(1251), + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6661), ShippingAddressId = 1, Status = 5 + }, + new + { + Id = 6, + EmailAddress = "test@admin.com", + FirstName = "Jérémy", + LastName = "Le Petit", + PhoneNumber = "111-111-1111", + PurchaseDate = new DateTime(2022, 11, 7, 22, 35, 25, 783, DateTimeKind.Local).AddTicks(6663), + ShippingAddressId = 2, + Status = 0 }); }); @@ -418,6 +439,13 @@ namespace GrossesMitainesAPI.Migrations InvoiceModelId = 5, ProductId = 15, Quantity = 2L + }, + new + { + Id = 16, + InvoiceModelId = 6, + ProductId = 20, + Quantity = 4L }); }); @@ -926,14 +954,14 @@ namespace GrossesMitainesAPI.Migrations new { Id = "c9e08b20-d8a5-473f-9f52-572eb23c12af", - ConcurrencyStamp = "3b41186e-cc4b-49c0-b172-4c2b9be614d2", + ConcurrencyStamp = "e5b77c04-830f-4c19-ad44-6c9e5a508efb", Name = "Administrateur", NormalizedName = "ADMINISTRATEUR" }, new { Id = "1b7b9c55-c746-493a-a24f-3d5ca937298e", - ConcurrencyStamp = "664e61a9-f77d-46ee-805c-98084e8b2fcb", + ConcurrencyStamp = "8b05058e-1c97-4021-a485-6987e774c877", Name = "Client", NormalizedName = "CLIENT" }); diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/InvoiceItem.js b/GrossesMitaines/grosses-mitaines-ui/src/components/InvoiceItem.js index c13bccd..3b940da 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/InvoiceItem.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/InvoiceItem.js @@ -2,7 +2,8 @@ const InvoiceItem = (invoice) => { return ( <> - Invoice Item +
+
); diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/MyInvoices.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/MyInvoices.js index 32f165f..ab961fb 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/MyInvoices.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/MyInvoices.js @@ -12,8 +12,14 @@ const MyInvoices = () => { mode: 'cors', credentials: 'include' }).then(async (response) => { - var json = await response.json(); - setInvoices(json); + if (response.ok) { + var json = await response.json(); + console.log(json); + setInvoices(json); + } + else{ + console.log("Erreur lors de la requête des invoices"); + } }); }, []);