public void Cancel(long orderLineId) { ChangeOrderLineStatus(orderLineId, OrderStatus.Canceled); OrderPayload orderPayload = _serviceUow.OrderService.GetOrderPayloadByOrderLineId(orderLineId); orderPayload.Verb = "canceled"; FirebaseService.FirebaseService.Instance.SendNotification(orderPayload); }
public void MarkAsIncompleted(long orderLineId) { var orderLine = ChangeOrderLineStatus(orderLineId, OrderStatus.Incompleted); _serviceUow.PaypalService.Refund(orderLineId); OrderPayload orderPayload = _serviceUow.OrderService.GetEventPlannerOrderPayloadByOrderLineId(orderLineId); orderPayload.Verb = "marked as incompleted"; FirebaseService.FirebaseService.Instance.SendNotification(orderPayload); }
public static void InitiateOrderProcess(msOrder targetOrder, OrderPayload payload) { if (targetOrder != null) { TransientShoppingCart = targetOrder; Payload = payload; HttpContext.Current.Response.Redirect("/orders/InitiateOrder.aspx?useTransient=true"); } else { HttpContext.Current.Response.Redirect("/orders/InitiateOrder.aspx"); } }
protected void MoveToOrderProcessing() { MultiStepWizards.PlaceAnOrder.ContinueShoppingUrl = "~/careercenter/SelectCareerCenterProduct.aspx"; //If the job posting details have already been specified then this is part of a larger workflow //and just complete the order as normal (the job posting will be saved since it's in the PlaceAnOrder.ObjectsToBeSaved collection) //Otherwise this is the start of the workflow and after the order direct the user to the page to enter job posting details. MultiStepWizards.PlaceAnOrder.OrderCompleteUrl = TransientJobPosting ? "~/careercenter/ConfirmJobPosting.aspx?post=true" : "~/careercenter/CreateEditJobPosting.aspx"; MultiStepWizards.PlaceAnOrder.ReloadEntityOnOrderComplete = true; var targetJobPosting = MultiStepWizards.PostAJob.JobPosting; var memo = targetJobPosting == null ? "Not available" : "Job posting '" + targetJobPosting.Name + "'"; var pl = new OrderPayload { EntitlementAdjustments = new List <OrderPayloadEntitlementAdjustments> { new OrderPayloadEntitlementAdjustments { EntityID = targetOrder.BillTo, EntitlementType = msJobPostingEntitlement.CLASS_NAME, AmountToAdjust = TransientJobPosting ? -1 : 0, Memo = memo } } }; if (targetJobPosting != null) { targetJobPosting.Order = "{OrderID}"; pl.ObjectsToSave = new List <MemberSuiteObject> { new MemberSuiteObject(targetJobPosting) }; } MultiStepWizards.PlaceAnOrder.InitiateOrderProcess(targetOrder, pl); }
private async System.Threading.Tasks.Task OnPayCommandAsync() { //Application.Current.MainPage.DisplayAlert("Payment", "Go to payment page", "OK"); try { if (Connectivity.NetworkAccess == NetworkAccess.Internet) { APIService aPIService = new APIService(); OrderPayload orderPayload = new OrderPayload(); // orderPayload.Id = DateTime.UtcNow.Ticks; orderPayload.Id = 1544012550; orderPayload.Total = App.ProductsInCart.Count; orderPayload.Details = new System.Collections.Generic.List <Detail>(); foreach (var product in App.ProductsInCart) { Detail detail = new Detail { Barcode = product.ScannedBarcode, Title = product.title, Price = 13499, Quantity = 1, Type = product.DeliveryType == DeliveryType.TakeAway ? "TAKEAWAY" : "DELIVERY", Product = "wLmX1iO821MPZBuf88Qd" }; orderPayload.Details.Add(detail); } var result = await aPIService.PostOrder(orderPayload); await Application.Current.MainPage.Navigation.PushAsync(new PaymentBarcodePageView { BindingContext = new PaymentBarcodePageViewModel(orderPayload.Id.ToString()) { } }); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void MarkAsCompleted(long orderLineId) { var orderLine = ChangeOrderLineStatus(orderLineId, OrderStatus.Completed); var ofBrand = _serviceUow.BrandService.GetBrandById(orderLine.BrandId); var success = _serviceUow.PaypalService.Transfer(ofBrand.PayPalEmail, (double)orderLine.AmountEarned); if (!success) { throw new Exception("Could not transfer money"); } // Increase order count var brandSummary = _serviceUow.BrandSummaryService.GetBrandSummaryByBrandId(orderLine.BrandId); brandSummary.OrderCount += 1; _serviceUow.BrandSummaryService.Update(brandSummary); OrderPayload orderPayload = _serviceUow.OrderService.GetEventPlannerOrderPayloadByOrderLineId(orderLineId); orderPayload.Verb = "marked as completed"; FirebaseService.FirebaseService.Instance.SendNotification(orderPayload); }
public async Task <string> PostOrder(OrderPayload payload) { string result = null; try { var httpClient = new HttpClient(); // httpClient.BaseAddress = new Uri(Config.BaseURL); // httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var jsonString = JsonConvert.SerializeObject(payload); //Uri uri = new Uri(string.Format("{0}{1}", Config.BaseURL, Config.PostOrderUrl));; Uri uri = new Uri("https://us-central1-scango-df13e.cloudfunctions.net/coreapi/api/v1/order"); HttpContent httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(uri, httpContent); response.EnsureSuccessStatusCode(); result = await response.Content.ReadAsStringAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }
protected void btnPlaceOrder_Click(object sender, EventArgs e) { const string ContentSuffix = "_Contents"; if (!IsValid) { return; } lock (threadLock) { if (targetOrder == null) { Refresh(); return; } targetOrder.Notes = tbNotesComments.Text; // add cross sell var csi = MultiStepWizards.PlaceAnOrder.CrossSellItems; if (csi != null && csi.Count > 0) { targetOrder.LineItems.AddRange(csi.FindAll(x => x.Quantity != 0)); // add any cross sell items } using (var api = GetServiceAPIProxy()) { var msPayload = new List <MemberSuiteObject>(); // Go over line items and generate payoads for all attachments realted fields. foreach (var lineItem in targetOrder.LineItems) { // We're looking for _Content only. _Content has to be of MemberSuiteFile type. var attachments = lineItem.Fields.Where(f => f.Key.EndsWith(ContentSuffix) && IsNonEmptyMemberSuiteFile(f.Value)) .Select(c => { var msf = (MemberSuiteFile)c.Value; // Generate ID var fileId = api.GenerateIdentifer("File").ResultValue; // Create ms object... var mso = new MemberSuiteObject(); mso.ClassType = "File"; mso.Fields["ID"] = fileId; mso.Fields["FileContents"] = msf.FileContents; mso.Fields["Name"] = msf.FileName; mso.Fields["ContentLength"] = msf.FileContents.Length; return(new { Key = c.Key.Replace(ContentSuffix, string.Empty), FileId = fileId, File = mso }); }); if (attachments.Count() > 0) { foreach (var a in attachments) { // JES product fullfillment logic expects an xml file to save.. Copy relevant values into MemberSuiteFile & serializer it to send to JES (MS-6424) // var ms = new MemberSuiteFile(); ms.FileName = a.File.SafeGetValue <string>("Name"); ms.FileContents = a.File.SafeGetValue <byte[]>("FileContents"); ms.FileType = a.File.SafeGetValue <string>("FileType"); //we don't currently have this var xml = MemberSuite.SDK.Utilities.Xml.Serialize(ms); lineItem.Options.Add(new NameValueStringPair { Name = a.Key, Value = xml }); // Add according ms file to payload. msPayload.Add(a.File); } } } OrderPayload payload = MultiStepWizards.PlaceAnOrder.Payload; if (msPayload.Count() > 0) { if (payload == null) { payload = new OrderPayload(); } if (payload.ObjectsToSave == null) { payload.ObjectsToSave = new List <MemberSuiteObject>(); } payload.ObjectsToSave.AddRange(msPayload); } if (targetOrder.Date == DateTime.MinValue) { targetOrder.Date = DateTime.Now; } var processedOrderPacket = api.PreProcessOrder(targetOrder).ResultValue; cleanOrder = processedOrderPacket.FinalizedOrder.ConvertTo <msOrder>(); cleanOrder.Total = processedOrderPacket.Total; //if (string.IsNullOrWhiteSpace(cleanOrder.BillingEmailAddress)) // cleanOrder.BillingEmailAddress = CurrentUser.EmailAddress; if (MultiStepWizards.RegisterForEvent.IsSessionSwap) { var swapResult = api.SwapSessions( MultiStepWizards.RegisterForEvent.SwapRegistrationID, MultiStepWizards.RegisterForEvent.SessionsToCancel, cleanOrder); if (!swapResult.Success) { QueueBannerError(swapResult.FirstErrorMessage); } else { QueueBannerMessage("Session updates complete."); } MultiStepWizards.RegisterForEvent.Clear(); GoTo(MultiStepWizards.PlaceAnOrder.OrderCompleteUrl ?? "OrderComplete.aspx"); } var processInfo = api.ProcessOrder(cleanOrder, payload).ResultValue; // let's wait for the order var processStatus = OrderUtilities.WaitForOrderToComplete(api, processInfo); if (processStatus.Status == LongRunningTaskStatus.Failed) { throw new ConciergeClientException( MemberSuite.SDK.Concierge.ConciergeErrorCode.IllegalOperation, processStatus.AdditionalInfo); } string url = MultiStepWizards.PlaceAnOrder.OrderCompleteUrl ?? "OrderComplete.aspx"; if (url.Contains("?")) { url += "&"; } else { url += "?"; } targetOrder = null; // clear the cart if (isTransient) { // clear out the items if (MultiStepWizards.PlaceAnOrder.TransientShoppingCart != null) { MultiStepWizards.PlaceAnOrder.TransientShoppingCart.LineItems.Clear(); } MultiStepWizards.PlaceAnOrder.TransientShoppingCart = null; } else { MultiStepWizards.PlaceAnOrder.ShoppingCart = null; MultiStepWizards.PlaceAnOrder.RecentlyAddedItems = null; } MultiStepWizards.PlaceAnOrder.CrossSellItems = null; MultiStepWizards.PlaceAnOrder.EditOrderLineItem = null; // clear this out MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductName = null; // clear this out MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductDemographics = null; // clear this out MultiStepWizards.PlaceAnOrder.OrderConfirmationPacket = null; if (processStatus.Status == LongRunningTaskStatus.Running) { // MS-5204. Don't create job posting here. If JES is down then, job posting will be created // during order processing. Otherwise we'll endup with duplicate job postings. // hack - let's save the job posting //if (MultiStepWizards.PostAJob.JobPosting != null) // SaveObject(MultiStepWizards.PostAJob.JobPosting); MultiStepWizards.PostAJob.JobPosting = null; GoTo("OrderQueued.aspx"); } var order = LoadObjectFromAPI <msOrder>(processStatus.WorkflowID); QueueBannerMessage(string.Format("Order #{0} was processed successfully.", order.SafeGetValue <long>( msLocallyIdentifiableAssociationDomainObject.FIELDS.LocalID))); url += "orderID=" + order.ID; if (!url.Contains("contextID=")) { url += "&contextID=" + order.ID; } GoTo(url); } } }
public override void ReadCallback(string tableId, object recordKey, object payload) { switch (this.currentState) { case NewOrderState.ReadItems: if (payload == null) { this.Close("read item failed"); break; } items[i++] = JsonConvert.DeserializeObject <ItemPayload>(payload as string); if (this.i < this.olCount) { ReadItem(); } else { this.currentState = NewOrderState.ReadW; WarehousePkey wpk = new WarehousePkey { W_ID = input.W_ID }; this.AddReq(wpk.ToString()); } break; case NewOrderState.ReadW: if (payload == null) { this.Close("read W fail"); break; } WarehousePayload wpl = JsonConvert.DeserializeObject <WarehousePayload>(payload as string); this.W_TAX = wpl.W_TAX; this.currentState = NewOrderState.ReadD; DistrictPkey dpk = new DistrictPkey { D_ID = input.D_ID, D_W_ID = input.W_ID }; this.dpkStr = dpk.ToString(); this.AddReq(this.dpkStr); break; case NewOrderState.ReadD: if (payload == null) { this.Close("read D fail"); break; } this.dpl = JsonConvert.DeserializeObject <DistrictPayload>(payload as string); this.D_NEXT_O_ID = dpl.D_NEXT_O_ID; this.currentState = NewOrderState.ReadC; CustomerPkey cpk = new CustomerPkey { C_ID = input.C_ID, C_D_ID = input.D_ID, C_W_ID = input.W_ID }; this.AddReq(cpk.ToString()); break; case NewOrderState.ReadC: if (payload == null) { this.Close("read C fail"); break; } this.cpl = JsonConvert.DeserializeObject <CustomerPayload>(payload as string); this.C_DISCOUNT = cpl.C_DISCOUNT; // this.currentState = NewOrderState.ReadInitO; OrderPkey opk = new OrderPkey { O_ID = D_NEXT_O_ID, O_D_ID = input.D_ID, O_W_ID = input.W_ID }; this.opkStr = opk.ToString(); this.AddReq(this.opkStr, null, OperationType.InitiRead); break; case NewOrderState.ReadInitO: if (payload != null) { this.Close("read init O fail"); break; } this.currentState = NewOrderState.InsertO; // all local or not bool allLocal = true; for (i = 0; i < this.olCount; i++) { allLocal = allLocal & input.OL_I_IDs[i] == input.W_ID; } OrderPayload opl = new OrderPayload { O_C_ID = input.C_ID, O_ENTRY_D = input.O_ENTRY_D, O_CARRIER_ID = Constants.NullCarrierID, O_OL_CNT = (uint)input.OL_I_IDs.Length, O_ALL_LOCAL = Convert.ToUInt32(allLocal) }; AddReq(this.opkStr, JsonConvert.SerializeObject(opl), OperationType.Insert); break; case NewOrderState.ReadInitNO: if (payload != null) { this.Close("read init NO fail"); break; } this.currentState = NewOrderState.InsertNO; this.AddReq(this.nopkStr, Constants.PlaceHolders, OperationType.Insert); break; case NewOrderState.InsertOLsReadS: if (payload == null) { this.Close("insert OL read S fail"); break; } this.currentState = NewOrderState.InsertOLsUpdateS; this.spl = JsonConvert.DeserializeObject <StockPayload>(payload as string); uint OL_QUANTITY = input.OL_QUANTITYs[i]; this.spl.S_YTD += OL_QUANTITY; if (spl.S_QUANTITY >= OL_QUANTITY + 10) { spl.S_QUANTITY -= (int)OL_QUANTITY; } else { spl.S_QUANTITY += 91 - (int)OL_QUANTITY; } spl.S_ORDER_CNT += 1; if (input.OL_SUPPLY_W_IDs[i] != input.W_ID) { spl.S_REMOTE_CNT += 1; } this.AddReq(this.spkStr, JsonConvert.SerializeObject(spl), OperationType.Update); break; case NewOrderState.InsertOLsReadInitOL: if (payload != null) { this.Close("insert OL read init OL fail"); break; } this.currentState = NewOrderState.InsertOLsInsertOL; double OL_AMOUNT = input.OL_QUANTITYs[i] * items[i].I_PRICE; this.totalFee += OL_AMOUNT; OrderLinePayload olpl = new OrderLinePayload { OL_I_ID = input.OL_I_IDs[i], OL_SUPPLY_W_ID = input.OL_SUPPLY_W_IDs[i], OL_DELIVERY_D = null, OL_QUANTITY = input.OL_QUANTITYs[i], OL_AMOUNT = OL_AMOUNT, OL_DIST_INFO = spl.S_DIST_01 // TODO, assign to S_DIST_XX, where XX equals to D_ID }; this.AddReq(this.olpkStr, JsonConvert.SerializeObject(olpl), OperationType.Insert); break; default: this.Close("exception read"); break; } this.StoreCurrentState(); }