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