Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Auction - remove IFormCollection
support9ed8443d85b6
diff --git a/src/Web/Grand.Web/Controllers/ActionCartController.cs b/src/Web/Grand.Web/Controllers/ActionCartController.csindex 644f3f420..b8bcd89b8 100644--- a/src/Web/Grand.Web/Controllers/ActionCartController.cs+++ b/src/Web/Grand.Web/Controllers/ActionCartController.cs@@ -13,6 +13,7 @@ using Grand.Web.Common.Filters;using Grand.Web.Extensions;using Grand.Web.Features.Models.Products;using Grand.Web.Features.Models.ShoppingCart;+using Grand.Web.Models.ShoppingCart;using MediatR;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc;@@ -608,8 +609,8 @@ namespace Grand.Web.Controllers#endregion}- [HttpPost]- public virtual async Task<IActionResult> AddBid(string productId, int shoppingCartTypeId, IFormCollection form,+ [HttpPost]+ public virtual async Task<IActionResult> AddBid(AddBidModel model,[FromServices] IAuctionService auctionService){var customer = _workContext.CurrentCustomer;@@ -621,19 +622,12 @@ namespace Grand.Web.Controllersmessage = _translationService.GetResource("ShoppingCart.Mustberegisteredtobid")});}- double bid = 0;- foreach (string formKey in form.Keys)- {- if (formKey.Equals(string.Format("auction_{0}.HighestBidValue", productId), StringComparison.OrdinalIgnoreCase))- {- double.TryParse(form[formKey], out bid);- if (bid == 0)- double.TryParse(form[formKey], NumberStyles.AllowDecimalPoint, CultureInfo.GetCultureInfo("en-US").NumberFormat, out bid);+ double.TryParse(model.HighestBidValue, out var bid);+ if (bid == 0)+ double.TryParse(model.HighestBidValue, NumberStyles.AllowDecimalPoint, CultureInfo.GetCultureInfo("en-US").NumberFormat, out bid);- bid = Math.Round(bid, 2);- break;- }- }+ bid = Math.Round(bid, 2);+if (bid <= 0){return Json(new@@ -643,7 +637,7 @@ namespace Grand.Web.Controllers});}- Product product = await _productService.GetProductById(productId);+ var product = await _productService.GetProductById(model.ProductId);if (product == null)throw new ArgumentNullException(nameof(product));@@ -656,7 +650,7 @@ namespace Grand.Web.Controllers});}- var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ? form["WarehouseId"].ToString() : _workContext.CurrentStore.DefaultWarehouseId;+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ? model.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId;var shoppingCartItem = new ShoppingCartItem {Attributes = new List<CustomAttribute>(),diff --git a/src/Web/Grand.Web/Models/ShoppingCart/AddBidModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/AddBidModel.csnew file mode 100644index 000000000..a30068e4e--- /dev/null+++ b/src/Web/Grand.Web/Models/ShoppingCart/AddBidModel.cs@@ -0,0 +1,8 @@+namespace Grand.Web.Models.ShoppingCart;++public record AddBidModel+{+ public string ProductId { get; set; }+ public string HighestBidValue { get; set; }+ public string WarehouseId { get; set; }+}\ No newline at end of filediff --git a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtmlindex e6bd48597..434a487fa 100644--- a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml+++ b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml@@ -32,7 +32,7 @@{<div class="btn-group w-100 mt-3"><input asp-for="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(System.Globalization.CultureInfo.InvariantCulture))" />- <button id="[email protected]" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" data-productid="@Model.Id" onclick="AxiosCart.addbid('@Url.RouteUrl("AddBid", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Auctions })', '#product-details-form'); return false;">+ <button id="[email protected]" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" data-productid="@Model.Id" onclick="AxiosCart.addbid('@Url.RouteUrl("AddBid", new { productId = Model.Id })', '#product-details-form'); return false;"><b-icon icon="hammer" class="mx-1"></b-icon><span>@Loc["ShoppingCart.Bid"]</span></button></div>diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtmlindex 8739dfe17..c9487e6e4 100644--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml@@ -159,9 +159,7 @@<!--auction-->@if (Model.ProductType == ProductType.Auction){- var dataDictAuction = new ViewDataDictionary(ViewData);- dataDictAuction.TemplateInfo.HtmlFieldPrefix = string.Format("auction_{0}", Model.Id);- <partial name="Partials/AuctionInfo" model="Model" view-data="dataDictAuction" />+ <partial name="Partials/AuctionInfo" model="Model" />}@{var dataDictAddToWishlist = new ViewDataDictionary(ViewData);diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AuctionInfo.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AuctionInfo.cshtmlindex 0cd692729..fe742288a 100644--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AuctionInfo.cshtml+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AuctionInfo.cshtml@@ -27,9 +27,9 @@</template><template v-if="new Date(PopupQuickViewVueModal.EndTime).getTime() > new Date().getTime()"><div class="input-group product-add-to-cart flex-nowrap">- <input :id="'auction_' + PopupQuickViewVueModal.Id + '_HighestBidValue'" :name="'auction_' + PopupQuickViewVueModal.Id + '.HighestBidValue'" type="number" class="form-control bid-input" :value="PopupQuickViewVueModal.HighestBidValue + 1" />+ <input :name="'HighestBidValue'" type="number" class="form-control bid-input" :value="PopupQuickViewVueModal.HighestBidValue + 1" /><div class="input-group-append">- <button :id="'bid-button-' + PopupQuickViewVueModal.Id" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" :data-productid="PopupQuickViewVueModal.Id" :onclick="'AxiosCart.addbid(`/addbid/AddBid/'+ PopupQuickViewVueModal.Id +'/3`, `#product-details-form`); return false;'">+ <button :id="'bid-button-' + PopupQuickViewVueModal.Id" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" :data-productid="PopupQuickViewVueModal.Id" :onclick="'AxiosCart.addbid(`/AddBid/'+ PopupQuickViewVueModal.Id +', `#product-details-form`); return false;'"><b-icon icon="hammer" class="mx-1"></b-icon><span>@Loc["ShoppingCart.Bid"]</span></button></div>