public ActionResult Create(string returnUrl) { if (!_services.Authorizer.Authorize(Permissions.AddBid, T("Couldn't add bid"))) { return(this.RedirectLocal(returnUrl, "~/")); } var bid = _services.ContentManager.New <BidPart>("Bid"); var editorShape = _services.ContentManager.UpdateEditor(bid, this); if (ModelState.IsValid) { _services.ContentManager.Create(bid); var bidPart = bid.As <BidPart>(); // Check if bid is higher than others var heighestBid = _bidService.GetHeighestBid(bid.BidedOn); if (bidPart.BidPrice <= heighestBid.BidPrice && bidPart.Id != heighestBid.Id) { _services.TransactionManager.Cancel(); _notifier.Error(T("Bid must be higher than {0}", heighestBid.BidPrice.ToString("c"))); AddEditorShapeToTempData(editorShape); return(this.RedirectLocal(returnUrl, "~/")); } // Check if bid is higher than minimum bid var bidsPart = _bidService.GetContainer(bidPart); var minimumPrice = bidsPart.MinimumBidPrice; if (bidPart.BidPrice <= minimumPrice) { _services.TransactionManager.Cancel(); _notifier.Error(T("Bid must be higher than {0}", minimumPrice.ToString("c"))); AddEditorShapeToTempData(editorShape); return(this.RedirectLocal(returnUrl, "~/")); } // Ensure the bids are not closed on the container, as the html could have been tampered manually if (!_bidService.CanCreateBid(bidPart)) { _services.TransactionManager.Cancel(); return(this.RedirectLocal(returnUrl, "~/")); } _notifier.Information(T("Your Bid has been added.")); if (bidsPart.NotificationEmail) { _bidService.SendNotificationEmail(bidPart); } } else { // Used a comma instead of a point, or the other way around _notifier.Error(T("Invalid format")); _services.TransactionManager.Cancel(); AddEditorShapeToTempData(editorShape); } return(this.RedirectLocal(returnUrl, "~/")); }