fxes improvements
This commit is contained in:
parent
cebe224395
commit
59a530ea55
|
|
@ -106,7 +106,15 @@ public class AuctionPluginAdminController : BasePluginController
|
|||
[HttpPost]
|
||||
public async Task<IActionResult> GetAuctionViewModel(AuctionViewModel viewModel)
|
||||
{
|
||||
viewModel.AuctionDto = new Domains.Dtos.AuctionDto();
|
||||
viewModel.AuctionDto.AuctionName = viewModel.AuctionName;
|
||||
viewModel.AuctionDto.AuctionType = viewModel.AuctionType;
|
||||
viewModel.AuctionDto.Closed = viewModel.Closed;
|
||||
viewModel.AuctionDto.StartDateUtc = viewModel.StartDateUtc;
|
||||
viewModel.AuctionDto.EndDateUtc = viewModel.EndDateUtc;
|
||||
var objOfAuctionDomain = viewModel.AuctionDto.CreateMainEntity();
|
||||
|
||||
|
||||
await _auctionService.InsertAuctionAsync(objOfAuctionDomain);
|
||||
|
||||
//if (viewModel.IsActive == true)
|
||||
|
|
@ -175,4 +183,33 @@ public class AuctionPluginAdminController : BasePluginController
|
|||
|
||||
return result != null ? Ok("Baaaazdmeeeeeeeeg") : StatusCode(500, "Error assigning product to auction.");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> GetAuctionById(int id)
|
||||
{
|
||||
var auction = await _auctionService.GetAuctionByIdAsync(id);
|
||||
if (auction == null)
|
||||
return NotFound();
|
||||
|
||||
return Json(new
|
||||
{
|
||||
id = auction.Id,
|
||||
auctionName = auction.AuctionName,
|
||||
startDateUtc = auction.StartDateUtc,
|
||||
closed = auction.Closed
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SaveAuction(Auction auction)
|
||||
{
|
||||
var dbAuction = await _auctionService.GetAuctionByIdAsync(auction.Id);
|
||||
if (auction != null)
|
||||
{
|
||||
dbAuction.AuctionName = auction.AuctionName;
|
||||
|
||||
dbAuction.Closed = auction.Closed;
|
||||
await _auctionService.UpdateAuctionAsync(auction);
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
|
|||
public string AuctionName { get; set; }
|
||||
public AuctionType AuctionType { get; set; }
|
||||
|
||||
public int? CategoryId { get; set; }
|
||||
|
||||
public DateTime StartDateUtc { get; set; }
|
||||
public DateTime? EndDateUtc { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,21 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-3" style="text-align:center;">
|
||||
|
||||
@Html.LabelFor(model => model.AuctionType)
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
|
||||
@Html.EditorFor(model => model.AuctionType)
|
||||
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-3" style="text-align:center;">
|
||||
|
||||
|
|
@ -63,6 +78,34 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-3" style="text-align:center;">
|
||||
|
||||
@Html.LabelFor(model => model.EndDateUtc)
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
@* <nop-editor asp-for="@Model.StartDateUtc" asp-template="DateTimePicker" /> *@
|
||||
@Html.EditorFor(model => model.EndDateUtc)
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-3" style="text-align:center;">
|
||||
|
||||
@Html.LabelFor(model => model.CategoryId)
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
@* <nop-editor asp-for="@Model.StartDateUtc" asp-template="DateTimePicker" /> *@
|
||||
@Html.EditorFor(model => model.CategoryId)
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-3" style="text-align:center;">
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<div class="content-header clearfix">
|
||||
<div class="pull-right">
|
||||
<a href="../GetAnnouncementViewModel" class="btn bg-blue">
|
||||
<a href="../AuctionPluginAdmin/GetAuctionViewModel" class="btn bg-blue">
|
||||
<i class="fa fa-floppy-o"></i>
|
||||
Add
|
||||
</a>
|
||||
|
|
@ -47,6 +47,12 @@
|
|||
{
|
||||
Title = "Closed",
|
||||
Width = "300"
|
||||
},
|
||||
new ColumnProperty(nameof(Auction.Id)) // Assuming Auction.Id exists
|
||||
{
|
||||
Title = "Actions",
|
||||
Render = new RenderCustom("renderEditButton"),
|
||||
Width = "100"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -59,3 +65,70 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="editAuctionModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Edit Auction</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editAuctionForm">
|
||||
<input type="hidden" name="Id" />
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
<input name="AuctionName" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Starts</label>
|
||||
<input name="StartDateUtc" type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Starts</label>
|
||||
<input name="EndDateUtc" type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Closed</label>
|
||||
<input name="Closed" type="checkbox" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveAuction()">Save</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function renderEditButton(data, type, row) {
|
||||
return `<button class="btn btn-primary btn-sm" onclick="openEditModal(${data})">
|
||||
<i class="fa fa-edit"></i> Edit
|
||||
</button>`;
|
||||
}
|
||||
|
||||
function openEditModal(auctionId) {
|
||||
// Fetch auction data via AJAX
|
||||
$.get(`/Admin/AuctionPluginAdmin/GetAuctionById/${auctionId}`, function (data) {
|
||||
$('#editAuctionModal input[name="Id"]').val(data.id);
|
||||
$('#editAuctionModal input[name="AuctionName"]').val(data.auctionName);
|
||||
$('#editAuctionModal input[name="StartDateUtc"]').val(data.startDateUtc);
|
||||
$('#editAuctionModal input[name="EndDateUtc"]').val(data.endDateUtc);
|
||||
$('#editAuctionModal input[name="Closed"]').prop('checked', data.closed);
|
||||
|
||||
$('#editAuctionModal').modal('show');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function saveAuction() {
|
||||
var formData = $('#editAuctionForm').serialize();
|
||||
console.log(formData);
|
||||
$.post('/Admin/AuctionPluginAdmin/SaveAuction', formData, function () {
|
||||
location.reload(); // Reload the grid after saving
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public static class AuctionDefaults
|
|||
public static string AnnouncementListRouteName => "Plugin.Misc.AuctionPlugin.AnnouncementList";
|
||||
public static string AuctionRouteName => "Plugin.Misc.AuctionPlugin.Auction";
|
||||
public static string AuctionListRouteName => "Plugin.Misc.AuctionPlugin.AuctionList";
|
||||
public static string GetAuctionByIdRouteName => "Plugin.Misc.AuctionPlugin.GetAuctionById";
|
||||
public static string SaveAuctionRouteName => "Plugin.Misc.AuctionPlugin.SaveAuction";
|
||||
public static string TestPageRouteName => "Plugin.Misc.AuctionPlugin.TestPage";
|
||||
public static string BidNotificationRouteName => "Plugin.Misc.AuctionPlugin.BidNotification";
|
||||
public static string RefreshAuctionWidgetRouteName => "Plugin.Misc.AuctionPlugin.RefreshAuctionWidget";
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class AuctionDto : IAuctionDto
|
|||
mainEntity.Id = Id;
|
||||
mainEntity.AuctionName = AuctionName;
|
||||
mainEntity.AuctionType = AuctionType;
|
||||
mainEntity.CategoryId = 0;
|
||||
mainEntity.StartDateUtc = StartDateUtc;
|
||||
mainEntity.EndDateUtc = EndDateUtc;
|
||||
mainEntity.Closed = Closed;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities
|
|||
public bool IsWinner { get; set; }
|
||||
public decimal BidPrice { get; set; }
|
||||
|
||||
public int AuctionId { get; set; }
|
||||
|
||||
[SkipValuesOnUpdate]
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
|||
|
||||
public interface IAuctionBid : IAuctionBidDtoBase, ITimeStampInfo//, ISoftRemoveEntityInt
|
||||
{
|
||||
|
||||
public int AuctionId { get; set; }
|
||||
}
|
||||
|
|
@ -38,6 +38,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
pattern: "Admin/AuctionPlugin/AuctionList",
|
||||
defaults: new { controller = "AuctionPluginAdmin", action = "AuctionList" });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.GetAuctionByIdRouteName,
|
||||
pattern: "Admin/AuctionPlugin/GetAuctionById/{auctionId}",
|
||||
defaults: new { controller = "AuctionPluginAdmin", action = "GetAuctionById" });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.SaveAuctionRouteName,
|
||||
pattern: "Admin/AuctionPlugin/SaveAuction",
|
||||
defaults: new { controller = "AuctionPluginAdmin", action = "SaveAuction" });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.TestPageRouteName,
|
||||
pattern: "Admin/Auction/TestPage",
|
||||
defaults: new { controller = "AuctionPluginAdmin", action = "TestPage" });
|
||||
|
|
|
|||
Loading…
Reference in New Issue