Zoumbadouwow pif-pif

This commit is contained in:
MarcEricMartel 2022-12-08 18:39:20 -08:00
parent 41ddc7d0e3
commit 4facacb853

View File

@ -118,7 +118,7 @@ public class InvoiceController : Controller {
var prodcom = sinv.ProdQuant; var prodcom = sinv.ProdQuant;
Dictionary<int, uint> badprods = new(); Dictionary<int, uint> badprods = new();
List<ProductModel> prods; List<ProductModel> prods;
InvoiceModel inv = new() { InvoiceModel inv = new() { // Populer les champs d'un invoice
FirstName = sinv.FirstName, FirstName = sinv.FirstName,
LastName = sinv.LastName, LastName = sinv.LastName,
EmailAddress = sinv.EmailAddress, EmailAddress = sinv.EmailAddress,
@ -131,14 +131,14 @@ public class InvoiceController : Controller {
inv.Products = new(); inv.Products = new();
try { try { // Chercher les produits achetés dans la table de produits.
prods = _context.Products.Where(x => sinv.ProdQuant.Select(x => x.Key).Contains(x.Id)).ToList(); 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); _logger.LogError(8, e.Message);
return BadRequest(); return BadRequest();
} }
foreach (var prod in prods) { foreach (var prod in prods) { // Les ajouter au invoice.
inv.Products.Add(new() { inv.Products.Add(new() {
Product = prod, Product = prod,
Quantity = sinv.ProdQuant.First(x => x.Key == prod.Id).Value Quantity = sinv.ProdQuant.First(x => x.Key == prod.Id).Value
@ -198,14 +198,15 @@ public class InvoiceController : Controller {
return BadRequest(ex.Message); return BadRequest(ex.Message);
} }
if (user.Result is not null) { if (user.Result is not null) { // Gestion de l'adresse client.
inv.LinkedAccount = user.Result; inv.LinkedAccount = user.Result;
ad = _context.Addresses.FirstOrDefault(x => x.CivicNumber == sinv.CivicNumber && ad = _context.Addresses.FirstOrDefault(x => x.CivicNumber == sinv.CivicNumber &&
x.Appartment == sinv.Appartment && x.Appartment == sinv.Appartment &&
x.Street == sinv.Street && x.Street == sinv.Street &&
x.City == sinv.City && x.City == sinv.City &&
x.Province == sinv.Province && x.Province == sinv.Province &&
x.Country == sinv.Country) ?? x.Country == sinv.Country /*&&
user.Result.Adresses.Contains(x)*/) ??
new() { new() {
CivicNumber = sinv.CivicNumber, CivicNumber = sinv.CivicNumber,
Appartment = sinv.Appartment, Appartment = sinv.Appartment,