improvements, fixes
This commit is contained in:
parent
0db7f7f342
commit
dd0d4f2097
|
|
@ -2,6 +2,8 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using AyCode.Services.Server.SignalRs;
|
||||
using AyCode.Services.SignalRs;
|
||||
using AyCode.Utils.Extensions;
|
||||
using FluentMigrator.Runner.Generators.Base;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
|
|
@ -225,10 +227,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
OrderStatusIds = orderStatuses,
|
||||
PaymentStatusIds = paymentStatuses,
|
||||
ShippingStatusIds = shippingStatuses,
|
||||
Length = 50,
|
||||
AvailablePageSizes = "20,50,100,500",
|
||||
SortColumn = "Id",
|
||||
SortColumnDirection = "desc",
|
||||
});
|
||||
|
||||
model.SetGridSort("Id", "desc");
|
||||
model.SetGridPageSize(50, "20,50,100,500");
|
||||
|
||||
return View("~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/List.cshtml", model);
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +244,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
public async Task<IActionResult> OrderList(OrderSearchModelExtended searchModel)
|
||||
{
|
||||
//prepare model
|
||||
//if (searchModel.SortColumn.IsNullOrWhiteSpace())
|
||||
//{
|
||||
// searchModel.SortColumn = "Id";
|
||||
// searchModel.SortColumnDirection = "desc";
|
||||
//}
|
||||
|
||||
var orderListModel = await GetOrderListModelByFilter(searchModel);
|
||||
//var orderListModel = new OrderListModel();
|
||||
|
||||
|
|
@ -294,19 +307,29 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
|
||||
public async Task<OrderListModelExtended> GetOrderListModelByFilter(OrderSearchModelExtended searchModel)
|
||||
{
|
||||
|
||||
var sortColumnIndex = Request.Form["order[0][column]"].FirstOrDefault();
|
||||
var sortDirection = Request.Form["order[0][dir]"].FirstOrDefault();
|
||||
|
||||
if (!string.IsNullOrEmpty(sortColumnIndex))
|
||||
//if (searchModel.SortColumn.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Get the column name from the column index
|
||||
var columnName = Request.Form[$"columns[{sortColumnIndex}][data]"].FirstOrDefault();
|
||||
var sortColumnIndex = Request.Form["order[0][column]"].FirstOrDefault();
|
||||
var sortDirection = Request.Form["order[0][dir]"].FirstOrDefault();
|
||||
|
||||
searchModel.SortColumn = columnName;
|
||||
searchModel.SortColumnDirection = sortDirection; // "asc" or "desc"
|
||||
if (!string.IsNullOrEmpty(sortColumnIndex))
|
||||
{
|
||||
// Get the column name from the column index
|
||||
var columnName = Request.Form[$"columns[{sortColumnIndex}][data]"].FirstOrDefault();
|
||||
|
||||
searchModel.SortColumn = columnName;
|
||||
|
||||
if(int.Parse(sortColumnIndex) > 0) searchModel.SortColumnDirection = sortDirection; // "asc" or "desc"
|
||||
else searchModel.SortColumnDirection = "desc";
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// searchModel.SortColumn = "Id";
|
||||
// searchModel.SortColumnDirection = "desc";
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// Get the paginated data
|
||||
var orderListModel = await _orderModelFactory.PrepareOrderListModelExtendedAsync(searchModel);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,5 +18,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.Order
|
|||
public string SortColumn { get; set; }
|
||||
public string SortColumnDirection { get; set; }
|
||||
|
||||
public void SetGridSort(string columnName, string columnDirection = "asc")
|
||||
{
|
||||
SortColumn = "Id";
|
||||
SortColumnDirection = columnDirection;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,14 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
return await ctx.ShippingItems.GetAll(true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItemsByDocumentId)]
|
||||
public async Task<List<ShippingItem>> GetShippingItemsByDocumentId(int shippingDocumentId)
|
||||
{
|
||||
_logger.Detail($"GetShippingItemsByDocumentId invoked");
|
||||
|
||||
return await ctx.ShippingItems.GetAllByShippingDocumentIdAsync(shippingDocumentId, true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItemById)]
|
||||
public async Task<ShippingItem> GetShippingItemById(int id)
|
||||
{
|
||||
|
|
@ -151,7 +159,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
_logger.Detail($"AddShippingItem invoked; id: {shippingItem.Id}");
|
||||
|
||||
if (!await ctx.AddShippingItemAsync(shippingItem)) return null;
|
||||
return await ctx.ShippingItems.GetByIdAsync(shippingItem.Id, shippingItem.ShippingDocument != null);
|
||||
return await ctx.ShippingItems.GetByIdAsync(shippingItem.Id, true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingItem)]
|
||||
|
|
|
|||
|
|
@ -227,10 +227,19 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
|
||||
if (productId > 0)
|
||||
{
|
||||
var productDto = await ProductDtos.GetByIdAsync(productId);
|
||||
shippingItem.IsMeasurable = productDto?.IsMeasurable ?? false;
|
||||
var productDto = await ProductDtos.GetByIdAsync(productId, true);
|
||||
|
||||
if (productDto != null)
|
||||
{
|
||||
shippingItem.IsMeasurable = productDto.IsMeasurable;
|
||||
shippingItem.Name = productDto.Name;
|
||||
}
|
||||
}
|
||||
|
||||
//IDEIGLENES, AMÍG NEM VEZETJÜK KI A shippingItem.Name-et!
|
||||
if (shippingItem.Name.IsNullOrEmpty() && !shippingItem.NameOnDocument.IsNullOrEmpty()) shippingItem.Name = shippingItem.NameOnDocument;
|
||||
else if (shippingItem.Name.IsNullOrEmpty()) shippingItem.Name = string.Empty;
|
||||
|
||||
await ShippingItems.InsertAsync(shippingItem);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -256,6 +265,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
throw new Exception($"shippingItem.ProductId > 0 && product == null; shippingItem.ProductId: {shippingItem.ProductId}");
|
||||
|
||||
productIsMeasurable = productDto.IsMeasurable;
|
||||
shippingItem.Name = productDto.Name;
|
||||
}
|
||||
|
||||
shippingItem.IsMeasurable = productIsMeasurable;
|
||||
|
|
|
|||
Loading…
Reference in New Issue