improvements, fixes, etc..
This commit is contained in:
parent
2ba5bbd01a
commit
357858c28f
|
|
@ -23,11 +23,11 @@ public class AuctionPluginAdminController : BasePluginController
|
|||
private readonly INotificationService _notificationService;
|
||||
private readonly ISettingService _settingService;
|
||||
private readonly AuctionSettings _auctionSettings;
|
||||
private readonly IAuctionService _auctionService;
|
||||
private readonly AuctionService _auctionService;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
//public AuctionPluginAdminController(SignalRservice signalRservice)
|
||||
public AuctionPluginAdminController(ILocalizationService localizationService, INotificationService notificationService, ISettingService settingService, AuctionSettings auctionSettings, ILogger logger, IAuctionService auctionService)
|
||||
public AuctionPluginAdminController(ILocalizationService localizationService, INotificationService notificationService, ISettingService settingService, AuctionSettings auctionSettings, ILogger logger, AuctionService auctionService)
|
||||
{
|
||||
_localizationService = localizationService;
|
||||
_notificationService = notificationService;
|
||||
|
|
@ -115,7 +115,9 @@ public class AuctionPluginAdminController : BasePluginController
|
|||
var model = new TestPageViewModel();
|
||||
|
||||
var auctions = await _auctionService.GetAllAuctionsAsync();
|
||||
model.Message = $"Teszt üzenet; Auctions count: {auctions.Count}";
|
||||
var auctionDtoWithProducts = await _auctionService.GetAuctionDtoWithProductByIdAsync(1, 4);
|
||||
|
||||
model.Message = $"Teszt üzenet; Auctions count: {auctions.Count}; Products count: {auctionDtoWithProducts.ProductToAuctionDtos.Count}";
|
||||
|
||||
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/TestPage.cshtml", model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Controllers;
|
|||
public class AuctionController : BasePluginController
|
||||
{
|
||||
|
||||
protected readonly IAuctionService _auctionService;
|
||||
protected readonly AuctionService _auctionService;
|
||||
protected readonly ILogger _logger;
|
||||
protected readonly IProductService _productService;
|
||||
protected readonly MyProductModelFactory _productModelFactory;
|
||||
|
||||
public AuctionController(IAuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory)
|
||||
public AuctionController(AuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory)
|
||||
{
|
||||
_auctionService = auctionService;
|
||||
_logger = logger;
|
||||
|
|
|
|||
|
|
@ -7,18 +7,21 @@ using System;
|
|||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||
|
||||
public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>, IAuctionBidDbSet<AuctionBidDbTable>
|
||||
public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>, IProductToAuctionDbSet<ProductToAuctionDbTable>, IAuctionBidDbSet<AuctionBidDbTable>
|
||||
{
|
||||
public AuctionDbTable Auctions { get; set; }
|
||||
public ProductToAuctionDbTable ProductToAuctions { get; set; }
|
||||
public AuctionBidDbTable AuctionBids { get; set; }
|
||||
|
||||
|
||||
//public EntityRepository<Auction> Auctions2 { get; set; }
|
||||
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
||||
|
||||
|
||||
public AuctionDbContext(INopDataProvider dataProvider, AuctionDbTable auctionDbTable, AuctionBidDbTable auctionBidDbTable) : base(dataProvider)
|
||||
public AuctionDbContext(INopDataProvider dataProvider, AuctionDbTable auctionDbTable, ProductToAuctionDbTable productToAuctionDbTable, AuctionBidDbTable auctionBidDbTable) : base(dataProvider)
|
||||
{
|
||||
Auctions = auctionDbTable;
|
||||
ProductToAuctions = productToAuctionDbTable;
|
||||
AuctionBids = auctionBidDbTable;
|
||||
|
||||
//Auctions.Table
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IProductToAuctionDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<ProductToAuctionMapping>
|
||||
{
|
||||
public TDbTable ProductToAuctions { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||
|
||||
public class ProductToAuctionDbTable: MgDbTableBase<ProductToAuctionMapping>
|
||||
{
|
||||
public ProductToAuctionDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
|
||||
{
|
||||
}
|
||||
|
||||
public IQueryable<ProductToAuctionMapping> GetByAuctionAndProductId(int auctionId, int productId)
|
||||
{
|
||||
return Table.Where(x => x.AuctionId == auctionId && x.ProductId == productId);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,44 @@
|
|||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
public class AuctionBidDto
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
|
||||
public class AuctionBidDto : IAuctionBidDto
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public int ProductAuctionMappingId { get; set; }
|
||||
public int CustomerId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public bool IsWinner { get; set; }
|
||||
public int BidPrice { get; set; }
|
||||
|
||||
|
||||
public AuctionBidDto()
|
||||
{
|
||||
}
|
||||
|
||||
public AuctionBidDto(AuctionBid auctionBid)
|
||||
{
|
||||
Id = auctionBid.Id;
|
||||
ProductAuctionMappingId = auctionBid.ProductAuctionMappingId;
|
||||
CustomerId = auctionBid.CustomerId;
|
||||
ProductId = auctionBid.ProductId;
|
||||
IsWinner = auctionBid.IsWinner;
|
||||
BidPrice = auctionBid.BidPrice;
|
||||
}
|
||||
|
||||
public AuctionBid CreateMainEntity()
|
||||
{
|
||||
var mainEntity = Activator.CreateInstance<AuctionBid>();
|
||||
|
||||
mainEntity.Id = Id;
|
||||
mainEntity.ProductAuctionMappingId = ProductAuctionMappingId;
|
||||
mainEntity.CustomerId = CustomerId;
|
||||
mainEntity.ProductId = ProductId;
|
||||
mainEntity.IsWinner = IsWinner;
|
||||
mainEntity.BidPrice = BidPrice;
|
||||
|
||||
|
||||
return mainEntity;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,45 @@
|
|||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
public class AuctionDto
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
|
||||
public class AuctionDto : IAuctionDto
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string AuctionName { get; set; }
|
||||
public AuctionType AuctionType { get; set; }
|
||||
public DateTime StartDateUtc { get; set; }
|
||||
public DateTime? EndDateUtc { get; set; }
|
||||
public bool Closed { get; set; }
|
||||
|
||||
public List<ProductToAuctionDto> ProductToAuctionDtos { get; } = [];
|
||||
|
||||
public AuctionDto()
|
||||
{
|
||||
}
|
||||
|
||||
public AuctionDto(Auction auction)
|
||||
{
|
||||
Id = auction.Id;
|
||||
AuctionName = auction.AuctionName;
|
||||
AuctionType = auction.AuctionType;
|
||||
StartDateUtc = auction.StartDateUtc;
|
||||
EndDateUtc = auction.EndDateUtc;
|
||||
Closed = auction.Closed;
|
||||
}
|
||||
|
||||
public Auction CreateMainEntity()
|
||||
{
|
||||
var mainEntity = Activator.CreateInstance<Auction>();
|
||||
|
||||
mainEntity.Id = Id;
|
||||
mainEntity.AuctionName = AuctionName;
|
||||
mainEntity.AuctionType = AuctionType;
|
||||
mainEntity.StartDateUtc = StartDateUtc;
|
||||
mainEntity.EndDateUtc = EndDateUtc;
|
||||
mainEntity.Closed = Closed;
|
||||
|
||||
return mainEntity;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
||||
public interface IAuctionBidDto : IAuctionBidDtoBase
|
||||
public interface IAuctionBidDto : IAuctionBidDtoBase, IMgModelDtoBase<AuctionBid>
|
||||
{
|
||||
//[NotMapped]
|
||||
//[NotColumn]
|
||||
public List<AuctionBid> AuctionBids { get; }
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
using AyCode.Interfaces;
|
||||
using AyCode.Interfaces.Server.Logins;
|
||||
using AyCode.Interfaces.Users.Dtos;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
||||
public interface IAuctionDto : IAuctionDtoBase
|
||||
public interface IAuctionDto : IAuctionDtoBase, IMgModelDtoBase<Auction>
|
||||
{
|
||||
//[NotMapped]
|
||||
//[NotColumn]
|
||||
public List<ProductToAuctionMapping> ProductToAuctionMappings { get; }
|
||||
public List<ProductToAuctionDto> ProductToAuctionDtos { get; }
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using AyCode.Interfaces;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
||||
public interface IProductToAuctionDto : IProductToAuctionDtoBase, IMgModelDtoBase<ProductToAuctionMapping>
|
||||
{
|
||||
public List<AuctionBidDto> AuctionBidDtos { get; }
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
||||
public interface IProductToAuctionDtoBase : IMgModelDtoBase
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
|
||||
public AuctionStatus AuctionStatus { get; set; }
|
||||
|
||||
public int StartingPrice { get; set; }
|
||||
public int BidPrice { get; set; }
|
||||
|
||||
public int BidAmount { get; set; }
|
||||
}
|
||||
|
|
@ -1,6 +1,49 @@
|
|||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
public class ProductToAuctionDto
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
|
||||
public class ProductToAuctionDto : IProductToAuctionDto
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
public AuctionStatus AuctionStatus { get; set; }
|
||||
public int StartingPrice { get; set; }
|
||||
public int BidPrice { get; set; }
|
||||
public int BidAmount { get; set; }
|
||||
|
||||
public List<AuctionBidDto> AuctionBidDtos { get; } = [];
|
||||
|
||||
|
||||
public ProductToAuctionDto()
|
||||
{
|
||||
}
|
||||
|
||||
public ProductToAuctionDto(ProductToAuctionMapping productToAuction)
|
||||
{
|
||||
Id = productToAuction.Id;
|
||||
ProductId = productToAuction.ProductId;
|
||||
AuctionId = productToAuction.AuctionId;
|
||||
AuctionStatus = productToAuction.AuctionStatus;
|
||||
StartingPrice = productToAuction.StartingPrice;
|
||||
BidPrice = productToAuction.BidPrice;
|
||||
BidAmount = productToAuction.BidAmount;
|
||||
}
|
||||
|
||||
public ProductToAuctionMapping CreateMainEntity()
|
||||
{
|
||||
var mainEntity = Activator.CreateInstance<ProductToAuctionMapping>();
|
||||
|
||||
mainEntity.Id = Id;
|
||||
mainEntity.ProductId = ProductId;
|
||||
mainEntity.AuctionId = AuctionId;
|
||||
mainEntity.AuctionStatus = AuctionStatus;
|
||||
mainEntity.StartingPrice = StartingPrice;
|
||||
mainEntity.BidPrice = BidPrice;
|
||||
mainEntity.BidAmount = BidAmount;
|
||||
|
||||
return mainEntity;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,8 @@ public partial class Auction: MgEntityBase, IAuction
|
|||
{
|
||||
public string AuctionName { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[NotColumn]
|
||||
public AuctionType AuctionType{ get; set; }
|
||||
|
||||
public DateTime StartDateUtc { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
||||
|
||||
public interface IProductToAuctionMapping : IProductToAuctionDtoBase, ITimeStampInfo //, ISoftRemoveEntityInt
|
||||
{
|
||||
}
|
||||
|
|
@ -1,18 +1,21 @@
|
|||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
using Nop.Core;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
public partial class ProductToAuctionMapping : MgEntityBase, ITimeStampInfo//, ISoftRemoveEntityInt
|
||||
public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMapping
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
|
||||
public AuctionStatus AuctionStatus { get; set; } = AuctionStatus.None;
|
||||
[NotMapped]
|
||||
[NotColumn]
|
||||
public AuctionStatus AuctionStatus { get; set; }
|
||||
|
||||
public int StartingPrice { get; set; }
|
||||
public int BidPrice { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using AyCode.Core.Extensions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
|
|
@ -6,6 +7,7 @@ using Microsoft.AspNetCore.Routing;
|
|||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Infrastructure;
|
||||
|
|
@ -51,15 +53,16 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
services.AddScoped<EventConsumer>();
|
||||
services.AddScoped<IWorkContext, WebWorkContext>();
|
||||
services.AddScoped<IAnnouncementService, AnnouncementService>();
|
||||
services.AddScoped<IAuctionService, AuctionService>();
|
||||
services.AddScoped<AuctionService>();
|
||||
services.AddScoped<IProductAttributeService, ProductAttributeService>();
|
||||
services.AddScoped<UrlHelperFactory>();
|
||||
services.AddScoped<IActionContextAccessor, ActionContextAccessor>();
|
||||
|
||||
services.AddScoped<AuctionDbTable>();
|
||||
services.AddScoped<ProductToAuctionDbTable>();
|
||||
services.AddScoped<AuctionBidDbTable>();
|
||||
services.AddScoped<AuctionDbContext>();
|
||||
|
||||
|
||||
services.AddScoped<MyProductModelFactory>();
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +71,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
/// </summary>
|
||||
/// <param name="application">Builder for configuring an application's request pipeline</param>
|
||||
public void Configure(IApplicationBuilder application)
|
||||
{
|
||||
{
|
||||
SerializeObjectExtensions.Options.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
|
||||
SerializeObjectExtensions.Options.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||
SerializeObjectExtensions.Options.NullValueHandling = NullValueHandling.Ignore;
|
||||
|
||||
application.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ProductToAuctionMappingBuilder : NopEntityBuilder<ProductToAuctionM
|
|||
.WithColumn(nameof(ProductToAuctionMapping.AuctionId)).AsInt32().ForeignKey<Auction>(onDelete: Rule.None) //Rule.Cascade??
|
||||
.WithColumn(nameof(ProductToAuctionMapping.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.None) //Rule.Cascade??
|
||||
|
||||
.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
||||
//.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
||||
|
||||
.WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable()
|
||||
.WithColumn(nameof(ProductToAuctionMapping.BidPrice)).AsInt32().NotNullable()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Nop.Core.Domain.Customers;
|
|||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
|
|
@ -41,7 +42,7 @@ public class AuctionService : IAuctionService
|
|||
/// <summary>
|
||||
/// Ctor
|
||||
/// </summary>
|
||||
/// <param name="customerBidRepository">Store pickup point repository</param>
|
||||
/// <param name="ctx"></param>
|
||||
/// <param name="shortTermCacheManager">Short term cache manager</param>
|
||||
/// <param name="staticCacheManager">Cache manager</param>
|
||||
public AuctionService(AuctionDbContext ctx, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, IWorkContext workContext)
|
||||
|
|
@ -62,8 +63,6 @@ public class AuctionService : IAuctionService
|
|||
private async Task<bool> ValidateAuctionBid(AuctionBid auctionBid)
|
||||
{
|
||||
auctionBid.CustomerId = (await _workContext.GetCurrentCustomerAsync()).Id; //elvileg megnézi cache-ben, csak utána DB-zik! - J.
|
||||
auctionBid.Modified = DateTime.UtcNow;
|
||||
|
||||
//etc...
|
||||
|
||||
return true;
|
||||
|
|
@ -145,8 +144,32 @@ public class AuctionService : IAuctionService
|
|||
//return (await _ctx.Auctions.GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default)).ToList();
|
||||
return [];
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Dtos
|
||||
public async Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId)
|
||||
{
|
||||
return new AuctionDto(await _ctx.Auctions.GetByIdAsync(auctionId));
|
||||
}
|
||||
|
||||
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId)
|
||||
{
|
||||
var auctionModel = new AuctionDto(await _ctx.Auctions.GetByIdAsync(auctionId));
|
||||
auctionModel.ProductToAuctionDtos.AddRange(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId).Select(x => new ProductToAuctionDto(x)).ToListAsync());
|
||||
|
||||
return auctionModel;
|
||||
}
|
||||
|
||||
public async Task<ProductToAuctionDto> GetProductToAuctionDtoByIdAsync(int productToAuctionId)
|
||||
{
|
||||
return new ProductToAuctionDto(await _ctx.ProductToAuctions.GetByIdAsync(productToAuctionId));
|
||||
}
|
||||
|
||||
public async Task<AuctionBidDto> GetAuctionBidDtoByIdAsync(int auctionBidId)
|
||||
{
|
||||
return new AuctionBidDto(await _ctx.AuctionBids.GetByIdAsync(auctionBidId));
|
||||
}
|
||||
|
||||
#endregion Dtos
|
||||
}
|
||||
Loading…
Reference in New Issue