public ActionResult ListBids(DataSourceRequest command, AUBidList model) { //if (lotId == 0) // return new NullJsonResult(); var bids = _lotService.GetBids( lotId: model.AULotId, saleId: model.SearchSaleId, storeId: model.SearchStoreId, userName: model.SearchUserName, pageIndex: 0, pageSize: 500); //if (activity == null) // return new NullJsonResult(); var gridModel = new DataSourceResult { Data = bids.Select(x => new { Id = x.Id, AULotId = x.AULotId, AUSaleId = x.AUSaleId, AUProductId = x.AUProductId, SaleStoreId = x.SaleStoreId, BidderId = x.BidderId, BidderUserName = x.BidderUserName, BidAmt = x.BidAmt, BidDateTime = x.BidDateTime }), Total = bids.TotalCount }; return Json(gridModel); }
// [HttpPost] grid is not posting // the grid passes in fields in the row schema as well as the form model //the grid schema can containmore fields than are displayed in the columns //AULotID comes from the schema //AUSaleID comes from the model public ActionResult DeleteBid(int Id, int AUSaleId, AUBidList model) { //TODO: AUTHORIZE //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedView(); //do not allow bids to be deleted in awarded sales. Bids can be deleted in closed sales that have not been awarded yet //use AUSaleId to get the sale and test this with new "closed" flag var bid = _bidhistoryRepo.GetById(Id); if (bid == null) { throw new NopException("Bid not found"); } //var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer(); //var currTime = System.DateTime.UtcNow; //string logError = ""; //int totalerrors = 0; //if (lot.IsLotSold || // (!lot.IsLotSold && model.SaleStartDateTime < currTime && model.SaleEndDateTime > currTime && lot.LastBidAmt != 0) || // (!lot.IsLotSold && model.SaleStartDateTime > currTime && model.SaleEndDateTime > currTime && lot.LastBidAmt != 0) // ) //{ // logError = string.Format("Remove Lot from Sale by user {2} : Can not remove this lot id# {0}/ Sku# {1} is sold or is in an active or future sale and has had bids", lot.AULotID, lot.Sku, CurrentCustomer.Username); // _logger.InsertLog(LogLevel.Error, logError); // totalerrors++; //} //else //{ //remove lot from to sale and record lot history for MOVE (RM if before sale closed, RH if after sale closed) _lotService.DeleteBid(bid); //} //if (productCategory == null) // throw new ArgumentException("No product category mapping found with the specified id"); ////var categoryId = productCategory.CategoryId; //_categoryService.DeleteProductCategory(productCategory); return new NullJsonResult(); }
//copied from C:\Users\Nicholas\Documents\My Documents\NopCommerce\Presentation\Nop.Web\Administration\Controllers\ProductController.cs public ActionResult ManageBidsForLot(int id = 0) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) // return View("~/Administration/Views/Security/AccessDenied.cshtml"); //a vendor should have access only to his products. Set the indicator in the model //model.IsLoggedInAsVendor = _workContext.CurrentVendor != null; var model = new AUBidList(); //the product may not have a lot associated to it yet - this should not happen if you check the store configuration //when consuming the Product edit tab (ProductEditConsumer), but leave it here anyway //TODO: you won't need to initialize these fields once you get rid of the null ass shit var lot = _consignorService.GetLotByProductId(id); if (lot != null) { model.AULotId = lot.AULotID; } else //TODO: the service nulls out the record - make so returns non-null no matter what? { model.AULotId = 0; } //NJM: Sales ---need only sales this lot has been in model.AvailableSales.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var sales = _lotService.GetSalesForLot( lotId: lot.AULotID, pageIndex: 0, pageSize: 2147483647); foreach (var c in sales) model.AvailableSales.Add(new SelectListItem { Text = c.AUSaleNbr, Value = c.AUSaleID.ToString() }); ////stores //model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //foreach (var s in _storeService.GetAllStores()) // model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); //warehouses model.AvailableBidders.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var bidder in _lotService.GetBiddersForLot(lotId: lot.AULotID, pageIndex: 0, pageSize: 2147483647)) model.AvailableBidders.Add(new SelectListItem { Text = bidder.BidderUserName, Value = bidder.BidderId.ToString() }); return View("~/Views/AUConsignor/ManageBids.cshtml", model); //return View("List.cshtml", model); }