react-version #1
@ -118,7 +118,7 @@ public class InvoiceController : Controller {
|
||||
var prodcom = sinv.ProdQuant;
|
||||
Dictionary<int, uint> badprods = new();
|
||||
List<ProductModel> prods;
|
||||
InvoiceModel inv = new() {
|
||||
InvoiceModel inv = new() { // Populer les champs d'un invoice
|
||||
FirstName = sinv.FirstName,
|
||||
LastName = sinv.LastName,
|
||||
EmailAddress = sinv.EmailAddress,
|
||||
@ -131,14 +131,14 @@ public class InvoiceController : Controller {
|
||||
|
||||
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();
|
||||
} catch (Exception e) {
|
||||
_logger.LogError(8, e.Message);
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
foreach (var prod in prods) {
|
||||
foreach (var prod in prods) { // Les ajouter au invoice.
|
||||
inv.Products.Add(new() {
|
||||
Product = prod,
|
||||
Quantity = sinv.ProdQuant.First(x => x.Key == prod.Id).Value
|
||||
@ -198,14 +198,15 @@ public class InvoiceController : Controller {
|
||||
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;
|
||||
ad = _context.Addresses.FirstOrDefault(x => x.CivicNumber == sinv.CivicNumber &&
|
||||
x.Appartment == sinv.Appartment &&
|
||||
x.Street == sinv.Street &&
|
||||
x.City == sinv.City &&
|
||||
x.Province == sinv.Province &&
|
||||
x.Country == sinv.Country) ??
|
||||
x.Country == sinv.Country /*&&
|
||||
user.Result.Adresses.Contains(x)*/) ??
|
||||
new() {
|
||||
CivicNumber = sinv.CivicNumber,
|
||||
Appartment = sinv.Appartment,
|
||||
|
Loading…
Reference in New Issue
Block a user