react-version #1

Merged
memartel_loc merged 290 commits from react-version into main 2023-11-04 09:48:15 -04:00
Showing only changes of commit 94567c2395 - Show all commits

View File

@ -103,8 +103,8 @@ public class InvoiceController : Controller {
}
[HttpPost, AllowAnonymous]
public async Task<ActionResult<InvoiceModel>> Post(SendInvoiceModel sinv) {
var user = await _userMan.GetUserAsync(_signInMan.Context.User);
public ActionResult<InvoiceModel> Post(SendInvoiceModel sinv) {
var user = _userMan.GetUserAsync(_signInMan.Context.User);
var prodcom = sinv.ProdQuant;
Dictionary<int, uint> badprods = new();
List<ProductModel> prods;
@ -116,9 +116,10 @@ public class InvoiceController : Controller {
PurchaseDate = DateTime.Now
};
AddressModel ad;
user.Wait();
if (user is not null) {
inv.LinkedAccount = user;
if (user.Result is not null) {
inv.LinkedAccount = user.Result;
ad = _context.Addresses.FirstOrDefault(x => x.CivicNumber == sinv.CivicNumber &&
x.Appartment == sinv.Appartment &&
x.Street == sinv.Street &&
@ -175,6 +176,7 @@ public class InvoiceController : Controller {
return BadRequest(badprods.ToArray());
try { // Faire les updates dans la BD.
if (ad.Id == 0)
_context.Addresses.Add(ad);
_context.Invoices.Add(inv);
_context.Products.UpdateRange(prods);