react-version #1
@ -103,8 +103,8 @@ public class InvoiceController : Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, AllowAnonymous]
|
[HttpPost, AllowAnonymous]
|
||||||
public async Task<ActionResult<InvoiceModel>> Post(SendInvoiceModel sinv) {
|
public ActionResult<InvoiceModel> Post(SendInvoiceModel sinv) {
|
||||||
var user = await _userMan.GetUserAsync(_signInMan.Context.User);
|
var user = _userMan.GetUserAsync(_signInMan.Context.User);
|
||||||
var prodcom = sinv.ProdQuant;
|
var prodcom = sinv.ProdQuant;
|
||||||
Dictionary<int, uint> badprods = new();
|
Dictionary<int, uint> badprods = new();
|
||||||
List<ProductModel> prods;
|
List<ProductModel> prods;
|
||||||
@ -116,9 +116,10 @@ public class InvoiceController : Controller {
|
|||||||
PurchaseDate = DateTime.Now
|
PurchaseDate = DateTime.Now
|
||||||
};
|
};
|
||||||
AddressModel ad;
|
AddressModel ad;
|
||||||
|
user.Wait();
|
||||||
|
|
||||||
if (user is not null) {
|
if (user.Result is not null) {
|
||||||
inv.LinkedAccount = user;
|
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 &&
|
||||||
@ -175,7 +176,8 @@ public class InvoiceController : Controller {
|
|||||||
return BadRequest(badprods.ToArray());
|
return BadRequest(badprods.ToArray());
|
||||||
|
|
||||||
try { // Faire les updates dans la BD.
|
try { // Faire les updates dans la BD.
|
||||||
_context.Addresses.Add(ad);
|
if (ad.Id == 0)
|
||||||
|
_context.Addresses.Add(ad);
|
||||||
_context.Invoices.Add(inv);
|
_context.Invoices.Add(inv);
|
||||||
_context.Products.UpdateRange(prods);
|
_context.Products.UpdateRange(prods);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
Loading…
Reference in New Issue
Block a user