public AUProductOverviewModel() { ProductPrice = new ProductPriceModel(); DefaultPictureModel = new PictureModel(); SpecificationAttributeModels = new List<ProductSpecificationModel>(); ReviewOverviewModel = new ProductReviewOverviewModel(); LotBidEntryModel = new AULotBidEntryModel(); }
public AUProductDetailsModel() { DefaultPictureModel = new PictureModel(); PictureModels = new List<PictureModel>(); GiftCard = new GiftCardModel(); ProductPrice = new ProductPriceModel(); AddToCart = new AddToCartModel(); ProductAttributes = new List<ProductAttributeModel>(); AssociatedProducts = new List<AUProductDetailsModel>(); VendorModel = new VendorBriefInfoModel(); Breadcrumb = new ProductBreadcrumbModel(); ProductTags = new List<ProductTagModel>(); ProductSpecifications= new List<ProductSpecificationModel>(); ProductManufacturers = new List<ManufacturerModel>(); ProductReviewOverview = new ProductReviewOverviewModel(); TierPrices = new List<TierPriceModel>(); LotBidEntry = new AULotBidEntryModel(); //NJM: AUConsignor }
public virtual AULotBidEntryModel GetLotBidEntryModel(int productId) { var model = new AULotBidEntryModel(); var lot = GetLotByProductId(productId); //if (lot != null) null not working when subroutine crete new if (lot.AULotID != 0) //only do this if lot is associated. Note - if store is auction site and lot not associated we have an issue logged above { //TODO THIS SHOULD NOT BE DONE FOR LISTS SO DO IN THE CONTROLLER //_workContext.CurrentProductId = productId; //var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer(); //record.CreatedBy = CurrentCustomer.Username; //record.UpdatedBy = CurrentCustomer.Username; model.ProductIsLot = true; model.ProductId = lot.AUProductID; model.AULotId = lot.AULotID; model.OpeningBidAmt = lot.OpeningBidAmt; model.ReserveAmt = lot.ReserveAmt; model.LastBidAmt = lot.LastBidAmt; model.LastBidderId = lot.LastBidId; model.LastBidDateTime = lot.LastBidDateTime; model.BidPostDateTime = lot.BidPostDateTime; //NJM: you are only using email, not user name because they can change their user name //see: http://docs.nopcommerce.com/display/nc/Customer+Settings model.NewBidderId = _workContext.CurrentCustomer.Id; model.NewBidderUsername = _workContext.CurrentCustomer.Email; model.LotNbr = lot.LotNbr; model.SaleEndDateTime = lot.SaleEndDateTime; model.AUSaleNbr = lot.AUSaleNbr; model.SaleTitle = lot.AUSaleNbr + " " + lot.SaleTitle; model.LotDispensation = lot.LotDispensation; model.AUSaleID = lot.AUSaleID; model.SaleStoreID = lot.SaleStoreID; model.BiddingIsOpen = false; switch (lot.LotDispensation) { case "PUBACTSALETOYOU": model.LotDispensationDescription = "You are currently the high bidder for this lot"; //reserve has been met model.BiddingIsOpen = true; break; case "PUBACTSALETOYOU-RSVNOMET": model.LotDispensationDescription = "You are currently the high bidder for this lot but the reserve has not been met"; model.BiddingIsOpen = true; break; case "PUBACTSALETOOTHER": model.LotDispensationDescription = "Someone else is currently high bidder for this lot"; model.BiddingIsOpen = true; break; case "PUBACTSALETOOTHER-RSVNOMET": model.LotDispensationDescription = "Someone else is currently high bidder for this lot but the reserve has not been met"; model.BiddingIsOpen = true; break; case "PUBACTSALE": model.LotDispensationDescription = "Be the first to bid!"; break; case "PUBSOLDTOYOU": model.LotDispensationDescription = "This lot was sold to you!"; model.BiddingIsOpen = true; break; case "PUBSOLDTOOTHER": model.LotDispensationDescription = "This lot was sold to someone else"; break; case "PUBNOSALE": model.LotDispensationDescription = "This lot is currently not in any sale. Please inquire for more information"; break; case "PUBUNSOLD": model.LotDispensationDescription = "This lot was previously offered but currently is not in any sale. Please inquire for more information"; break; case "PUBTOBESOLD": model.LotDispensationDescription = "This lot is scheduled to be offered in a future sale. Please inquire for more information"; break; case "GUESTSOLD": model.LotDispensationDescription = "This lot has already been sold"; break; case "GUEST": //they will be told to sign in to bid model.LotDispensationDescription = "Signin to bid!"; //message might be lot has bids and reserve met - signin to bid model.BiddingIsOpen = true; break; default: model.LotDispensationDescription = "Unknown Dispensation"; break; } //Use opening bid amount if no bids entered yet //TODO: BiddingIncrement is a really bad name for MinimumNextBidAmt if (lot.LotDispensation == "PUBACTSALE" || lot.LotDispensation == "PUBACTSALETOYOU" || lot.LotDispensation == "PUBACTSALETOOTHER" || lot.LotDispensation == "GUEST" || lot.LotDispensation == "PUBACTSALETOYOU-RSVNOMET" || lot.LotDispensation == "PUBACTSALETOOTHER-RSVNOMET") //should only need to get increments for active sale where at least one bid entered { if (lot.LastBidAmt == 0) { model.BiddingIncrement = lot.OpeningBidAmt; } else { //TODO: make this component var increments = GetSaleIncrements(lot.AUSaleID, lot.SaleStoreID); for (var i = 0; i < increments.Count; i++) { if (lot.LastBidAmt < (increments[i].ToBidAmt)) { model.BiddingIncrement = increments[i].IncrementAmt + lot.LastBidAmt; break; } } } } //TODO: how to hide lot/sale and othe bidding info ifsaleexpired - need ajax //TODO. note what is lofic when lot not associated to sale (lot/sale end = null) //TODO: only addincrement to last bid if bid entered - else what to show (starting bid?); //TODO: check to make sure increments were entered correctlt - if don't hit aything above //get the sale increments from cache - if not there build the cache //"AUConsignor.sale.increments-{0}-{1}-{2}" } else { model.ProductIsLot = false; } return model; }
public ActionResult AddBidToLot_Details(AULotBidEntryModel lot, string Origin, int productId = 0) { //bool isGuest = _workContext.CurrentCustomer.IsGuest(); //if (isGuest) //{ // return RedirectToRoute("Login"); // //Response.RedirectToRoute("Login"); // //Response.End(); //} var warnings = new List<string>(); //var lot = _AUcatalogService.GetLotByProductId(productId); //if (lot == null) // return Json(new // { // success = false, // message = "No product found with the specified ID" // }); //TODO: put delta test logic here to make sure noone updated underneath. Decided to build into sp instead. ////need to do this because defined as int? int saleid = lot.AUSaleID.GetValueOrDefault(); // works; defaults to 0M if x was null int salestoreid = lot.SaleStoreID.GetValueOrDefault(); // works; defaults to 0M if x was null if (productId == 0) { warnings.Add("We're sorry but your bid entry failed for technical reasons. Please try again"); } else { //TODO: should you get current user id or take it in as parameter //int result = _AUcatalogService.UpdateLotBid(saleid, salestoreid, productId, lot.NewBidAmt, lot.NewBidderId, lot.NewBidderUsername); int result = _lotService.UpdateLotBid(saleid, salestoreid, productId, lot.NewBidAmt, lot.NewBidderId, lot.BiddingIncrement, lot.ReserveAmt, Origin, null); //NJM: null bid entry DateTime so generates in stored proc //BiddingIncrement passed so stored proc can determine if max bid needed if (result == 99) //DB update error { warnings.Add("We're sorry but your bid entry failed for technical reasons. Please try again"); } else { if (result == 98) //bidder got underbid { warnings.Add("We're sorry but another bid was made while you were reviewing the product. Please try again"); } } } //NEW APPROACH //return PartialView("~/Views/Product/_AUConsignorEnterBid", lot ); //var query = from b in _bidhistoryRepo.Table // join s in _saleRepo.Table on b.AUSaleId equals s.AUSaleID // //where s.SaleEndDateTime != Convert.ToDateTime("01/01/0001") // where b.BidderId == lot.NewBidderId // group b by b.AUProductId // into bGroup // select bGroup; DateTime nullDate = Convert.ToDateTime("01/01/0001"); DateTime currTime = DateTime.UtcNow; //TODO: maybe just add to the html here to avoid db access var query = from b in _bidhistoryRepo.Table join s in _saleRepo.Table on b.AUSaleId equals s.AUSaleID where s.SaleIsPublished && s.SaleStartDateTime != nullDate && s.SaleEndDateTime != nullDate && s.SaleStartDateTime < currTime && s.SaleEndDateTime > currTime && b.BidderId == lot.NewBidderId //TODO: customer.Id?? see Headerlinks() group b by b.AUProductId into bGroup select bGroup; //display notification message and update appropriate blocks var updatetopmybidssectionhtml = string.Format(_localizationService.GetResource("Wishlist.HeaderQuantity"), query.ToList().Count()); if (warnings.Count > 0) { //cannot be added to the cart/wishlist //let's display warnings return Json(new { success = false, message = warnings.ToArray() }); } //TODO check to messaage if maximum generated return Json(new { success = true, message = string.Format(_localizationService.GetResource("Plugins.Misc.AUConsignor.Enterbid.Bidentered"), Url.RouteUrl("CompareProducts")), updatetopmybidssectionhtml = updatetopmybidssectionhtml, }); //return Json(new //{ // success = true, // //message = ("Bid has been entered", Url.RouteUrl("CompareProducts")) // message = string.Format(_localizationService.GetResource("Plugins.Misc.AUConsignor.Enterbid.Bidentered"), Url.RouteUrl("CompareProducts")) // //use the code below (commented) if you want a customer to be automatically redirected to the compare products page // //redirect = Url.RouteUrl("CompareProducts"), //}); }
public ActionResult RefreshLot_Details(int ProductId) { ModelState.Clear(); //NJM: this is needed to reset read-only razor field (see http://stackoverflow.com/questions/26062359/mvc-4-textbox-not-updating-on-postback) var lot = new AULotBidEntryModel(); //when made partial class //return RedirectToAction("Product", "person", new { personID = Person.personID }); ////var newlot = _AUcatalogService.GetLotByProductId(lot.ProductId); var newlot = _lotService.GetLotBidEntryModel(ProductId); lot.ProductIsLot = newlot.ProductIsLot; lot.AULotId = newlot.AULotId; lot.ProductId = newlot.ProductId; lot.LastBidAmt = newlot.LastBidAmt; //lot.LastBidderUID = newlot.LastBidUsername; lot.LastBidderId = newlot.LastBidderId; lot.LastBidDateTime = newlot.LastBidDateTime; lot.BidPostDateTime = newlot.BidPostDateTime; lot.NewBidAmt = 0; lot.ReserveAmt = newlot.ReserveAmt; //lot.NewBidderId = _workContext.CurrentCustomer.Id; //lot.NewBidderUsername = _workContext.CurrentCustomer.Username; lot.NewBidderId = newlot.NewBidderId; lot.NewBidderUsername = newlot.NewBidderUsername; lot.LotNbr = newlot.LotNbr; lot.SaleEndDateTime = newlot.SaleEndDateTime; lot.AUSaleNbr = newlot.AUSaleNbr; lot.SaleTitle = newlot.AUSaleNbr + " " + newlot.SaleTitle; lot.LotDispensation = newlot.LotDispensation; lot.LotDispensationDescription = newlot.LotDispensationDescription; lot.AUSaleID = newlot.AUSaleID; lot.SaleStoreID = newlot.SaleStoreID; //TODO: REFACTOR THIS TO BE A FUNCTION (ALSO IN ADDBIDTOLOT) //var increments = GetSaleIncrements(lot.AUSaleID, lot.SaleStoreID); //for (var i = 0; i < increments.Count; i++) //{ // //System.Console.WriteLine("{0}", list[i]); // if (lot.LastBidAmt < (increments[i].ToBidAmt)) // { // lot.BiddingIncrement = increments[i].IncrementAmt + lot.LastBidAmt; // break; // } //} lot.OpeningBidAmt = newlot.OpeningBidAmt; lot.BiddingIncrement = newlot.BiddingIncrement; //bool isGuest = _workContext.CurrentCustomer.IsGuest(); //if (isGuest) // ViewData["IsRegistered"] = false; //else // ViewData["IsRegistered"] = true; bool isGuest = _workContext.CurrentCustomer.IsGuest(); if (isGuest) ViewData["IsSignedOn"] = false; else ViewData["IsSignedOn"] = true; return PartialView("_AUConsignorBidInfo", lot); //return PartialView("Testview", lot); }