Compare commits
9 Commits
68a873f15d
...
15ac7a0771
| Author | SHA1 | Date |
|---|---|---|
|
|
15ac7a0771 | |
|
|
efe66eaa88 | |
|
|
568deb0131 | |
|
|
3abfc03d1e | |
|
|
fbad15e02f | |
|
|
268ec3f7f4 | |
|
|
d245c50890 | |
|
|
372a3d6b40 | |
|
|
dd985b94f4 |
|
|
@ -0,0 +1,251 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using AyCode.Services.SignalRs;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Loggers;
|
||||
using FruitBank.Common.Models;
|
||||
using FruitBank.Common.Server;
|
||||
using FruitBank.Common.SignalRs;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Models;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Customers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
using Nop.Services.Customers;
|
||||
using Nop.Services.Localization;
|
||||
using Nop.Web.Framework.Controllers;
|
||||
using NUglify.Helpers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||
{
|
||||
//https://linq2db.github.io/articles/sql/Join-Operators.html
|
||||
public class FruitBankDataController(
|
||||
FruitBankDbContext ctx,
|
||||
IWorkContext workContext,
|
||||
ICustomerService customerService,
|
||||
ICustomerRegistrationService customerRegistrationService,
|
||||
ILocalizationService localizationService,
|
||||
IEnumerable<IAcLogWriterBase> logWriters)
|
||||
: BasePluginController, IFruitBankDataControllerServer
|
||||
{
|
||||
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
||||
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringModels)]
|
||||
public async Task<List<MeasuringModel>> GetMeasuringModels()
|
||||
{
|
||||
throw new NotImplementedException("GetMeasuringModels");
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringModelByShippingId)]
|
||||
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||
{
|
||||
return await ctx.GetMeasuringModelByShippingId(shippingId).FirstOrDefaultAsync(c => true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPartners)]
|
||||
public async Task<List<Partner>> GetPartners()
|
||||
{
|
||||
_logger.Detail($"GetPartners invoked");
|
||||
|
||||
return await ctx.Partners.GetAll().ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPartnerById)]
|
||||
public async Task<Partner> GetPartnerById(int id)
|
||||
{
|
||||
_logger.Detail($"GetPartnerById invoked; id: {id}");
|
||||
|
||||
//var customers = await ctx.GetCustormersBySystemRoleName("Measuring").ToListAsync();
|
||||
//_logger.Error($"COUNT: {customers.Count}");
|
||||
|
||||
return await ctx.Partners.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdatePartner)]
|
||||
public async Task<Partner> UpdatePartner(Partner partner)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(partner);
|
||||
|
||||
_logger.Detail($"UpdatePartner invoked; id: {partner.Id}");
|
||||
|
||||
await ctx.Partners.UpdateAsync(partner);
|
||||
return partner;
|
||||
}
|
||||
|
||||
|
||||
[SignalR(SignalRTags.GetShippings)]
|
||||
public async Task<List<Shipping>> GetShippings()
|
||||
{
|
||||
_logger.Detail($"GetShippings invoked");
|
||||
|
||||
return await ctx.Shippings.GetAll(false).ToListAsync();
|
||||
//return await ctx.Shippings.Table.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetNotMeasuredShippings)]
|
||||
public async Task<List<Shipping>> GetNotMeasuredShippings()
|
||||
{
|
||||
_logger.Detail($"GetNotMeasuredShippings invoked");
|
||||
|
||||
return await ctx.Shippings.GetNotMeasured(true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingById)]
|
||||
public async Task<Shipping> GetShippingById(int id)
|
||||
{
|
||||
_logger.Detail($"GetShippingById invoked; id: {id}");
|
||||
|
||||
return await ctx.Shippings.GetByIdAsync(id, true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShipping)]
|
||||
public async Task<Shipping> UpdateShipping(Shipping shipping)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shipping);
|
||||
|
||||
_logger.Detail($"UpdateShipping invoked; id: {shipping.Id}");
|
||||
|
||||
await ctx.Shippings.UpdateAsync(shipping);
|
||||
return shipping;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItems)]
|
||||
public async Task<List<ShippingItem>> GetShippingItems()
|
||||
{
|
||||
_logger.Detail($"GetShippingItems invoked");
|
||||
|
||||
return await ctx.ShippingItems.GetAll().ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItemById)]
|
||||
public async Task<ShippingItem> GetShippingItemById(int id)
|
||||
{
|
||||
_logger.Detail($"GetShippingItemById invoked; id: {id}");
|
||||
|
||||
return await ctx.ShippingItems.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingItem)]
|
||||
public async Task<ShippingItem> UpdateShippingItem(ShippingItem shippingItem)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shippingItem);
|
||||
|
||||
_logger.Detail($"UpdateShippingItem invoked; id: {shippingItem.Id}");
|
||||
|
||||
await ctx.ShippingItems.UpdateAsync(shippingItem);
|
||||
return shippingItem;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingDocuments)]
|
||||
public async Task<List<ShippingDocument>> GetShippingDocuments()
|
||||
{
|
||||
_logger.Detail($"GetShippingDocuments invoked");
|
||||
|
||||
return await ctx.ShippingDocuments.GetAll().ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingDocumentById)]
|
||||
public async Task<ShippingDocument> GetShippingDocumentById(int id)
|
||||
{
|
||||
_logger.Detail($"GetShippingDocumentById invoked; id: {id}");
|
||||
|
||||
return await ctx.ShippingDocuments.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingDocument)]
|
||||
public async Task<ShippingDocument> UpdateShippingDocument(ShippingDocument shippingDocument)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shippingDocument);
|
||||
|
||||
_logger.Detail($"UpdateShippingDocument invoked; id: {shippingDocument.Id}");
|
||||
|
||||
await ctx.ShippingDocuments.UpdateAsync(shippingDocument);
|
||||
return shippingDocument;
|
||||
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringUsers)]
|
||||
public async Task<List<CustomerDto>> GetMeasuringUsers()
|
||||
{
|
||||
_logger.Detail($"GetMeasuringUsers invoked");
|
||||
|
||||
var customers = await ctx.GetCustormersBySystemRoleName(FruitBankConst.MeasuringRoleSystemName).Select(c => new CustomerDto(c)).ToListAsync();
|
||||
|
||||
return customers; //.ToModelDto<CustomerDto>();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetProductDtos)]
|
||||
public async Task<List<ProductDto>> GetProductDtos()
|
||||
{
|
||||
_logger.Detail($"GetProductDtos invoked");
|
||||
|
||||
return await ctx.GetProducts().Select(c => new ProductDto(c)).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.AuthenticateUser)]
|
||||
public async Task<MgLoginModelResponse> LoginMeasuringUser(MgLoginModelRequest loginModelRequest)
|
||||
{
|
||||
var customerEmail = loginModelRequest?.Email;
|
||||
var customerPassword = loginModelRequest?.Password;
|
||||
|
||||
_logger.Detail($"LoginMeasuringUser invoked; customerEmail; {customerEmail}");
|
||||
|
||||
var resultLoginModel = new MgLoginModelResponse();
|
||||
|
||||
if (!customerEmail.IsNullOrWhiteSpace() && !customerPassword.IsNullOrWhiteSpace())
|
||||
{
|
||||
var loginResult = await customerRegistrationService.ValidateCustomerAsync(customerEmail, customerPassword);
|
||||
|
||||
switch (loginResult)
|
||||
{
|
||||
case CustomerLoginResults.Successful:
|
||||
{
|
||||
var customer = await customerService.GetCustomerByEmailAsync(customerEmail);
|
||||
|
||||
var isInMeasuringRole = await customerService.IsInCustomerRoleAsync(customer, FruitBankConst.MeasuringRoleSystemName);
|
||||
if (!isInMeasuringRole)
|
||||
{
|
||||
resultLoginModel.ErrorMessage = "Is not in MeauringRole!";
|
||||
break;
|
||||
}
|
||||
|
||||
//var actionResult = await customerRegistrationService.SignInCustomerAsync(customer, returnUrl, loginModel.RememberMe);
|
||||
|
||||
//await _workContext.SetCurrentCustomerAsync(customer);
|
||||
//await _authenticationService.SignInAsync(customer, isPersist);
|
||||
////raise event
|
||||
//await _eventPublisher.PublishAsync(new CustomerLoggedinEvent(customer));
|
||||
|
||||
resultLoginModel.CustomerDto = new CustomerDto(customer); //customer.ToModel<CustomerDto>();
|
||||
break;
|
||||
}
|
||||
case CustomerLoginResults.CustomerNotExist:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials.CustomerNotExist");
|
||||
break;
|
||||
case CustomerLoginResults.Deleted:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials.Deleted");
|
||||
break;
|
||||
case CustomerLoginResults.NotActive:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials.NotActive");
|
||||
break;
|
||||
case CustomerLoginResults.NotRegistered:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials.NotRegistered");
|
||||
break;
|
||||
case CustomerLoginResults.LockedOut:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials.LockedOut");
|
||||
break;
|
||||
case CustomerLoginResults.WrongPassword:
|
||||
default:
|
||||
resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else resultLoginModel.ErrorMessage = await localizationService.GetResourceAsync("Account.Login.WrongCredentials");
|
||||
|
||||
if (!resultLoginModel.ErrorMessage.IsNullOrWhiteSpace()) _logger.Error($"{resultLoginModel.ErrorMessage}; email: {customerEmail}");
|
||||
return resultLoginModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
using FruitBank.Common.Models;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Customers;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
using Nop.Services.Catalog;
|
||||
using Nop.Services.Logging;
|
||||
using NUglify.Helpers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>, IShippingDbSet<ShippingDbTable>, IShippingItemDbSet<ShippingItemDbTable>, IShippingDocumentDbSet<ShippingDocumentDbTable>
|
||||
{
|
||||
private readonly IProductService _productService;
|
||||
private readonly IStaticCacheManager _staticCacheManager;
|
||||
|
||||
public PartnerDbTable Partners { get; set; }
|
||||
public ShippingDbTable Shippings { get; set; }
|
||||
public ShippingItemDbTable ShippingItems { get; set; }
|
||||
public ShippingDocumentDbTable ShippingDocuments { get; set; }
|
||||
|
||||
public IRepository<Product> Products { get; set; }
|
||||
public IRepository<Customer> Customers { get; set; }
|
||||
public IRepository<CustomerRole> CustomerRoles { get; set; }
|
||||
public IRepository<CustomerCustomerRoleMapping> CustomerRoleMappings { get; set; }
|
||||
|
||||
|
||||
public FruitBankDbContext(INopDataProvider dataProvider, PartnerDbTable partnerDbTable, ShippingDbTable shippingDbTable, ShippingItemDbTable shippingItemDbTable,
|
||||
ShippingDocumentDbTable shippingDocumentDbTable, IProductService productService, IStaticCacheManager staticCacheManager,
|
||||
IRepository<Product> productRepository,
|
||||
IRepository<Customer> customerRepository,
|
||||
IRepository<CustomerCustomerRoleMapping> customerCustomerRoleMappingRepository,
|
||||
IRepository<CustomerRole> customerRoleRepository,
|
||||
ILogger logger) : base(dataProvider, logger)
|
||||
{
|
||||
_productService = productService;
|
||||
_staticCacheManager = staticCacheManager;
|
||||
|
||||
Partners = partnerDbTable;
|
||||
Shippings = shippingDbTable;
|
||||
ShippingItems = shippingItemDbTable;
|
||||
ShippingDocuments = shippingDocumentDbTable;
|
||||
|
||||
Products = productRepository;
|
||||
Customers = customerRepository;
|
||||
CustomerRoles = customerRoleRepository;
|
||||
CustomerRoleMappings = customerCustomerRoleMappingRepository;
|
||||
}
|
||||
|
||||
public IQueryable<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||
{
|
||||
var query =
|
||||
from p in Partners.Table
|
||||
join s in Shippings.Table on p.Id equals s.PartnerId
|
||||
where s.Id == shippingId
|
||||
select new MeasuringModel(p.Name);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public IQueryable<Customer> GetCustormersBySystemRoleName(string systemRoleName)
|
||||
{
|
||||
if (systemRoleName.IsNullOrWhiteSpace()) throw new ArgumentException("systemRoleName.IsNullOrWhiteSpace()", nameof(systemRoleName));
|
||||
|
||||
var query =
|
||||
from c in Customers.Table
|
||||
join crm in CustomerRoleMappings.Table on c.Id equals crm.CustomerId
|
||||
join cr in CustomerRoles.Table on crm.CustomerRoleId equals cr.Id
|
||||
where c.Active && !c.Deleted && cr.SystemName == systemRoleName
|
||||
select c;
|
||||
|
||||
return query.Distinct().OrderBy(o => o.Username);
|
||||
}
|
||||
|
||||
public IQueryable<Product> GetProducts()
|
||||
=> Products.Table.Where(p => !p.Deleted).OrderBy(o => o.Name);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IPartnerDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<Partner>
|
||||
{
|
||||
public TDbTable Partners { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IShippingDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<Shipping>
|
||||
{
|
||||
public TDbTable Shippings { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IShippingDocumentDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<ShippingDocument>
|
||||
{
|
||||
public TDbTable ShippingDocuments { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IShippingItemDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<ShippingItem>
|
||||
{
|
||||
public TDbTable ShippingItems { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class PartnerDbTable : MgDbTableBase<Partner>
|
||||
{
|
||||
public PartnerDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//public IOrderedQueryable<AuctionBid> GetAllLastBidByAuctionId(int auctionId)
|
||||
//{
|
||||
// return GetAllByAuctionId(auctionId)
|
||||
// .OrderByDescending(x => x.Id)
|
||||
// .GroupBy(x => x.AuctionId, (_, bids) => bids.FirstOrDefault())
|
||||
// .OrderByDescending(percentGroup => percentGroup.Id);
|
||||
//}
|
||||
|
||||
//public IOrderedQueryable<AuctionBid> GetLastAuctionBidByProductToAuctionId(int productToAuctionId)
|
||||
// => GetAllByProductToAuctionId(productToAuctionId).OrderByDescending(x => x.Id);
|
||||
|
||||
//public Task<int> GetBidsCountByProductToAuctionIdAsync(int productToAuctionId)
|
||||
// => Table.CountAsync(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
|
||||
//public IQueryable<AuctionBid> GetAllByAuctionId(int auctionId)
|
||||
// => Table.Where(x => x.AuctionId == auctionId);
|
||||
|
||||
//public IQueryable<AuctionBid> GetAllByProductToAuctionId(int productToAuctionId)
|
||||
// => Table.Where(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
|
||||
//public Task<bool> HasBidByProductToAuctionIdAsync(int productToAuctionId)
|
||||
//{
|
||||
// return Table.AnyAsync(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
//}
|
||||
|
||||
//public async Task<AuctionBid> RevertByProductToAuctionIdAsync(int productToAuctionId)
|
||||
//{
|
||||
// var lastBid = await GetLastAuctionBidByProductToAuctionId(productToAuctionId).FirstOrDefaultAsync();
|
||||
// if (lastBid == null)
|
||||
// {
|
||||
// await Logger.InformationAsync($"AuctionBidDbTable.RevertByProductToAuctionIdAsync(); (lastBid == null); productToAuction.Id: {productToAuctionId}");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// await DeleteAsync(lastBid);
|
||||
// return await GetLastAuctionBidByProductToAuctionId(productToAuctionId).FirstOrDefaultAsync();
|
||||
//}
|
||||
|
||||
//public async Task<int> DeleteAllByProductToAuctionIdAsync(int productToAuctionId)
|
||||
//{
|
||||
// var deletedBids = await DeleteAsync(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
// await Logger.InformationAsync($"AuctionBidDbTable.DeleteAllByProductToAuctionIdAsync(); productToAuction.Id: {productToAuctionId}; deletedBids: {deletedBids}");
|
||||
|
||||
// return deletedBids;
|
||||
//}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class ShippingDbTable : MgDbTableBase<Shipping>
|
||||
{
|
||||
public ShippingDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<Shipping> GetAll()
|
||||
=> base.GetAll().OrderBy(s => s.ShippingDate);
|
||||
|
||||
public IQueryable<Shipping> GetAll(bool loadRelations)
|
||||
{
|
||||
return loadRelations
|
||||
? GetAll()
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems)
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(p => p.Partner)
|
||||
: GetAll();
|
||||
}
|
||||
|
||||
public IQueryable<Shipping> GetNotMeasured(bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(s => !s.IsAllMeasured);
|
||||
|
||||
|
||||
public Task<Shipping> GetByIdAsync(int id, bool loadRelations)
|
||||
=> GetAll(loadRelations).FirstOrDefaultAsync(s => s.Id == id);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class ShippingDocumentDbTable : MgDbTableBase<ShippingDocument>
|
||||
{
|
||||
public ShippingDocumentDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class ShippingItemDbTable : MgDbTableBase<ShippingItem>
|
||||
{
|
||||
public ShippingItemDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using FruitBank.Common.Server;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
|
|
@ -50,8 +51,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin
|
|||
// --- INSTALL ---
|
||||
public override async Task InstallAsync()
|
||||
{
|
||||
|
||||
// TODO: Add "NeedsToBeMeasured" product attribute if not exists
|
||||
//TODO: Add "Measuring" role - FruitBankConst.MeasuringRoleSystemName
|
||||
//TODO: Add "NeedsToBeMeasured" product attribute if not exists
|
||||
|
||||
// Default settings
|
||||
var settings = new OpenAiSettings
|
||||
|
|
|
|||
|
|
@ -2,18 +2,21 @@
|
|||
|
||||
using AyCode.Core.Loggers;
|
||||
using FruitBank.Common;
|
||||
using FruitBank.Common.Server.Controllers;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Server.Services.Loggers;
|
||||
using FruitBank.Common.Server.Services.SignalRs;
|
||||
using Mango.Nop.Core.Loggers;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nop.Core.Infrastructure;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Filters;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Catalog;
|
||||
using FruitBankDataController = Nop.Plugin.Misc.FruitBankPlugin.Controllers.FruitBankDataController;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
|
||||
|
||||
|
|
@ -31,24 +34,21 @@ public class PluginNopStartup : INopStartup
|
|||
options.ViewLocationExpanders.Add(new ViewLocationExpander());
|
||||
});
|
||||
|
||||
//services.AddCors(feature =>
|
||||
// feature.AddPolicy(
|
||||
// "AllowBlazorClient",
|
||||
// apiPolicy => apiPolicy
|
||||
// .WithOrigins("https://localhost:7144")
|
||||
// .AllowAnyHeader()
|
||||
// .AllowAnyMethod()
|
||||
// .AllowCredentials()
|
||||
// ));
|
||||
|
||||
services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);
|
||||
|
||||
//register services and interfaces
|
||||
|
||||
services.AddSingleton<LoggerToLoggerApiController>();
|
||||
|
||||
services.AddSingleton<IAcLogWriterBase, ConsoleLogWriter>();
|
||||
services.AddSingleton<IAcLogWriterBase, NopLogWriter>();
|
||||
services.AddSingleton<LoggerToLoggerApiController2>();
|
||||
//services.AddSingleton<SessionService>();
|
||||
services.AddScoped<FruitBankDataController>();
|
||||
|
||||
services.AddScoped<PartnerDbTable>();
|
||||
services.AddScoped<ShippingDbTable>();
|
||||
services.AddScoped<ShippingItemDbTable>();
|
||||
services.AddScoped<ShippingDocumentDbTable>();
|
||||
|
||||
services.AddScoped<FruitBankDbContext>();
|
||||
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
||||
|
||||
//services.AddScoped<CustomModelFactory, ICustomerModelFactory>();
|
||||
services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
|
||||
|
|
@ -59,6 +59,8 @@ public class PluginNopStartup : INopStartup
|
|||
{
|
||||
options.Filters.AddService<PendingMeasurementCheckoutFilter>();
|
||||
});
|
||||
|
||||
services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -82,7 +84,7 @@ public class PluginNopStartup : INopStartup
|
|||
{
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapHub<LoggerSignalRHub>(loggrHubEndPoint);
|
||||
endpoints.MapHub<LoggerSignalRHub2>(loggrHubEndPoint);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using Nop.Data.Mapping;
|
||||
using FruitBank.Common;
|
||||
using FruitBank.Common.Entities;
|
||||
using Nop.Data.Mapping;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Mapping;
|
||||
|
||||
|
|
@ -7,7 +9,14 @@ public partial class NameCompatibility : INameCompatibility
|
|||
/// <summary>
|
||||
/// Gets table name for mapping with the type
|
||||
/// </summary>
|
||||
public Dictionary<Type, string> TableNames => new();
|
||||
public Dictionary<Type, string> TableNames => new Dictionary<Type, string>
|
||||
{
|
||||
{ typeof(Partner), FruitBankConstClient.PartnerDbTableName },
|
||||
{ typeof(Shipping), FruitBankConstClient.ShippingDbTableName },
|
||||
{ typeof(ShippingItem), FruitBankConstClient.ShippingItemDbTableName},
|
||||
{ typeof(ShippingDocument), FruitBankConstClient.ShippingDocumentDbTableName },
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets column name for mapping with the entity's property and type
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\Presentation\Nop.Web\Nop.Web.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\FruitBank\Libraries\Nop.Services\Nop.Services.csproj" />
|
||||
<ProjectReference Include="..\..\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" />
|
||||
<ProjectReference Include="..\..\Libraries\Mango.Nop.Services\Mango.Nop.Services.csproj" />
|
||||
<ClearPluginAssemblies Include="$(SolutionDir)\Build\ClearPluginAssemblies.proj" />
|
||||
|
|
@ -52,6 +53,7 @@
|
|||
<Folder Include="Areas\Admin\Extensions\" />
|
||||
<Folder Include="Areas\Admin\Factories\" />
|
||||
<Folder Include="Areas\Admin\Validators\" />
|
||||
<Folder Include="Domains\Entities\" />
|
||||
<Folder Include="Extensions\" />
|
||||
<Folder Include="Factories\" />
|
||||
<Folder Include="Models\" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
using AyCode.Services.Server.SignalRs;
|
||||
using FruitBank.Common.Server.Services.Loggers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
|
||||
|
||||
public class LoggerSignalRHub2(LoggerToLoggerApiController2 logger) : AcLoggerSignalRHub<LoggerToLoggerApiController2>(logger)
|
||||
{ }
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using AyCode.Core.Enums;
|
||||
using AyCode.Core.Loggers;
|
||||
using FruitBank.Common.Loggers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
|
||||
public class LoggerToLoggerApiController2(IAcLogWriterBase[] logWriters) : Logger<LoggerToLoggerApiController2>(logWriters);
|
||||
Loading…
Reference in New Issue