public async Task <IActionResult> Edit(int id, [Bind("Id,InvoiceNumber,SellDate,ClientId,Paid,Remaining,TotalAmount,CreationDate,CreationBy,IsActive,UserId")] SellRequest sellRequest) { if (id != sellRequest.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sellRequest); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SellRequestExists(sellRequest.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "Name", sellRequest.ClientId); ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", sellRequest.UserId); return(View(sellRequest)); }
public ActionResult Details([Bind(Include = "Id,Make,Model,Year,Price,Kms,EnginLitres,Transmission,Fuel_Type,IsUsed,Color,CustomerID,Image")] SellRequest sellRequest) { if (ModelState.IsValid) { SellRequest sentRequest = db.SellRequests.Find(sellRequest.Id); Car car = new Car() { Make = sentRequest.Make, Model = sentRequest.Model, Year = sentRequest.Year, Price = sentRequest.Price, Kms = sentRequest.Kms, EnginLitres = sentRequest.EnginLitres, Transmission = sentRequest.Transmission, Fuel_Type = sentRequest.Fuel_Type, IsUsed = sentRequest.IsUsed, Color = sentRequest.Color, CustomerID = sentRequest.CustomerID, Image = sentRequest.Image }; db.Cars.Add(car); SellRequest soldRequest = db.SellRequests.Find(sellRequest.Id); db.SellRequests.Remove(soldRequest); Session["RequestID"] = sellRequest.Id; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(sellRequest)); }
public static IList <byte> Sell(SellRequest request) { var command = new List <byte>(); command.AddRange(StringToByteArray("02")); command.AddRange(Encoding.ASCII.GetBytes("VEN")); command.AddRange(StringToByteArray("6800")); command.AddRange( Encoding.ASCII.GetBytes( request.Amount.ToString("N2").Replace(".", "").PadLeft(12, '0') )); command.AddRange(Encoding.ASCII.GetBytes(request.InvoiceNumber.ToString().PadLeft(12, '0'))); command.AddRange(Encoding.ASCII.GetBytes(request.Installments.ToString().PadLeft(2, '0'))); command.AddRange(Encoding.ASCII.GetBytes(request.CardCode.PadLeft(3, '0'))); command.AddRange(Encoding.ASCII.GetBytes(request.PlanCode.ToString().Substring(0, 1))); var sellRequest = (SellRequest)request; command.AddRange( Encoding.ASCII.GetBytes( sellRequest.TipAmount.ToString("N2").Replace(".", "").PadLeft(12, '0') )); command.AddRange(Encoding.ASCII.GetBytes(request.MerchantNumber.ToString().PadLeft(15, ' '))); command.AddRange(Encoding.ASCII.GetBytes(request.MerchantName.ToString().PadLeft(23, ' '))); command.AddRange(Encoding.ASCII.GetBytes(request.MerchantCuit.ToString().PadLeft(23, ' '))); command.AddRange(StringToByteArray(request.IsOnlineTransaction ? "01": "00")); command.Add(3); command.Add(GetCrc(command.ToArray())); return(command); }
public async Task A_Transaction_Will_Not_Be_Created_If_You_Dont_Have_Enough_Shares() { const int Quantity_To_Sell = 20; var client = _factory.CreateDefaultClient(); var createdAccountDetails = await CreateAccount(client); var purchase = await CreatePurchase(client, createdAccountDetails); var requestData = new SellRequest() { AccountNumber = createdAccountDetails.AccountNumber, MinUnitPrice = 1000, ProductCode = Constants.ProductA, Quantity = Quantity_To_Sell }; var response = await client.PostAsJsonAsync("/api/Sales", requestData); response.EnsureSuccessStatusCode(); var responseData = await response.Content.ReadAsJsonAsync <Sale>(); Assert.False(responseData.Success); Assert.Equal(Constants.ProductA, responseData.ProductCode); Assert.Equal(0, responseData.Quantity); Assert.True(responseData.UnitPrice < requestData.MinUnitPrice); Assert.Equal(0, responseData.TotalValue); Assert.Equal(Guid.Empty, responseData.TransactionID); }
private void ButtonSell_Click(object sender, RoutedEventArgs e) { myLogger.Info("Sell button was pressed"); string c = commodity.Text; string a = amount.Text; string p = price.Text; if (c.Length != 0 & a.Length != 0 & p.Length != 0) { int cI = Convert.ToInt32(c); int aI = Convert.ToInt32(a); int pI = Convert.ToInt32(p); SellRequest SR = new SellRequest(); int output = SR.SendSellRequest(pI, cI, aI); if (output == -1) { MessageBox.Show("Failed"); } else { MessageBox.Show("The sell is done:request id:" + output); EnterHistory("Sell", cI, aI, pI, output, false); } } else { MessageBox.Show("full all the fields"); } commodity.Text = ""; amount.Text = ""; price.Text = ""; }
public void confirmChoose() { Debug.Log("Confirmed trade"); Debug.Log("Starts get"); while (File.Exists("Passout.json")) { File.Delete("Passout.json"); } //GIMEM A USERNAME HERE!!!! //Also where do I find the mosnter hp?? (replace 100) SellRequest req = new SellRequest(UserInfo.SignedInUser, mon_name.text, ask, 100); string message = JsonUtility.ToJson(req); Debug.Log(message); using (FileStream fs = File.Create("Passin.json")) { byte[] info = new UTF8Encoding(true).GetBytes(message); fs.Write(info, 0, info.Length); fs.Flush(); fs.Close(); fs.Dispose(); } confirm.enabled = false; StartCoroutine(ReadFile()); }
public ActionResult DeleteConfirmed(int id) { SellRequest sellRequest = db.SellRequests.Find(id); db.SellRequests.Remove(sellRequest); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Make,Model,Year,Price,Kms,EnginLitres,Transmission,Fuel_Type,IsUsed,Color,CustomerID,Image")] SellRequest sellRequest) { if (ModelState.IsValid) { db.Entry(sellRequest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "Id", "Name", sellRequest.CustomerID); return(View(sellRequest)); }
public async Task <IActionResult> Create([Bind("Id,InvoiceNumber,SellDate,ClientId,Paid,Remaining,TotalAmount,CreationDate,CreationBy,IsActive,UserId")] SellRequest sellRequest) { if (ModelState.IsValid) { _context.Add(sellRequest); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "Name"); ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", sellRequest.UserId); return(View(sellRequest)); }
public void Test2Sell() { SellRequest sell = new SellRequest(); if (buy[0] != 1) { Assert.AreNotEqual(-1, sell.SendSellRequest(1000, 5, 3)); } else { Assert.AreEqual(-1, sell.SendSellRequest(1000, 5, 3)); } }
private void button1_Click(object sender, EventArgs e) { //send int commodity = (int)numericUpDown1.Value; int amount = (int)numericUpDown2.Value; int price = (int)numericUpDown3.Value; SellRequest req = new SellRequest(commodity, amount, price); IMarketResponse res = InterperatorPB.sendRequest(req); MessageBox.Show(this, res.ToString()); myLogger.Info("User clicked SELL: {commodity: " + commodity + ", price: " + price + ", amount: " + amount + "}"); }
// GET: SellRequests/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SellRequest sellRequest = db.SellRequests.Find(id); if (sellRequest == null) { return(HttpNotFound()); } return(View(sellRequest)); }
public ActionResult <string> Post( [FromBody] SellRequest sellRequest) { var response = _storeManager.Sell(sellRequest); if (response.Error == null) { return(Ok()); } else { return(NotFound()); } }
public int SendSellRequest(int price, int commodity, int amount) { SellRequest sendReq = new SellRequest(commodity, amount, price); //create and define sell request String output = client.SendPostRequest <SellRequest>(loginInfo.GetURL(), loginInfo.GetUser(), loginInfo.GetToken(), sendReq); if (Utils.Shell.isNumeric(output)) //if the request output is numeric then it succeeded { return(Int32.Parse(output)); } else // the request failed , printing the output { Console.WriteLine(output); return(-1); } }
// GET: SellRequests/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SellRequest sellRequest = db.SellRequests.Find(id); if (sellRequest == null) { return(HttpNotFound()); } ViewBag.CustomerID = new SelectList(db.Customers, "Id", "Name", sellRequest.CustomerID); return(View(sellRequest)); }
public void OnClickSellItem(int itemId, Action CallBack) { if (m_CurrentState == MTStatus.Sell) { PlayAudio("Yindaoyu_#121a1_G_D"); return; } m_OnSellCallBack = CallBack; WindowManager.Instance.OpenWindow(WindowID.Loading); SellRequest request = new SellRequest(); request.ItemId = itemId; m_SellerBidItemId = itemId; AsyncSellRequest async = new AsyncSellRequest(request); async.TryRequest(); }
public IActionResult Sell([FromBody] SellRequest request) { try { var insuranceCompany = insuranceCompanyService.Get(); var result = insuranceCompany.SellPolicy( request.NameOfInsuredObject, request.ValidFrom, request.ValidMonths, request.SelectedRisks.ToList()); return(Ok(result)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
private static async Task <Sale> CreateSale(HttpClient client, AccountDetails createdAccountDetails) { var requestData = new SellRequest() { AccountNumber = createdAccountDetails.AccountNumber, MinUnitPrice = 100, ProductCode = Constants.ProductA, Quantity = Constants.QuantitySold }; var response = await client.PostAsJsonAsync("/api/Sales", requestData); response.EnsureSuccessStatusCode(); var responseData = await response.Content.ReadAsJsonAsync <Sale>(); Assert.True(responseData.Success); return(responseData); }
public IMarketResponse SendSellRequest(int price, int commodity, int amount) { SellRequest sellReq = new SellRequest(commodity, amount, price); //create and define sell request MBuySell marketResponse = new MBuySell(); try { marketResponse.id = client.SendPostRequest <SellRequest>(url, user, privateKey, sellReq); myLogger.Info("Sent Sell Request{commodity:" + commodity + ", price:" + price + ", amount:" + amount + ", url:" + url + "}"); } catch (Exception e) { return(catchMethod(e)); } myHistory.Info("Sent Sell Request-\r\ncommodity:" + commodity + ", price:" + price + ", amount:" + amount + "\nResponse: " + marketResponse.ToString()); return(marketResponse); }
private static async Task <Sale> MakeSale(HttpClient httpClient, Guid account_code, string productCode, int minUnitPrice, int quantity) { var requestData = new SellRequest() { AccountNumber = account_code, MinUnitPrice = minUnitPrice, ProductCode = productCode, Quantity = quantity }; var response = await httpClient.PostAsJsonAsync("/api/Sales", requestData); response.EnsureSuccessStatusCode(); var responseData = await response.Content.ReadAsJsonAsync <Sale>(); //TODO: Check the sales was successful return(responseData); }
public IActionResult Sell(SellRequest sellRequest) { if (Application.Resolve <ICoreService>().Config.ReadOnlyMode) { return(new BadRequestResult()); } if (!string.IsNullOrWhiteSpace(sellRequest.Pair) && sellRequest.Amount > 0) { ITradingService tradingService = Application.Resolve <ITradingService>(); tradingService.Sell(new SellOptions(sellRequest.Pair) { Amount = sellRequest.Amount, ManualOrder = true }); return(new OkResult()); } return(new BadRequestResult()); }
public ActionResult Create([Bind(Include = "Id,Make,Model,Year,Price,Kms,EnginLitres,Transmission,Fuel_Type,IsUsed,Color,CustomerID,Image")] Car car) { if (Session["LoginCustomerName"].Equals("Admin")) { if (ModelState.IsValid) { db.Cars.Add(car); SellRequest soldRequest = db.SellRequests.Find(car.Id); db.SellRequests.Remove(soldRequest); db.SaveChanges(); if (Session["LoginCustomerName"].Equals("Admin")) { return(RedirectToAction("List")); } } ViewBag.CustomerID = new SelectList(db.Customers, "Id", "Name", car.CustomerID); return(View(car)); } else { return(RedirectToAction("Index", "Home")); } }
// public BookingUpdateResponseData createBooking(GetLowFareAvailabilityResponse availresponse, String faretype, int numadt, int numchd, String currency, String sourceorg, String agentcode) // { public BookingUpdateResponseData createBooking(GetAvailabilityResponse availresponse, String faretype, int numadt, int numchd, String currency, String sourceorg, String agentcode) { SellRequest sellrequest = new SellRequest(); sellrequest.Signature = signature; //to indicate we are selling the ticket a journey: sellrequest.SellRequestData = new SellRequestData(); sellrequest.SellRequestData.SellBy = SellBy.Journey;//sell the ticket by journey sellrequest.SellRequestData.SellJourneyRequest = new SellJourneyRequest(); SellJourneyRequestData selldata = new SellJourneyRequestData(); selldata.TypeOfSale = new TypeOfSale(); selldata.TypeOfSale.FareTypes = new string[1]; selldata.TypeOfSale.FareTypes[0] = faretype; selldata.CurrencyCode = currency;//this is required to get pricing details //i need to specify Adult + child in the pax count variable but in the xml log this will be overrriden by the passenger info selldata.PaxCount = (short)(numadt + numchd);//this will define the number of passengers 2 sell //selldata.PaxCount = 0; // selldata.Journeys = new SellJourney[pricedata.PriceJourneys.Length];//in the case of 1 way trip, just replace by new SellJourney[1] selldata.Journeys = new SellJourney[1];// for 1 way flight- put 1 as original , for 2 way flight as 2 for (int i = 0; i < selldata.Journeys.Length; i++) { selldata.Journeys[i] = new SellJourney(); Segment[] availsegment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments;//change back to index 0 for Journeys selldata.Journeys[i].Segments = new SellSegment[availsegment.Length]; Console.WriteLine("Flight Number is :" + availsegment[i].FlightDesignator.CarrierCode + " " + availsegment[i].FlightDesignator.FlightNumber); Console.WriteLine("Flight Timing is :" + availsegment[i].STD + " " + availsegment[i].STA); Console.WriteLine("Flight Duration is :" + availsegment[i].STA.AddMinutes(availsegment[i].Legs[availsegment[i].Legs.Length-1].LegInfo.ArrvLTV*-1).Subtract(availsegment[i].STD.AddMinutes(availsegment[i].Legs[0].LegInfo.DeptLTV*-1)));//provided by peiru // Fare fare = availsegment[i].Fares[0];//get the fares at index 0 for starter and 1 for starter plus and 2 for max which will only apply for voucher details for (int j = 0; j < selldata.Journeys[i].Segments.Length; j++) { selldata.Journeys[i].Segments[j] = new SellSegment(); selldata.Journeys[i].Segments[j].ActionStatusCode = "NN"; selldata.Journeys[i].Segments[j].FlightDesignator = availsegment[j].FlightDesignator; selldata.Journeys[i].Segments[j].ArrivalStation = availsegment[j].ArrivalStation; selldata.Journeys[i].Segments[j].DepartureStation = availsegment[j].DepartureStation; selldata.Journeys[i].Segments[j].STA = availsegment[j].STA; selldata.Journeys[i].Segments[j].STD = availsegment[j].STD; //if (fare.ProductClass.StartsWith("S")) // Console.Write("Starter "); //else if (fare.ProductClass.StartsWith("P")) // Console.Write("Starter Plus"); //else if (fare.ProductClass.StartsWith("Y")) // Console.Write("Starter Max"); //else if (fare.ProductClass.StartsWith("F")) // Console.Write("Business Max"); //else if (fare.ProductClass.StartsWith("J")) // Console.Write("Business"); // selldata.Journeys[i].Segments[j].Fare = new SellFare();//uncomment this //selldata.Journeys[i].Segments[j].Fare.CarrierCode = fare.CarrierCode;//uncomment this ////selldata.Journeys[i].Segments[j].Fare.CarrierCode = "BL";//- this is for test //selldata.Journeys[i].Segments[j].Fare.ClassOfService = fare.ClassOfService;//uncomment this // // segments[j].Fare.ClassOfService = fare.ClassOfService; // selldata.Journeys[i].Segments[j].Fare.FareApplicationType = fare.FareApplicationType;//uncomment this // // segments[j].Fare.FareApplicationType = fare.FareApplicationType; // selldata.Journeys[i].Segments[j].Fare.FareBasisCode = fare.FareBasisCode;//uncomment this // //segments[j].Fare.FareBasisCode = fare.FareBasisCode; //selldata.Journeys[i].Segments[j].Fare.ProductClass = fare.ProductClass;//uncomment this // //segments[j].Fare.ProductClass = fare.ProductClass; // selldata.Journeys[i].Segments[j].Fare.RuleNumber = fare.RuleNumber;//uncommnet this // // segments[j].Fare.RuleNumber = fare.RuleNumber; for (int k = 0; k < availsegment[i].Fares.Length; k++)// i do not use availsegment.Length directly here as i need to get the fares associated with each segment { Fare fare = availsegment[i].Fares[k]; Console.WriteLine((k + 1) + ")Class: "); if (fare.ProductClass.StartsWith("S")) Console.Write("Startter"); else if (fare.ProductClass.StartsWith("P")) Console.Write("Starter Plus"); else if (fare.ProductClass.StartsWith("Y")) Console.Write("StarterMax"); else if (fare.ProductClass.StartsWith("F")) Console.Write("Business Max"); else if (fare.ProductClass.StartsWith("J")) Console.Write("Business"); Console.WriteLine(fare.ProductClass + ", Basis Code :" + fare.FareBasisCode); selldata.Journeys[i].Segments[j].Fare = new SellFare(); selldata.Journeys[i].Segments[j].Fare.CarrierCode = availsegment[j].Fares[k].CarrierCode; selldata.Journeys[i].Segments[j].Fare.ClassOfService = availsegment[j].Fares[k].ClassOfService; selldata.Journeys[i].Segments[j].Fare.FareApplicationType = availsegment[j].Fares[k].FareApplicationType; selldata.Journeys[i].Segments[j].Fare.FareBasisCode = availsegment[j].Fares[k].FareBasisCode; selldata.Journeys[i].Segments[j].Fare.ProductClass = availsegment[j].Fares[k].ProductClass; selldata.Journeys[i].Segments[j].Fare.RuleNumber = availsegment[j].Fares[k].RuleNumber; } // Console.WriteLine(fare.ProductClass + ", Basis Code : " + fare.FareBasisCode + ", Class of Service : " + fare.ClassOfService);// writing in the loop will return me the fare details in each segment of journey } } //to retrieve n chnage booknigs, it must belong to a current agent and organization, which are set in POS //SellRequest must contain a correct SourcePOS if (sourceorg.Length > 0) { selldata.SourcePOS = new PointOfSale(); selldata.SourcePOS.AgentCode = agentcode; selldata.SourcePOS.OrganizationCode = sourceorg; selldata.SourcePOS.DomainCode = "EXT"; selldata.SourcePOS.LocationCode = "API"; } else { selldata.SourcePOS = new PointOfSale(); selldata.SourcePOS.AgentCode = "JQ"; selldata.SourcePOS.OrganizationCode = "JQ"; selldata.SourcePOS.DomainCode = "EXT"; selldata.SourcePOS.LocationCode = "APT"; } //i have to assign the value back to obj selldata in the last state for most updated value sellrequest.SellRequestData.SellJourneyRequest.SellJourneyRequestData = selldata; SellResponse sellresponse = clientapi.Sell(sellrequest); System.Console.WriteLine("Total Flight Cost {0:C}", sellresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost); //this completes the flightcost by using SellRequest using SellBy Journey. //--------------------------------------------------------------------------------------------------------- GetBookingFromStateRequest bookingfromstaterequest = new GetBookingFromStateRequest(); bookingfromstaterequest.Signature = signature; GetBookingFromStateResponse bookingfromstateresponse = clientapi.GetBookingFromState(bookingfromstaterequest); // this is to get the SSR cost //------------------------------------------------------------------------------------------------------------ // PassengerInfant passengerInfant = null; PassengerInfant []passengerInfant = new PassengerInfant[2]; passengerInfant[0] = new PassengerInfant(); passengerInfant[1] = new PassengerInfant(); //---------------------------------------------------------------------------------------------------------------------- //lets say if i have 3 ssr to sell, so i put in a for loop // SellRequest []sellSSRRequest3 = new SellRequest[3]; //if i need to put this in an array //for (int m = 0; m < sellSSRRequest3.Length; m++) //{ // sellSSRRequest3[m] = new SellRequest(); // sellSSRRequest3[m].Signature = signature; // SellRequestData sellrequestdata3 = new SellRequestData(); // sellSSRRequest3[m].SellRequestData = sellrequestdata3; // sellrequestdata3.SellBy = SellBy.SSR; // SellSSR sellssr3 = new SellSSR(); // sellrequestdata3.SellSSR = sellssr3; // sellssr3.SSRRequest = new SSRRequest(); // SSRRequest ssrrequest3 = new SSRRequest(); // sellssr3.SSRRequest = ssrrequest3; // ssrrequest3.CurrencyCode = "AUD"; //ssrrequest3.SegmentSSRRequests = new SegmentSSRRequest[1]; //SegmentSSRRequest segmentSSRRequest = new SegmentSSRRequest(); //ssrrequest3.SegmentSSRRequests[0] = segmentSSRRequest; //---------------------------------------------------------------------------------------------------- SellRequest sellSSRRequest = new SellRequest(); sellSSRRequest.Signature = signature; SellRequestData sellrequestdata = new SellRequestData(); sellSSRRequest.SellRequestData = sellrequestdata; sellrequestdata.SellBy = SellBy.SSR; SellSSR sellssr = new SellSSR(); sellrequestdata.SellSSR = sellssr; sellssr.SSRRequest = new SSRRequest(); SSRRequest ssrrequest = new SSRRequest(); sellssr.SSRRequest = ssrrequest; ssrrequest.CurrencyCode = "AUD"; //---------------------------------------------------------------- //this is for the second SSR SellRequest sellSSRRequest2 = new SellRequest(); sellSSRRequest2.Signature = signature; SellRequestData sellrequestdata2 = new SellRequestData(); sellSSRRequest2.SellRequestData = sellrequestdata2; sellrequestdata2.SellBy = SellBy.SSR; SellSSR sellssr2 = new SellSSR(); sellrequestdata2.SellSSR = sellssr2; sellssr2.SSRRequest = new SSRRequest(); SSRRequest ssrrequest2 = new SSRRequest(); sellssr2.SSRRequest = ssrrequest2; ssrrequest2.CurrencyCode = "AUD"; //------------------------------------------------------------------------------------------------- //this is for the first SSR ssrrequest.SegmentSSRRequests = new SegmentSSRRequest[1]; //since SegmentSSRRequests is an array data type, the way to write in one step is : //ssrrequest.SegmentSSRRequests[0] = new SegmentSSRRequest(); otherwise as below in 2 steps SegmentSSRRequest segmentSSRRequest = new SegmentSSRRequest(); ssrrequest.SegmentSSRRequests[0] = segmentSSRRequest; //------------------------------------------------------------------------------------------------- //this is for the second SSR ssrrequest2.SegmentSSRRequests = new SegmentSSRRequest[1]; SegmentSSRRequest segmentSSRRequest2 = new SegmentSSRRequest(); ssrrequest2.SegmentSSRRequests[0] = segmentSSRRequest2; //-------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------- selldata.Journeys = new SellJourney[1];// for 1 way flight for (int i = 0; i < selldata.Journeys.Length; i++) { selldata.Journeys[i] = new SellJourney(); Segment[] availsegment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments; selldata.Journeys[i].Segments = new SellSegment[availsegment.Length]; for (int j = 0; j < selldata.Journeys[i].Segments.Length; j++) { selldata.Journeys[i].Segments[j] = new SellSegment(); segmentSSRRequest.ArrivalStation = availsegment[j].ArrivalStation; segmentSSRRequest.DepartureStation = availsegment[j].DepartureStation; segmentSSRRequest.FlightDesignator = availsegment[j].FlightDesignator; segmentSSRRequest.STD = availsegment[j].STD; //this is for the second SSRRequest segmentSSRRequest2.ArrivalStation = availsegment[j].ArrivalStation; segmentSSRRequest2.DepartureStation = availsegment[j].DepartureStation; segmentSSRRequest2.FlightDesignator = availsegment[j].FlightDesignator; segmentSSRRequest2.STD = availsegment[j].STD; ssrrequest.SegmentSSRRequests[0].PaxSSRs = new PaxSSR[selldata.PaxCount];//change this back to 0 instead of j ssrrequest2.SegmentSSRRequests[0].PaxSSRs = new PaxSSR[selldata.PaxCount];//change this back to 0 instead of j for (int k = 0; k < selldata.PaxCount; k++) { ssrrequest.SegmentSSRRequests[0].PaxSSRs[k] = new PaxSSR();//only first segment has ssr ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].ActionStatusCode = "NN"; ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].DepartureStation = availsegment[j].DepartureStation; ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].ArrivalStation = availsegment[j].ArrivalStation; Console.Write("SSR : (BG20): ");//BA droid is added by BCS we dont check....IFOO SSR is only made available on long haul flights String line2 = Console.ReadLine(); if (line2.Length == 0) { line2 = "BG20";//BA droid is added by BCS we dont check } ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].SSRCode = line2.ToUpper(); ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].SSRNumber = (short)k; ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].PassengerNumber = (short)(k % selldata.PaxCount); } //--------------------------------------------------------------------------------------------------------------------- for (int k = 0; k < selldata.PaxCount; k++) { ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k] = new PaxSSR(); ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].ActionStatusCode = "NN"; ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].DepartureStation = availsegment[j].DepartureStation; ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].ArrivalStation = availsegment[j].ArrivalStation; Console.Write("SSR 2 (INFT): "); String line3 = Console.ReadLine(); if (line3.Length == 0) line3 = "INFT"; if (line3.ToUpper().Equals("INFT")) { passengerInfant[0] = new PassengerInfant(); passengerInfant[0].DOB = new DateTime(2014, 2, 03); passengerInfant[0].Gender = Gender.Female; passengerInfant[0].State = MessageState.New; passengerInfant[0].Names = new BookingName[1]; passengerInfant[0].Names[0] = new BookingName(); passengerInfant[0].Names[0].FirstName = "Michelle"; passengerInfant[0].Names[0].LastName = "idontknow"; passengerInfant[0].Names[0].Title = "Miss";//master passengerInfant[0].Nationality = "SG"; passengerInfant[0].ResidentCountry = "SG"; passengerInfant[1] = new PassengerInfant(); passengerInfant[1].DOB = new DateTime(2013, 3, 03); passengerInfant[1].Gender = Gender.Female; passengerInfant[1].State = MessageState.New; passengerInfant[1].Names = new BookingName[1]; passengerInfant[1].Names[0] = new BookingName(); passengerInfant[1].Names[0].FirstName = "Michelle2"; passengerInfant[1].Names[0].LastName = "idontknow2"; passengerInfant[1].Names[0].Title = "Miss";//master passengerInfant[1].Nationality = "SG"; passengerInfant[1].ResidentCountry = "SG"; } ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].SSRCode = line3.ToUpper(); ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].SSRNumber = (short)k; ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].PassengerNumber = (short)(k % selldata.PaxCount); } } } SellResponse sellssrresponse = clientapi.Sell(sellSSRRequest); SellResponse sellssrresponse2 = clientapi.Sell(sellSSRRequest2); System.Console.WriteLine("Total Flight + 1st SSR Cost : {0:C}", sellssrresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost); System.Console.WriteLine("Total Flight + 1st and 2nd SSR Cost : {0:C}", sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost); //--------------------------------------------------------------------------------------------------------------------------------------- // this is the end of the SSR cost Booking booking = new Booking(); booking.Passengers = new Passenger[numadt + numchd]; // booking.Passengers = new Passenger[numadt];this means the credit card fee will only be applied to the adt Decimal balancedue = 0.0M; //this is to get the credit card fees for per journey and passenger basis //------------------------------------------------------------------------------------------------------------------------ for (int i = 0; i < numadt+ numchd; i++)//selldata.Paxcount { booking.Passengers[i] = new Passenger(); booking.Passengers[i].PassengerFees = new PassengerFee[1]; booking.Passengers[i].PassengerFees[0] = new PassengerFee(); GetPaymentFeePriceRequest paymentfeepricerequest = new GetPaymentFeePriceRequest(); paymentfeepricerequest.paymentFeePriceReqData = new PaymentFeePriceRequest();//i added this paymentfeepricerequest.Signature = signature; paymentfeepricerequest.paymentFeePriceReqData.FeeCode = "CC"; paymentfeepricerequest.paymentFeePriceReqData.CurrencyCode = "AUD"; paymentfeepricerequest.paymentFeePriceReqData.PaymentAmount = sellresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue; GetPaymentFeePriceResponse paymentfeeresponse = new GetPaymentFeePriceResponse(); paymentfeeresponse.paymentFeePriceRespData = new PaymentFeePriceResponse(); paymentfeeresponse = clientapi.GetPaymentFeePrice(paymentfeepricerequest); //since the booking charge is made on per passenger per journey basis //balancedue = sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost;//required for payment currency. this will pass the most updated balance due...** if it is stored somewhere else, will show discrepancy in total cost and payment. if (paymentfeeresponse.paymentFeePriceRespData.PassengerFees.Length > 0)//this checks for passenger fees { Console.WriteLine("CC Fee: {0:C} " + paymentfeeresponse.paymentFeePriceRespData.PassengerFees[0].ServiceCharges[0].Amount); } } balancedue = sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost;//required for payment currency. this will pass the most updated balance due...** if it is stored somewhere else, will show discrepancy in total cost and payment. //before make payment thru credit card, need to get the most updated balance thru balancedue after i have sold the flight and the SSR //------------------------------------------------------------------------------------------------------------------------------------------- //this is the end of the Credit Card fees //this is for Sell Fee(additional fees outside of credit cards)-- not required for external partners //------------------------------------------------------------------------------------------------------------- //payment using 2 function calls : AddPaymentToBooking() + BookingCommit() : can be a method byitself of paybooking(String PNR) //creditcard fees // Decimal balancedue = sellresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue; //start payment AddPaymentToBookingRequest paymentrequest = new AddPaymentToBookingRequest(); paymentrequest.addPaymentToBookingReqData = new AddPaymentToBookingRequestData(); paymentrequest.Signature = signature; paymentrequest.ContractVersion = 0; String response; if (Double.Parse(balancedue.ToString()) > 0.0) { Console.Write("Payment (MC/VI/AX/DI/JB/TP/AG): "); response = Console.ReadLine().ToUpper(); if (response.Equals("MC")) { paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount; paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "MC"; paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency; paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue; paymentrequest.addPaymentToBookingReqData.AccountNumber = "5453010000064154"; // paymentrequest.addPaymentToBookingReqData.AccountNumber = "5224999999999909";// for test paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05"); paymentrequest.addPaymentToBookingReqData.PaymentText = "Test Payment"; paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2]; paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName"; paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "123"; } else if (response.Equals("AX")) { paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount; paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "AX"; paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency; paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue; paymentrequest.addPaymentToBookingReqData.AccountNumber = "345678000000007"; paymentrequest.addPaymentToBookingReqData.PaymentText = "Amex Payment"; paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05"); paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2]; paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName"; paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "1234"; } else if (response.Equals("TP")) { paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount; paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "TP"; paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency; paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue; paymentrequest.addPaymentToBookingReqData.AccountNumber = "135416000696332"; paymentrequest.addPaymentToBookingReqData.PaymentText = "UATP Payment"; paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2014-12"); paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2]; paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName"; paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Anannya"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::Verification Code"; } else if (response.Equals("AG"))//if i use this, then i need to call AddPaymentToBooking twice { paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.AgencyAccount; paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "AG"; paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency; if (sourceorg.Length > 0) { paymentrequest.addPaymentToBookingReqData.AccountNumber = sourceorg; } paymentrequest.addPaymentToBookingReqData.PaymentFields = null; } else //if (response.Equals("VI")) { paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount; paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "VI"; paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency; paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue; // paymentrequest.addPaymentToBookingReqData.AccountNumber = "30123400000000";- for Diners paymentrequest.addPaymentToBookingReqData.AccountNumber = "4929498311400002";// this is a 3DS card-the authorization status will be pending client response // paymentrequest.addPaymentToBookingReqData.AccountNumber = "4123450131001381"; // paymentrequest.addPaymentToBookingReqData.AccountNumber = "4543059790016721";- for test booking paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05"); paymentrequest.addPaymentToBookingReqData.PaymentText = "Test Payment"; paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2]; paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName"; paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField(); paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode"; paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "123"; } } //paymentrequest.addPaymentToBookingReqData.AccountNumberID = 0;// not required for new booking; only use this if the card cd has been swipped before n then it has an account tied to it AddPaymentToBookingResponse paymentresponse = clientapi.AddPaymentToBooking(paymentrequest); //validate the payments ValidationPayment validationpayment = paymentresponse.BookingPaymentResponse.ValidationPayment; if (validationpayment.PaymentValidationErrors.Length > 0) { Console.WriteLine(validationpayment.PaymentValidationErrors[0].ErrorDescription); return null; } if (validationpayment.Payment.PaymentAddedToState) { Console.WriteLine("Payment added to booking state : Payment complete"); } //for adding AG payment // . //. //. //after AddpaymentToBooking; then i need to do BookingCommit(); first do the bookingcontacts and update passenger list first BookingCommitRequest bookingcommitrequest = new BookingCommitRequest(); bookingcommitrequest.Signature = signature; // bookingcommitrequest.BookingCommitRequestData = new BookingCommitRequestData(); BookingCommitRequestData bookingcommitrequestdata = new BookingCommitRequestData(); bookingcommitrequest.BookingCommitRequestData = bookingcommitrequestdata; //------------------------------------------------------------------------------------------------------------------- //BookingContact[] bookingContacts = new BookingContact[1]; //bookingContacts[0] = new BookingContact(); //bookingContacts[0].State = MessageState.New; //bookingContacts[0].Names = new BookingName[1]; //bookingContacts[0].Names[0] = new BookingName(); //bookingContacts[0].Names[0].FirstName = "Michelle"; //bookingContacts[0].Names[0].LastName = "Sadhnani"; //bookingContacts[0].Names[0].Title = "Miss"; //if (sourceorg.Length > 0) //{ // bookingContacts[0].SourceOrganization = sourceorg; //} //bookingContacts[0].AddressLine1 = "123 Airport Road"; //bookingContacts[0].AddressLine2 = "Boulevard Terminal"; //bookingContacts[0].City = "Singapore"; //bookingContacts[0].CountryCode = "SG"; //bookingContacts[0].EmailAddress = "*****@*****.**"; //// bookingContacts[0].EmailAddress = "*****@*****.**";//for test purposes //bookingContacts[0].ProvinceState = "AB"; //bookingContacts[0].PostalCode = "123456789"; //bookingContacts[0].OtherPhone = "91444345";// this is my mobile number //bookingContacts[0].HomePhone = "+65654321"; //bookingContacts[0].TypeCode = "P"; //bookingContacts[0].CultureCode = "en-AU"; //bookingContacts[0].DistributionOption = DistributionOption.Email; //bookingContacts[0].NotificationPreference = NotificationPreference.None; //----------------------------------------------------------------------------------------------------------------- //Anannya- get prompt from user : another way of writing //----------------------------------------------------------------------------------------------------------- //this is for declaring 2 booking contacts // BookingContact[] BookingContacts = new BookingContact[2]; // for (int i = 0; i < BookingContacts.Length; i++) // { // BookingContacts[i] = new BookingContact(); // BookingContacts[i].State = MessageState.New; // BookingContacts[i].Names = new BookingName[1]; // BookingName bookingname = new BookingName(); // BookingContacts[i].Names[0] = bookingname; // String firstname, lastname, salutation, emailadd, mobilenumber; // Console.Write("Provide Booking Contact First Name for Emeergency :"); // firstname = Console.ReadLine().ToUpper(); // Console.Write("Provide Booking Contact Last Name for Emeergency :"); // lastname = Console.ReadLine().ToUpper(); // Console.Write("Provide Booking Contact Title :"); // salutation = Console.ReadLine().ToUpper(); // Console.Write("Provide Booking Contact E-Mail add for Emeergency :"); // emailadd = Console.ReadLine().ToUpper(); // Console.Write("Provide Booking Contact Mobile Number for Emeergency :"); // mobilenumber = Console.ReadLine().ToUpper(); // bookingname.FirstName = firstname; // bookingname.LastName = lastname; // bookingname.Title = salutation; // if (sourceorg.Length > 0) // { // BookingContacts[i].SourceOrganization = sourceorg; // } // BookingContacts[i].AddressLine1 = "123 Airport Road"; // BookingContacts[i].AddressLine2 = "Boulevard Terminal"; // BookingContacts[i].City = "Singapore"; // BookingContacts[i].CountryCode = "SG"; // BookingContacts[i].EmailAddress = emailadd; // BookingContacts[i].ProvinceState = "AB"; // BookingContacts[i].PostalCode = "123456789"; // BookingContacts[i].OtherPhone = mobilenumber;// this is my mobile number // BookingContacts[i].HomePhone = "+65654321"; //BookingContacts[i].TypeCode = "P"; //BookingContacts[i].CultureCode = "en-AU"; // BookingContacts[i].DistributionOption = DistributionOption.Email; // BookingContacts[i].NotificationPreference = NotificationPreference.None; // }---------------------------------------------------------------------------------------------------------- //in the even i do not want a prompt and just pur to one booknig contact only still in an array: BookingContact[] BookingContacts = new BookingContact[1]; BookingContacts[0] = new BookingContact(); BookingContacts[0].State = MessageState.New; BookingContacts[0].Names = new BookingName[1]; BookingName bookingname = new BookingName(); BookingContacts[0].Names[0] = bookingname; bookingname.FirstName = "Anannya"; bookingname.LastName = "Sadhnani"; bookingname.Title = "ms".ToUpper(); if (sourceorg.Length > 0) { BookingContacts[0].SourceOrganization = sourceorg; } BookingContacts[0].AddressLine1 = "123 Airport Road"; BookingContacts[0].AddressLine2 = "Boulevard Terminal"; BookingContacts[0].City = "Singapore"; BookingContacts[0].CountryCode = "SG"; BookingContacts[0].EmailAddress = "*****@*****.**"; BookingContacts[0].ProvinceState = "AB"; BookingContacts[0].PostalCode = "123456789"; BookingContacts[0].OtherPhone = "91444345";// this is my mobile number BookingContacts[0].HomePhone = "+65654321"; BookingContacts[0].TypeCode = "P"; BookingContacts[0].CultureCode = "en-AU"; BookingContacts[0].DistributionOption = DistributionOption.Email; BookingContacts[0].NotificationPreference = NotificationPreference.None; bookingcommitrequestdata.DistributeToContacts = true;//by default this is set to false, we need to set this line to true. //--------------------------------------------------------------------------------------------------------- //update the booking contacts in the bookingcommit request UpdateContactsRequest updatecontactrequest = new UpdateContactsRequest(); updatecontactrequest.Signature = signature; updatecontactrequest.updateContactsRequestData = new UpdateContactsRequestData(); //updatecontactrequest.updateContactsRequestData.BookingContactList = bookingContacts; updatecontactrequest.updateContactsRequestData.BookingContactList = BookingContacts; clientapi.UpdateContacts(updatecontactrequest); //---------------------------------------------------------------------------- // booking comment array setup here // Booking booking = new Booking();//create the booking obj so that i can pass the passenger info to it booking.ReceivedBy = new ReceivedByInfo(); booking.ReceivedBy.LatestReceivedBy = "TesttoMichelle"; booking.BookingComments = new BookingComment[2]; booking.BookingComments[0] = new BookingComment(); booking.BookingComments[0].CommentText = "This is a one way intl route booking test-PER to DPS"; booking.BookingComments[0].CommentType = CommentType.Default; booking.BookingComments[1] = new BookingComment(); booking.BookingComments[1].CommentText = "Whatever crap"; booking.BookingComments[1].CommentType = CommentType.Default; bookingcommitrequest.BookingCommitRequestData.BookingComments = booking.BookingComments; //--------------------------------------------------------------------------------------------------- //BookingHold bookinghold = new BookingHold(); // booking.BookingHold.HoldDateTime = DateTime.Parse("0001-01-01T00:00:00"); this is not required in .net framework booking.Passengers = new Passenger[numadt + numchd]; String title; String line; for (int i = 0; i < booking.Passengers.Length; i++)// or (int i=0; i<(numadt + numchd); i++) { booking.Passengers[i] = new Passenger(); booking.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1 booking.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo(); //this is the way to write in 2 steps // PassengerTypeInfo passengertypeinfo = new PassengerTypeInfo(); //booking.Passengers[i].PassengerTypeInfos[0] = passengertypeinfo; line = "M"; if (i < numadt - 1) { title = "MR"; line = "M"; } else { title = "MS"; line = "F"; } //this is setting up the Passenger array object info booking.Passengers[i] = new Passenger(); booking.Passengers[i].State = MessageState.New;//cannot put this to modified state as it will only take pax=1 booking.Passengers[i].Names = new BookingName[1];//change back to 1 booking.Passengers[i].Names[0] = new BookingName(); booking.Passengers[i].Names[0].Title = title.ToUpper();//MR; MRS; etc String firstname, lastname, salutation; Console.Write("Provide your first name): "); firstname = Console.ReadLine().ToUpper(); Console.Write("Provide your last name): "); lastname = Console.ReadLine().ToUpper(); Console.Write("Salution): "); salutation = Console.ReadLine().ToUpper(); booking.Passengers[i].Names[0].FirstName = firstname; booking.Passengers[i].Names[0].LastName = lastname; booking.Passengers[i].Names[0].Title = salutation; //if i hardcode //booking.Passengers[i].Names[0].FirstName = "Michelle";//replace back to the Passengers[i] //booking.Passengers[i].Names[0].LastName = "Sadhnani"; //booking.Passengers[i].Names[0].Title = "MISS"; // if (i == 0 && passengerInfant != null)// i need this for passenger infant type SSR //{ //if(i==0 && passengerInfant != null)//means not an adult or child if(i==0) booking.Passengers[i].Infant = passengerInfant[0]; booking.Passengers[i].Infant = passengerInfant[1]; //} if (i > 0) { booking.Passengers[i].Names[0].Suffix = "EXST"; } booking.Passengers[i].PassengerInfo = new PassengerInfo(); booking.Passengers[i].PassengerInfo.State = MessageState.Modified; booking.Passengers[i].PassengerInfo.Nationality = "SG"; booking.Passengers[i].PassengerNumber = (short)i; if (line == "M") { booking.Passengers[i].PassengerInfo.Gender = Gender.Male; booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Male; } else { booking.Passengers[i].PassengerInfo.Gender = Gender.Female; booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Female; } //create the new PassengerTypeInfos array where i specify the total number of passengers, this excludes infants in PassegerTypeInfo[variable] booking.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1 if it does not work booking.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo();//change back PassengerTypeInfos to 0 if it doesnt work // booking.Passengers[i].PassengerTypeInfos[0].State = MessageState.Modified; // PassengerTypeInfo passengertypeinfo = new PassengerTypeInfo(); //booking.Passengers[i].PassengerTypeInfos[0] = passengertypeinfo; //passengertypeinfo.PaxType = "ADT"; //booking.Passengers[i].PassengerTypeInfos[1] = passengertypeinfo; //passengertypeinfo.PaxType = "CHD"; if (i < numadt) { booking.Passengers[i].PassengerTypeInfos[0].PaxType = "ADT"; booking.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("1987-12-10T00:00:00"); } else { booking.Passengers[i].PassengerTypeInfos[0].PaxType = "CHD"; booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Child; //selldata.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("2008-8-12T00:00:00Z"); } booking.Passengers[i].PaxDiscountCode = null; //this information is needed per the SkySpeed Passenger sub-object booking.Passengers[i].PassengerTravelDocuments = new PassengerTravelDocument[1]; booking.Passengers[i].PassengerTravelDocuments[0] = new PassengerTravelDocument(); booking.Passengers[i].PassengerTravelDocuments[0].Names = new BookingName[1]; booking.Passengers[i].PassengerTravelDocuments[0].Names[0] = new BookingName(); booking.Passengers[i].PassengerTravelDocuments[0].Names[0].Title = booking.Passengers[i].Names[0].Title; booking.Passengers[i].PassengerTravelDocuments[0].Names[0].FirstName = booking.Passengers[i].Names[0].FirstName; booking.Passengers[i].PassengerTravelDocuments[0].Names[0].LastName = booking.Passengers[i].Names[0].LastName; booking.Passengers[i].PassengerTravelDocuments[0].Gender = booking.Passengers[i].PassengerInfo.Gender; booking.Passengers[i].PassengerTravelDocuments[0].DocTypeCode = "P"; booking.Passengers[i].PassengerTravelDocuments[0].IssuedByCode = "US"; booking.Passengers[i].PassengerTravelDocuments[0].DocNumber = "12345"; booking.Passengers[i].PassengerTravelDocuments[0].ExpirationDate = new DateTime(2010, 02, 01); //booking.Passengers[i].PassengerTravelDocuments[0].Names = new BookingName[1]; //BookingName name = new BookingName(); //booking.Passengers[i].PassengerTravelDocuments[0].Names[0] = name; //name.FirstName = "Anannya"; //name.LastName = "Sadhnani"; //now equate the passenger docs info to the passenger info // passengertraveldocs.Names = new BookingName[1];//uncomment this // BookingName bookingname2 = new BookingName();//uncomment this // passengertraveldocs.Names[0] = bookingname2;//uncomment this //bookingname2.Title = salutation;//uncomment this //bookingname2.LastName = lastname;//uncomment this //bookingname2.FirstName = firstname;//uncomment this //bookingname2.MiddleName = booking.Passengers[i].Names[0].MiddleName;//uncomment this //passengertraveldocs.DOB = booking.Passengers[i].PassengerTypeInfos[0].DOB;//uncomment this //passengertraveldocs.Gender = booking.Passengers[i].PassengerInfo.Gender;//uncomment this //passengertraveldocs.Nationality = booking.Passengers[i].PassengerInfo.Nationality;//uncomment this //passengertraveldocs.DocTypeCode = "OAFF";//uncomment this //passengertraveldocs.IssuedByCode = "QF";//uncomment this //passengertraveldocs.DocNumber = "6142116";//uncomment this //booking.Passengers[i].PassengerTravelDocuments[0].ExpirationDate = new DateTime(2020, 01, 01);//optional field//uncomment this //passengertraveldocs.IssuedDate = new DateTime(2012, 02, 01);//uncomment this } //------------------------------------------------------------------------------------------------------------------ // start - use this to set the passenger info using the UpdatePassengers method UpdatePassengersRequest updatepassengerrequest = new UpdatePassengersRequest(); updatepassengerrequest.Signature = signature; updatepassengerrequest.updatePassengersRequestData = new UpdatePassengersRequestData(); updatepassengerrequest.updatePassengersRequestData.Passengers = booking.Passengers; clientapi.UpdatePassengers(updatepassengerrequest); // end - use this to set the passenger info using the UpdatePassengers method //---------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------ //booking.BookingContacts = new BookingContact[2];//BookingContacts is an object of class BookingContacct,declariing to create 2 instances of the class [0] & [1] //booking.BookingContacts[0] = new BookingContact();//initialize the object //booking.BookingContacts[0].State = MessageState.New;//state is a propoerty of the BookingContact class //booking.BookingContacts[0].Names = new BookingName[2];//Names is a property of BookingContact class and an onject of BookingName class //booking.BookingContacts[0].Names[0] = new BookingName(); //booking.BookingContacts[0].Names[0].FirstName = "Michelle"; //booking.BookingContacts[0].Names[0].LastName = "Sadhnani"; //booking.BookingContacts[0].Names[0].Title = "Miss"; //if (sourceorg.Length > 0) //{ // booking.BookingContacts[0].SourceOrganization = sourceorg; //} //booking.BookingContacts[0].AddressLine1 = "123 Airport Road"; //booking.BookingContacts[0].AddressLine2 = "Airport Boulevard"; //booking.BookingContacts[0].City = "Singapore"; //booking.BookingContacts[0].CountryCode = "SG"; //booking.BookingContacts[0].EmailAddress = "*****@*****.**"; //booking.BookingContacts[0].OtherPhone = "+659999999"; //booking.BookingContacts[0].TypeCode = "P"; //booking.BookingContacts[0].CultureCode = "en-AU"; //booking.BookingContacts[0].DistributionOption = DistributionOption.Email; //booking.BookingContacts[0].NotificationPreference = NotificationPreference.None; // bookingcommitrequest.BookingCommitRequestData.BookingContacts = booking.BookingContacts; //booking.BookingComments = new BookingComment[2]; //booking.BookingComments[0] = new BookingComment(); //booking.BookingComments[0].CommentText = "This is a one way intl route booking test-PER to DPS"; //booking.BookingComments[0].CommentType = CommentType.Default; //booking.BookingComments[1] = new BookingComment(); //booking.BookingComments[1].CommentText = "Whatever crap"; //booking.BookingComments[1].CommentType = CommentType.Default; //bookingcommitrequest.BookingCommitRequestData.BookingComments = booking.BookingComments; //now call the flight + cc + SSR cost //-------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------- BookingCommitResponse bookingcommitresponse = new BookingCommitResponse(); bookingcommitresponse = clientapi.BookingCommit(bookingcommitrequest); Console.WriteLine("Booking Commited: " + bookingcommitresponse.BookingUpdateResponseData.Success.RecordLocator); // balancedue = bookingfromstateresponse.BookingData.BookingSum.BalanceDue; GetBookingPaymentsRequest getbookingpaymentrequest = new GetBookingPaymentsRequest(); getbookingpaymentrequest.GetBookingPaymentsReqData = new GetBookingPaymentsRequestData(); getbookingpaymentrequest.GetBookingPaymentsReqData.GetCurrentState = true; getbookingpaymentrequest.Signature = signature; GetBookingPaymentsResponse getbookingpaymentresponse = clientapi.GetBookingPayments(getbookingpaymentrequest); // else if (response.Equals("AG")) // { // booking.Payments[0].PaymentMethodType = PaymentMethodType.AgencyAccount; // booking.Payments[0].PaymentMethodCode = "AG"; // if (sourceorg.Length > 0) // { // booking.Payments[0].AccountNumber = sourceorg; // } // else // { // booking.Payments[0].AccountNumber = agentcode; // } // } return null;//--this returns the BooknigUpdateResponseData }
public void Post(SellRequest sellRequest) { }
//--------------------------------------------------------------------------------------------------------------------- public BookingManager.PriceItineraryRequest GetPriceIntineraryRequest(int numadt, int numchd, String faretype, String currency, String sourceorg, String agentcode, GetAvailabilityResponse availresponse) { PriceItineraryRequest priceitinrequest = new PriceItineraryRequest(); priceitinrequest.Signature = signature; priceitinrequest.ItineraryPriceRequest = new ItineraryPriceRequest();// this is from service contract class priceitinrequest.ItineraryPriceRequest.TypeOfSale = new TypeOfSale(); priceitinrequest.ItineraryPriceRequest.TypeOfSale.FareTypes = new string[1]; priceitinrequest.ItineraryPriceRequest.TypeOfSale.FareTypes[0] = faretype; priceitinrequest.ItineraryPriceRequest.SSRRequest = new SSRRequest(); priceitinrequest.ItineraryPriceRequest.PriceItineraryBy = PriceItineraryBy.JourneyWithLegs; SellJourneyByKeyRequestData sellkeyrequest = new SellJourneyByKeyRequestData(); priceitinrequest.ItineraryPriceRequest.SellByKeyRequest = sellkeyrequest; PriceJourneyRequestData pricerequest = new PriceJourneyRequestData(); pricerequest.CurrencyCode = currency; pricerequest.PaxCount = (short)(numadt + numchd);// to check if this is required //setting up the paxdetails to get the pricing correctly, must follow my get avaialbility function call pricerequest.Passengers = new Passenger[numadt + numchd]; for (int i = 0; i < (numadt + numchd); i++) { pricerequest.Passengers[i] = new Passenger();// instantiate to avoid Null Pointer Exception error pricerequest.Passengers[i].State = MessageState.New; pricerequest.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1 if it does not work pricerequest.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo();//change back PassengerTypeInfos to 0 if it doesnt work if (i < numadt) { pricerequest.Passengers[i].PassengerTypeInfos[0].PaxType = "ADT"; } else { pricerequest.Passengers[i].PassengerTypeInfos[0].PaxType = "CHD"; } pricerequest.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("0001-01-01"); } //new set input on 20nd March SellRequest sellrequest = new SellRequest(); sellrequest.Signature = signature; sellrequest.SellRequestData = new SellRequestData(); sellrequest.SellRequestData.SellBy = SellBy.Journey; sellrequest.SellRequestData.SellJourneyRequest = new SellJourneyRequest(); SellResponse sellresponse = clientapi.Sell(sellrequest); //end of input pricerequest.PriceJourneys = new PriceJourney[1];// set this to 1 for a 1 way trip for (int i = 0; i < pricerequest.PriceJourneys.Length; i++) { pricerequest.PriceJourneys[i] = new PriceJourney(); // now i need to get all the available segments for price itinerary Segment[] segment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments; //i want to use the flight designator object for the segment as it contains the carriercode, flight number used to identify a flight Console.WriteLine("Flight Number is :" + segment[i].FlightDesignator.CarrierCode + " " + segment[i].FlightDesignator.FlightNumber); Console.WriteLine("FlightTiming is : " + segment[i].STD + " " + segment[i].STA); PriceSegment[] pricesegment = new PriceSegment[segment.Length];//find the pricing of that particular segment : for a 1 way journey with 2 points, it will be 1 segment SegmentSSRRequest[] ssrRequest = new SegmentSSRRequest[segment.Length]; for (int j = 0; j < segment.Length; j++) { //to setup the segment details and equate the values of price to segment pricesegment[j] = new PriceSegment(); pricesegment[j].ActionStatusCode = "NN"; pricesegment[j].FlightDesignator = segment[j].FlightDesignator; pricesegment[j].DepartureStation = segment[j].DepartureStation; pricesegment[j].ArrivalStation = segment[j].ArrivalStation; pricesegment[j].STA = pricesegment[j].STA; //SSR setup ssrRequest[j] = new SegmentSSRRequest(); ssrRequest[j].DepartureStation = segment[j].DepartureStation; ssrRequest[j].ArrivalStation = segment[j].ArrivalStation; ssrRequest[j].FlightDesignator = segment[j].FlightDesignator; ssrRequest[j].STD = segment[j].STD; //now assume that 1 SSR is tied to 1 passenger to 1 direct flight ssrRequest[j].PaxSSRs = new PaxSSR[1]; ssrRequest[j].PaxSSRs[0] = new PaxSSR(); ssrRequest[j].PaxSSRs[0].ActionStatusCode = "SS"; ssrRequest[j].PaxSSRs[0].DepartureStation = segment[j].DepartureStation; ssrRequest[j].PaxSSRs[0].ArrivalStation = segment[j].ArrivalStation; ssrRequest[j].PaxSSRs[0].SSRCode = "BG20";// type of SSR ssrRequest[j].PaxSSRs[0].SSRNumber = 0;//this is the index of the passenger array, tag the SSR to the first passenger //now set up the Fare according to the GetAvailability Response, no need to choose the option- same as Booking2 Fare fare = segment[j].Fares[0]; pricesegment[j].Fare = new SellFare(); pricesegment[j].Fare.CarrierCode = fare.CarrierCode; pricesegment[j].Fare.ClassOfService = fare.ClassOfService; pricesegment[j].Fare.FareApplicationType = fare.FareApplicationType; pricesegment[j].Fare.FareBasisCode = fare.FareBasisCode; pricesegment[j].Fare.ProductClass = fare.ProductClass; pricesegment[j].Fare.RuleNumber = fare.RuleNumber; } priceitinrequest.ItineraryPriceRequest.SSRRequest.SegmentSSRRequests = ssrRequest; priceitinrequest.ItineraryPriceRequest.PriceItineraryBy = PriceItineraryBy.JourneyWithLegs; priceitinrequest.ItineraryPriceRequest.PriceJourneyWithLegsRequest = pricerequest; } if (sourceorg.Length > 0) { pricerequest.SourcePOS = new PointOfSale(); pricerequest.SourcePOS.AgentCode = agentcode; pricerequest.SourcePOS.OrganizationCode = sourceorg; pricerequest.SourcePOS.DomainCode = "EXT"; pricerequest.SourcePOS.LocationCode = "API"; } else { pricerequest.SourcePOS = null; } //sell my SSR on 22nd March -new input if (priceitinrequest.ItineraryPriceRequest.SSRRequest.SegmentSSRRequests != null) { sellrequest.SellRequestData = new SellRequestData(); sellrequest.SellRequestData.SellSSR = new SellSSR(); sellrequest.SellRequestData.SellSSR.SSRRequest = priceitinrequest.ItineraryPriceRequest.SSRRequest; sellrequest.SellRequestData.SellBy = SellBy.SSR; sellresponse = clientapi.Sell(sellrequest); System.Console.WriteLine("Total Flight + SSR cost {0:C}", sellresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost); } //end of SSR code return priceitinrequest; }
private void button3_Click(object sender, EventArgs e) { SellRequest sr = new SellRequest(); sr.ShowDialog(); }
private void onTimedEvent(Object source, ElapsedEventArgs e) { sql.close(); sql.connect(); MarketUserData MYUSER = new MarketUserData(); MarketUserData myUser = MYUSER.SendQueryUserRequest(); AllMarketCommodityOffer MACO = new AllMarketCommodityOffer(); List <ComInfo> cominfo = MACO.SendQueryAllMarketRequest(); SqlDataReader rdr = sql.sendCommand("SELECT top 100 commodity, AVG(price) as 'average' FROM (SELECT commodity, price, timestamp FROM items where buyer = 20) commodity group by commodity order by commodity"); int counterS = 0; string Scom = ""; while (counterS < 10 && rdr.Read()) { Scom = "" + rdr["commodity"]; if (Convert.ToInt32(Scom) > 3 && myUser.commodities[Scom] > 1) { SellRequest SR = new SellRequest(); int price = Math.Max(Convert.ToInt32(rdr["average"]) + Convert.ToInt32(rdr["average"]) * 20 / 100, cominfo[Convert.ToInt32(rdr["commodity"])].info.bid); int amount = Convert.ToInt32(myUser.commodities[Scom] / 20) + 1; int commodity = Convert.ToInt32(rdr["commodity"]); int response = SR.SendSellRequest(price, commodity, amount); if (response != -1) { DateTime date = DateTime.Now; string sdate = date.ToString(); HistoryItem h = new HistoryItem("Sell", response, Convert.ToInt32(myUser.commodities[Scom] / 20) + 1, price, Convert.ToInt32(rdr["commodity"]), true, sdate); // MessageBox.Show("SellDone");//for test App.Current.Dispatcher.Invoke((Action) delegate { mainWin.History.Insert(0, h); }); string path = "..\\History.txt"; using (StreamWriter wr = File.AppendText(path)) { wr.WriteLine("Request"); wr.WriteLine("sell"); wr.WriteLine(response); wr.WriteLine(Convert.ToInt32(myUser.commodities[Scom] / 20) + 1); wr.WriteLine(price); wr.WriteLine(Convert.ToInt32(rdr["commodity"])); wr.WriteLine("true"); wr.WriteLine(sdate.ToString()); } } counterS++; } } rdr.Close(); SqlDataReader rdr2 = sql.sendCommand("SELECT top 100 commodity, AVG(price) as 'average' FROM (SELECT commodity, price, timestamp FROM items where seller = 20) commodity group by commodity order by commodity"); int counterB = 0; while (counterB < 10 && rdr2.Read()) { Scom = "" + rdr2["commodity"]; if (Convert.ToInt32(Scom) > 3 && myUser.funds > 5000) { BuyRequest SB = new BuyRequest(); int price = Math.Min(Convert.ToInt32(rdr2["average"]) - Convert.ToInt32(rdr2["average"]) * 20 / 100, cominfo[Convert.ToInt32(rdr2["commodity"])].info.ask); int response = SB.sendBuyRequest(price, Convert.ToInt32(rdr2["commodity"]), Convert.ToInt32(myUser.commodities[Scom] / 20) + 1); if (response != -1) { DateTime date = DateTime.Now; string sdate = date.ToString(); HistoryItem h = new HistoryItem("Buy", response, Convert.ToInt32(myUser.commodities[Scom] / 20) + 1, price, Convert.ToInt32(rdr2["commodity"]), true, sdate); //MessageBox.Show("BuyDone");//for test App.Current.Dispatcher.Invoke((Action) delegate { mainWin.History.Insert(0, h); }); string path = "..\\History.txt"; using (StreamWriter wr = File.AppendText(path)) { wr.WriteLine("Request"); wr.WriteLine("buy"); wr.WriteLine(response); wr.WriteLine(Convert.ToInt32(myUser.commodities[Scom] / 10) + 1); wr.WriteLine(price); wr.WriteLine(Convert.ToInt32(rdr2["commodity"])); wr.WriteLine("true"); wr.WriteLine(sdate.ToString()); } } } counterB++; } rdr2.Close(); sql.close(); }
public Task Sell(SellRequest sellRequest, CancellationToken cancellationToken) => this.SendAsync <SellRequest, EmptyResponse>(sellRequest, HttpMethod.Post, "/api/ORCA/v1/sell", cancellationToken);
public async Task <ActionResult <Sale> > Sell([FromBody] SellRequest sellRequest) { var account = await _accountQuery.Evaluate(sellRequest.AccountNumber); if (account == null) { return(NotFound("Account does not exist")); } var currentPrice = await _currentPriceQuery.Evaluate(sellRequest.ProductCode); if (currentPrice == DataAccess.CurrentPriceQuery.ErrorConditions.ProductDoesNotExist) { return(NotFound("Product does not exist")); } if (currentPrice == DataAccess.CurrentPriceQuery.ErrorConditions.PriceDoesNotExist) { return(BadRequest("No valid price")); } if (currentPrice < sellRequest.MinUnitPrice) { return(new Sale() { UnitPrice = currentPrice, Message = $"The current price of {currentPrice} is lower than the minimum you specified of {sellRequest.MinUnitPrice}.", Success = false, ProductCode = sellRequest.ProductCode, }); } var totalIncome = currentPrice * sellRequest.Quantity; var sharesCurrentlyHeld = account.Portfolio.FirstOrDefault(investment => investment.ProductCode == sellRequest.ProductCode)?.Quantity ?? 0; if (sellRequest.Quantity > sharesCurrentlyHeld) { return(new Sale() { UnitPrice = currentPrice, Message = $"You have requested to sell {sellRequest.Quantity} but you only have {sharesCurrentlyHeld}.", Success = false, ProductCode = sellRequest.ProductCode, }); } var transaction = new Transaction() { AccountNumber = account.AccountNumber, Quantity = -sellRequest.Quantity, Time = DateTime.Now, UnitPrice = currentPrice, TotalValue = totalIncome, ProductCode = sellRequest.ProductCode, ID = Guid.NewGuid() }; await _storeTransactionAction.Execute(transaction); return(new Sale() { Message = "Success", Quantity = sellRequest.Quantity, ProductCode = sellRequest.ProductCode, Success = true, TotalValue = totalIncome, UnitPrice = currentPrice, TransactionID = transaction.ID }); }
public SellResponse SellReceiptAccepted(SellModel model, string token) { string operation = "/sell"; string baseUrl = _settings.BaseUrl; decimal Sum = model.Price * model.Quantity; var sellRequest = new SellRequest() { external_id = model.Id, receipt = new Receipt() { client = new Client() { email = model.Email, phone = model.Phone }, company = new Company() { email = _settings.Email, inn = _settings.Inn, sno = _settings.Sno, payment_address = _settings.Payment_address }, items = new Item[] { new Item() { name = model.ItemName, price = model.Price, quantity = model.Quantity, sum = Sum, agent_info = null, measurement_unit = model.MeasurementUnit, payment_method = PaymentMethod.full_payment.ToString("F"), payment_object = PaymentObject.commodity.ToString("F"), vat = new Vat() { type = VatType.vat20.ToString("F"), sum = null } } }, payments = new Payment[] { new Payment() { type = PaymentType.Electronic, sum = Sum } }, total = Sum, vats = null }, service = new Service() { callback_url = "http://kabinet.hm-ges.ru/" }, timestamp = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") }; var client = new RestClient(baseUrl + _settings.GroupCode + operation); var request = new RestRequest(Method.POST); var param = JsonConvert.SerializeObject(sellRequest, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); request.AddHeader("content-type", "application/json"); request.AddHeader("Token", token); request.AddParameter("application/json", param, ParameterType.RequestBody); var response = client.Execute <SellResponse>(request); return(response.Data); }
public async Task <IActionResult> CreateSR(SellRequestVM requestVM)//, string purchasedate, string supplierid, string paid, string remaining)//, [Bind("ItemId", "PurchasePrice", "PurchaseQuantity")] PurchaseRequestDetails[] purchaserequestdetails) { //if (requestVM != null) //{ PurchaseRequestVM itm = (PurchaseRequestVM)requestVM; } string result = "Error! Order Is Not Complete! " + requestVM.InvoiceNumber; if (requestVM != null && requestVM.SellRequestDetails != null) { // check item balance var msg = string.Empty; if (!checkItemBalances(requestVM.SellRequestDetails, out msg)) { return(Json(msg)); } SellRequest sellRequest = new SellRequest(); sellRequest.InvoiceNumber = requestVM.InvoiceNumber; sellRequest.ClientId = requestVM.ClientId; sellRequest.Paid = requestVM.Paid; sellRequest.Remaining = requestVM.Remaining; sellRequest.CreationDate = DateTime.Now; sellRequest.SellDate = requestVM.SellDate; sellRequest.UserId = _userManager.GetUserId(User); var Pr = _context.SellRequest.Add(sellRequest); // add header success if (await _context.SaveChangesAsync() > 0) { // 1- Update Customer Balances var client = _context.Clients.FirstOrDefault(sId => sId.Id == requestVM.ClientId); if (client != null) { client.TotalPaid = (client.TotalPaid == null ? 0 : client.TotalPaid) + requestVM.Paid; client.TotalRemaining = (client.TotalRemaining == null ? 0 : client.TotalRemaining) + requestVM.Remaining; _context.Clients.Update(client); } foreach (var item in requestVM.SellRequestDetails) { SellRequestDetails requestDetails = new SellRequestDetails(); requestDetails.ItemId = item.ItemId; requestDetails.SellPrice = item.SellPrice; requestDetails.SellQuantity = item.SellQuantity; requestDetails.CreationDate = DateTime.Now; requestDetails.SellRequestId = Pr.Entity.Id; requestDetails.UserId = _userManager.GetUserId(User); _context.SellRequestDetails.Add(requestDetails); // 2- Update Items Balances var Newitem = _context.StoreItems.FirstOrDefault(sId => sId.Id == item.ItemId); if (Newitem != null) { Newitem.Quantity = (Newitem.Quantity == null ? 0 : Newitem.Quantity) - item.SellQuantity; _context.StoreItems.Update(Newitem); } } if (await _context.SaveChangesAsync() > 0) { result = "Ok"; } } } return(Json(result)); }
public void SellItems(ObjectId vendor, SellListItem[] items) { var request = new SellRequest(vendor, items); Send(request.RawPacket); }