fix purchase
This commit is contained in:
parent
f032fc0f44
commit
d498e507ff
@ -75,7 +75,7 @@ namespace HardwareShopContracts.BusinessLogicsContracts
|
||||
model.PurchaseStatus = PurchaseStatus.Выдан;
|
||||
model.DatePurchase = DateTime.Now;
|
||||
CheckModel(model, false);
|
||||
if (_purchaseStorage.Update(model) == null)
|
||||
if (_purchaseStorage.Update(model, false) == null)
|
||||
{
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
return false;
|
||||
|
@ -11,7 +11,7 @@ namespace HardwareShopContracts.StoragesContracts
|
||||
List<PurchaseViewModel> GetReportFilteredList(PurchaseSearchModel model);
|
||||
PurchaseViewModel? GetElement(PurchaseSearchModel model);
|
||||
PurchaseViewModel? Insert(PurchaseBindingModel model);
|
||||
PurchaseViewModel? Update(PurchaseBindingModel model);
|
||||
PurchaseViewModel? Update(PurchaseBindingModel model, bool withParams = true);
|
||||
PurchaseViewModel? Delete(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Update(PurchaseBindingModel model)
|
||||
public PurchaseViewModel? Update(PurchaseBindingModel model, bool withParams = true)
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
@ -117,7 +117,11 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
}
|
||||
purchase.Update(model);
|
||||
context.SaveChanges();
|
||||
purchase.UpdateGoods(context, model);
|
||||
if (!withParams) {
|
||||
transaction.Commit();
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
purchase.UpdateGoods(context, model);
|
||||
transaction.Commit();
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using HardwareShopContracts.BusinessLogicsContracts;
|
||||
using HardwareShopContracts.SearchModels;
|
||||
using HardwareShopContracts.ViewModels;
|
||||
using HardwareShopDatabaseImplement.Models.Storekeeper;
|
||||
using HardwareShopDataModels.Enums;
|
||||
using HardwareShopDataModels.Models;
|
||||
using HardwareShopRestApi.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -59,8 +60,7 @@ namespace HardwareShopRestApi.Controllers
|
||||
{
|
||||
for (int i = 0; i < model.PurchaseGoodsCounts.Count; i++)
|
||||
{
|
||||
model.PurchaseGoods.Add(model.ListPurchaseGoods[i].Id,
|
||||
(model.ListPurchaseGoods[i] as IGoodModel, model.PurchaseGoodsCounts[i]));
|
||||
model.PurchaseGoods.Add(model.ListPurchaseGoods[i].Id,(model.ListPurchaseGoods[i] as IGoodModel, model.PurchaseGoodsCounts[i]));
|
||||
}
|
||||
_purchaseLogic.Create(model);
|
||||
}
|
||||
@ -76,6 +76,10 @@ namespace HardwareShopRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var oldModel = _purchaseLogic.ReadElement(new() {
|
||||
Id = model.Id,
|
||||
});
|
||||
model.Sum = oldModel.Sum;
|
||||
_purchaseLogic.DeliveryPurchase(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -106,7 +106,7 @@
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
"Sum": parseFloat(totalSum.value),
|
||||
"ListPurchaseGoods": goods
|
||||
"ListPurchaseGoods": goods, "PurchaseGoodsCounts": counts
|
||||
})
|
||||
}
|
||||
).done(() => window.location.href = '/Home/Purchases')
|
||||
|
Loading…
Reference in New Issue
Block a user