public ActionResult Cancel() { string bvin = SessionManager.GetCurrentPaymentPendingCartId(MTApp.CurrentStore); if (bvin.Trim().Length < 1) Response.Redirect("~/cart"); Order Basket = MTApp.OrderServices.Orders.FindForCurrentStore(bvin); if (Basket != null) { Basket.StatusCode = OrderStatusCode.Cancelled; Basket.StatusName = "Cancelled"; OrderNote n = new OrderNote(); n.IsPublic = true; n.Note = "Cancelled by Customer"; Basket.Notes.Add(n); MTApp.OrderServices.Orders.Update(Basket); SessionManager.SetCurrentPaymentPendingCartId(MTApp.CurrentStore, string.Empty); } return Redirect("~/cart"); }
protected void btnSubmit_Click(object sender, System.Web.UI.ImageClickEventArgs e) { this.MessageBox1.ClearMessage(); if (this.ValidateSelections() == true) { if (o != null) { SaveInfoToOrder(true); //we can't put this in "SaveInfoToOrder" because //that is called multiple times on the page OrderNote note = new OrderNote(); note.Note = InstructionsField.Text; note.IsPublic = false; o.Notes.Add(note); MTApp.OrderServices.Orders.Update(o); // Save as Order MerchantTribe.Commerce.BusinessRules.OrderTaskContext c = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp); c.UserId = string.Empty; // Use currently selected user for process new order context CustomerAccount u = GetSelectedUserAccount(); if (u != null) { if (u.Bvin != string.Empty) { c.UserId = u.Bvin; o.UserID = u.Bvin; } } c.Order = o; if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrder)) { Response.Redirect("ViewOrder.aspx?id=" + o.bvin); } else { // Show Errors string errorString = string.Empty; for (int i = 0; i <= c.Errors.Count - 1; i++) { errorString += c.Errors[i].Description + "<br />"; } if (errorString.Length > 0) { this.MessageBox1.ShowWarning(errorString); } } } } }
private void AddNote(string message, bool isPublic) { Order o = MTApp.OrderServices.Orders.FindForCurrentStore(this.BvinField.Value); OrderNote n = new OrderNote(); n.OrderID = this.BvinField.Value; n.IsPublic = isPublic; n.Note = message; o.Notes.Add(n); MTApp.OrderServices.Orders.Update(o); LoadOrder(); }
public void FromDTO(OrderDTO dto) { if (dto == null) return; this.AffiliateID = dto.AffiliateID ?? string.Empty; this.BillingAddress.FromDto(dto.BillingAddress); this.bvin = dto.Bvin ?? string.Empty; this.Coupons.Clear(); if (dto.Coupons != null) { foreach (OrderCouponDTO c in dto.Coupons) { OrderCoupon cp = new OrderCoupon(); cp.FromDto(c); this.Coupons.Add(cp); } } this.CustomProperties.Clear(); if (dto.CustomProperties != null) { foreach (CustomPropertyDTO prop in dto.CustomProperties) { CustomProperty p = new CustomProperty(); p.FromDto(prop); this.CustomProperties.Add(p); } } this.FraudScore = dto.FraudScore; this.Id = dto.Id; this.Instructions = dto.Instructions ?? string.Empty; this.IsPlaced = dto.IsPlaced; this.Items.Clear(); if (dto.Items != null) { foreach (LineItemDTO li in dto.Items) { LineItem l = new LineItem(); l.FromDto(li); this.Items.Add(l); } } this.LastUpdatedUtc = dto.LastUpdatedUtc; this.Notes.Clear(); if (dto.Notes != null) { foreach (OrderNoteDTO n in dto.Notes) { OrderNote nn = new OrderNote(); nn.FromDto(n); this.Notes.Add(nn); } } this.OrderDiscountDetails.Clear(); if (dto.OrderDiscountDetails != null) { foreach (DiscountDetailDTO d in dto.OrderDiscountDetails) { Marketing.DiscountDetail m = new Marketing.DiscountDetail(); m.FromDto(d); this.OrderDiscountDetails.Add(m); } } this.OrderNumber = dto.OrderNumber ?? string.Empty; this.Packages.Clear(); if (dto.Packages != null) { foreach (OrderPackageDTO pak in dto.Packages) { OrderPackage pak2 = new OrderPackage(); pak2.FromDto(pak); this.Packages.Add(pak2); } } this.PaymentStatus = (OrderPaymentStatus)((int)dto.PaymentStatus); this.ShippingAddress.FromDto(dto.ShippingAddress); this.ShippingDiscountDetails.Clear(); if (dto.ShippingDiscountDetails != null) { foreach (DiscountDetailDTO sd in dto.ShippingDiscountDetails) { Marketing.DiscountDetail sdd = new Marketing.DiscountDetail(); sdd.FromDto(sd); this.ShippingDiscountDetails.Add(sdd); } } this.ShippingMethodDisplayName = dto.ShippingMethodDisplayName ?? string.Empty; this.ShippingMethodId = dto.ShippingMethodId ?? string.Empty; this.ShippingProviderId = dto.ShippingProviderId ?? string.Empty; this.ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty; this.ShippingStatus = (OrderShippingStatus)((int)dto.ShippingStatus); this.StatusCode = dto.StatusCode ?? string.Empty; this.StatusName = dto.StatusName ?? string.Empty; this.StoreId = dto.StoreId; this.ThirdPartyOrderId = dto.ThirdPartyOrderId ?? string.Empty; this.TimeOfOrderUtc = dto.TimeOfOrderUtc; this.TotalHandling = dto.TotalHandling; this.TotalShippingBeforeDiscounts = dto.TotalShippingBeforeDiscounts; this.TotalTax = dto.TotalTax; this.TotalTax2 = dto.TotalTax2; this.UserEmail = dto.UserEmail ?? string.Empty; this.UserID = dto.UserID ?? string.Empty; }