public static String OperationsToStr(OrderOperations operation) { switch (operation) { case OrderOperations.Open: return "Open"; case OrderOperations.Clsoe: return "Close"; case OrderOperations.Delete: return "Delete"; default: return "Error converting type to str"; } }
public void Execute() { //bool correctData = false; //do //{ string name = GetNameForOrder(); string state = GetStateForOrder(); string productType = GetProductTypeForOrder(); decimal area = GetAreaForOrder(); ProductOperations po = new ProductOperations(); OrderOperations addOrderOperations = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository()); StateOperations so = new StateOperations(); State stateInformation = new State(); Product ProductInfornmation = po.GetProductByName(productType); stateInformation = so.GetStateByName(state); decimal MaterialCost = area * ProductInfornmation.MaterialCostPerSqFoot; decimal LaborCost = area * ProductInfornmation.LaborCostPerSqFoot; decimal TaxTotal = (LaborCost + MaterialCost) * (stateInformation.TaxRate / 100); decimal OrderTotal = MaterialCost + LaborCost + TaxTotal; Order newOrder = new Order() { // OrderNumber = newOrderNumber, CustomerName = name, DateTime = DateTime.Now.ToShortDateString(), State = state, TaxRate = stateInformation.TaxRate, ProductType = ProductInfornmation.ProductType, Area = area, MaterialCostPerSqFt = ProductInfornmation.MaterialCostPerSqFoot, LaborCostPerSqFt = ProductInfornmation.LaborCostPerSqFoot, TotalMaterialCost = MaterialCost, TotalLaborCost = LaborCost, TotalTaxCost = TaxTotal, TotalOrderCost = OrderTotal }; bool isValid = false; string confirm = ""; while (!isValid) { DisplayNewOrder(MaterialCost, LaborCost, TaxTotal, OrderTotal, newOrder); Console.WriteLine(); Console.WriteLine("Is all the information correct?"); Console.WriteLine("Enter (Y) or (N)"); confirm = Console.ReadLine().ToUpper(); if (string.IsNullOrEmpty(confirm)) { isValid = false; Console.WriteLine("Please enter (Y) or (N)"); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else if ((confirm != "N") && (confirm != "Y")) { isValid = false; Console.WriteLine("{0} is not a \"Y\" or \"N\"", confirm); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } else { isValid = true; } } if (confirm == "Y") { var test = addOrderOperations.CreateNewOrder(newOrder); if (test.IsValid) { Console.Clear(); Console.WriteLine(); Console.WriteLine("your order was added"); Console.WriteLine(); Console.WriteLine("The order number is {0}", newOrder.OrderNumber); Console.WriteLine("The date of the order is {0}", newOrder.DateTime); Console.WriteLine(); Console.WriteLine("Press ENTER to Continue."); Console.ReadLine(); } } }
public EditOrderWorkFlow(OrderOperations oops) { _orderToEdit = new Order(); _errorResponse = new ErrorResponse(); _oops = oops; }
public CustomerOrderController(INorthWindTransactionalUnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; orderOperations = new OrderOperations(unitOfWork); this.credentialValidator = CredentialValidationFactory.CreateDefaultInstance(); }
public DisplayOrdersWorkFlow(OrderOperations oops) { _oops = oops; _errorResponse = new ErrorResponse(); }
public void EditOrder() { Console.Clear(); Console.WriteLine("Edit Order"); Console.WriteLine("***************************\n"); bool validDate = false; DateTime orderDate = new DateTime(); int orderNumber = 0; while (!validDate) { Console.Write("Enter a date (MM/DD/YYYY): "); validDate = DateTime.TryParse(Console.ReadLine(), out orderDate); if (!validDate) { Console.WriteLine("\nInvalid Date"); } } OrderOperations orderOperations = new OrderOperations(); OrdersResult result = orderOperations.RetrieveOrdersFor(orderDate); bool validEntry = false; if (result.Success) { while (!validEntry) { bool validNumber = false; while (!validNumber) { Console.Write("\nPlease enter an order number: "); validNumber = int.TryParse(Console.ReadLine(), out orderNumber); if (!validNumber) { Console.WriteLine("\nInvalid order number"); } else { bool reply = orderOperations.CheckIfExistingOrder(orderNumber, orderDate); if (reply) { validEntry = true; } else { Console.WriteLine("\nThere is no order for that number on that date!"); } } } } Order fullOrder = orderOperations.RetrieveOrderByNumber(orderNumber, orderDate); TaxRateOperations taxOps = new TaxRateOperations(); ProductOperations prodOps = new ProductOperations(); CustomerInput editedOrder = new CustomerInput() { CustName = fullOrder.CustomerName, Area = fullOrder.Area, ProductType = fullOrder.ProductType, State = fullOrder.State, OrderNumber = fullOrder.OrderNumber }; Console.WriteLine("\n{0} {1} {2} {3}", editedOrder.CustName, editedOrder.State, editedOrder.ProductType, editedOrder.Area); bool validName = false; string input; while (!validName) { Console.Write("\nPlease enter new Customer Name, or press enter key to skip: "); input = Console.ReadLine(); if (input != "") { editedOrder.CustName = input; validName = true; } else { validName = true; } } bool validState = false; while (!validState) { Console.Write("\nPlease enter new State, or press enter key to skip: "); input = Console.ReadLine().ToUpper(); if (input != "") { if (taxOps.IsAllowedState(input)) { editedOrder.State = input; validState = true; } else { Console.Write("\nThat is not a valid state"); } } else { validState = true; } } bool validProduct = false; while (!validProduct) { Console.Write("\nPlease enter new Product Type, or press enter key to skip: "); input = Console.ReadLine().ToUpper(); if (input != "") { if (prodOps.IsExistingProduct(input)) { editedOrder.ProductType = input; validProduct = true; } else { Console.Write("\nThat is not one of our products"); } } else { validProduct = true; } } bool validArea = false; while (!validArea) { Console.Write("\nPlease enter new Area in square feet, or press enter key to skip: "); input = Console.ReadLine(); if (input != "") { decimal userChoice; bool isDecimal = decimal.TryParse(input, out userChoice); if (isDecimal) { editedOrder.Area = userChoice; validArea = true; } else { Console.WriteLine("\nThat is not a valid number"); } } else { validArea = true; } } Console.Write("\nAre you ready to save edited order details? Y/N "); if (Console.ReadLine().ToUpper() == "N") { MenuDisplay(); } else { orderOperations.CreateNewOrder(editedOrder, orderDate); Order newEditedOrder = orderOperations.RetrieveOrderByNumber(orderNumber, orderDate); Console.Clear(); Console.Write("\nYour order has been edited:\n"); Console.WriteLine("\n{0} {1} {2} {3} {4} {5} {6:c} {7:c} {8:c} {9:c} {10:c} {11:c}", newEditedOrder.OrderNumber, newEditedOrder.CustomerName, newEditedOrder.State, newEditedOrder.TaxRate, newEditedOrder.ProductType, newEditedOrder.Area, newEditedOrder.CostPerSquareFoot, newEditedOrder.LaborCostPerSquareFoot, newEditedOrder.MaterialCost, newEditedOrder.LaborCost, newEditedOrder.Tax, newEditedOrder.Total); Console.Write("\nPress Enter to return to the Main Menu"); Console.ReadLine(); } } else { Console.WriteLine("\nUnable to display orders: {0}", result.Message); } }
public void oopSetup() { _oops = new OrderOperations(); }
//******************************************************************************************************************** public void PasiftekiEmirler_Islem() { string alissatis = "H", seans = "0", hisse = ""; try { OrderOperations isl = new OrderOperations(this); isl.Grid_Initialize1_Replacement(ref gridControl1, ref gridView1, chkedt, this); string hangiseanstayiz = isl.HangiSeanstayiz(); hisse = Emenkul.EditValue.ToString(); alissatis = Ealsat.EditValue.ToString(); if (SECIMDURUMU == 3) //*Tüm müşteriler ise { Ehesapno.Text = "000"; } OrderList beklist = isl.BekleyenEmirler(Ehesapno.EditValue.ToString(), danisman.EditValue.ToString(), hisse, alissatis, seans, frmana.SESSIONDATE); List <Order> lst = beklist.Resultlist; (gridControl1.DataSource as DataTable).Clear(); //* tabloyu temizler. E4.Text = "0"; foreach (Order a in lst) { if (a.Ordinodurumu == "İptal") { continue; } if (a.Tip != "Limit") //* sadece Limit emirlerde fiyat alanı doludur. Diğerlerinde boştur, dolayısıyla iyileştirme olmaz. { continue; } if (SECIMDURUMU == 2) { if ((FIYAT != null) && (FIYAT > 0)) { if (a.Fiyat != FIYAT) { continue; } } } // PasiftekiEmirler_Doldur(a.Saat, a.Hesap, a.Adsoy, a.Menkul, a.Alsat, a.Lot, a.Fiyat, a.Ordinodurumu, a.Seans, a.Danismankodu, a.Transactionid, a.FinInstid, a.Customerid, a.Accountid, a.Gecerlilik, a.Maximumlot, a.Tip, a.Initialmarketsessiondate, a.Endingmarketsessiondate, a.Settlementdate); E4.Text = Convert.ToString(Convert.ToDecimal(E4.Text) + a.Lot); DataRow newrow = (gridControl1.DataSource as DataTable).NewRow(); newrow["CHECK"] = true; newrow["HESAP"] = a.Hesap; newrow["MENKUL"] = a.Menkul; newrow["LOT"] = a.Lot; newrow["FIYAT"] = a.Fiyat; newrow["SAAT"] = a.Saat; newrow["ALSAT"] = a.Alsat; newrow["SEANS"] = a.Seans; newrow["GECERLILIK"] = a.Gecerlilik; newrow["TRANSACTIONID"] = a.Transactionid; newrow["FININSTID"] = a.FinInstid; newrow["CUSTOMERID"] = a.Customerid; newrow["ACCOUNTID"] = a.Accountid; newrow["MAXIMUMLOT"] = a.Maximumlot; newrow["TIP"] = a.Tip; //*2015-11-10 00:00:00.000 newrow["INITIAL_MARKET_SESSION_DATE"] = String.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", a.Initialmarketsessiondate); // Convert.ToString(initialmarketsessiondate); newrow["ENDING_MARKET_SESSION_DATE"] = String.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", a.Endingmarketsessiondate); // Convert.ToString(endingmarketsessiondate); newrow["SETTLEMENT_DATE"] = String.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", a.Settlementdate); // Convert.ToString(settlementdate); newrow["INITIAL_MARKET_SESSION_SEL"] = a.Initialmarketsessionsel; newrow["ENDING_MARKET_SESSION_SEL"] = a.Endingmarketsessionsel; newrow["LAK"] = a.Lak; (gridControl1.DataSource as DataTable).Rows.Add(newrow); } isl = null; beklist = null; lst = null; } catch (Exception ex) { } }
public ActionResult <string> AddToCart(AddToCartRequest request) { return(Ok(OrderOperations.AddToCart(request.productId, request.email))); }
public ActionResult <string> GetCartDetail(CartDetailRequest request) { return(Ok(OrderOperations.GetCartDetail(request.customerId))); }
public void BubbleSortTheArrayDescTest(int[] a, int[] expected) { int[] actual = OrderOperations.BubbleSortTheArrayDesc(a); Assert.AreEqual(expected, actual); }
public void InsertSortTheArrayAscTest(int[] a, int[] expected) { int[] actual = OrderOperations.InsertSortTheArrayAsc(a); Assert.AreEqual(expected, actual); }
public void InterchangeTheArrayByTheCentreTest(int[] a, int[] expected) { int[] actual = OrderOperations.InterchangeTheArrayByTheCentre(a); Assert.AreEqual(expected, actual); }
public void ReverseTheArrayTest(int[] a, int[] expected) { int[] actual = OrderOperations.ReverseTheArray(a); Assert.AreEqual(expected, actual); }
//******************************************************************************************************************** private void simpleButton1_Click(object sender, EventArgs e) { string TransactionId, alsat, debitcredit = "", fininstid, customerid, accountid, valuedate, initialmarketdate, tip, gecerlilik, lak; decimal units, price; Int32 initialMarketSessionSel, EndingMarketSessionSel, orderMaxlot; string taban = "0", tavan = "0"; bool secili; decimal ekrlot; int satirsayisi = gridView1.RowCount; if (satirsayisi == 0) { System.Windows.Forms.MessageBox.Show("İyileştirme yapılacak seçili hiçbir kayıt bulunamadı."); return; } if ((yenifiyat.Text == null) || (yenifiyat.Text.Trim().Length == 0)) { ekrlot = 0; } else { ekrlot = Convert.ToDecimal(yenifiyat.Text); } OrderOperations op = new OrderOperations(this); if (ekrlot == 0) { System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Serbest Fiyatlı emir girişi yapmaktasınız. Devam etmek istiyormusunuz ?", "Onay", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { return; } DataTable Tablo1 = op.FiyatKademeListesi_Al(this, Emenkul.Text); for (int i = 0; i < Tablo1.Rows.Count; i++) { taban = Tablo1.Rows[i]["VALUE10"].ToString(); tavan = Tablo1.Rows[i]["VALUE11"].ToString(); } } System.Windows.Forms.DialogResult dialogResult2 = System.Windows.Forms.MessageBox.Show("Toplu İyileştirme İşlemi Yapıyorsunuz. İşlemi Onaylıyormusunuz ?", "Onay", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult2 == System.Windows.Forms.DialogResult.No) { return; } for (int i = 0; i < gridView1.RowCount; i++) { secili = Convert.ToBoolean(gridView1.GetRowCellValue(i, "CHECK")); if (secili == true) { TransactionId = gridView1.GetRowCellValue(i, "TRANSACTIONID").ToString(); alsat = gridView1.GetRowCellValue(i, "ALSAT").ToString(); if (alsat == "A") { debitcredit = "CREDIT"; } else if (alsat == "S") { debitcredit = "DEBIT"; } if (yenifiyat.Text.Trim().Length == 0) //*Eğer serbest fiyatlı emir ise Alışta:tavan , Satışta:taban fiyat uygula. { if (alsat == "A") { yenifiyat.Text = tavan; } else if (alsat == "S") { yenifiyat.Text = taban; } } fininstid = gridView1.GetRowCellValue(i, "FININSTID").ToString(); units = Convert.ToDecimal(gridView1.GetRowCellValue(i, "LOT").ToString()); price = Convert.ToDecimal(yenifiyat.Text); customerid = gridView1.GetRowCellValue(i, "CUSTOMERID").ToString(); accountid = gridView1.GetRowCellValue(i, "ACCOUNTID").ToString(); initialmarketdate = gridView1.GetRowCellValue(i, "INITIAL_MARKET_SESSION_DATE").ToString(); valuedate = gridView1.GetRowCellValue(i, "SETTLEMENT_DATE").ToString(); initialMarketSessionSel = Convert.ToInt32(gridView1.GetRowCellValue(i, "INITIAL_MARKET_SESSION_SEL").ToString()); EndingMarketSessionSel = Convert.ToInt32(gridView1.GetRowCellValue(i, "ENDING_MARKET_SESSION_SEL").ToString());; orderMaxlot = Convert.ToInt32(gridView1.GetRowCellValue(i, "MAXIMUMLOT").ToString()); tip = gridView1.GetRowCellValue(i, "TIP").ToString(); gecerlilik = gridView1.GetRowCellValue(i, "GECERLILIK").ToString(); lak = gridView1.GetRowCellValue(i, "LAK").ToString(); bool OrdinoBorsayaIletildimi = op.OrdinoBorsayaIletildimi(TransactionId); //* Sistemde bekliyor , yada borsada... if (OrdinoBorsayaIletildimi == false) { Sistemden_Iyilestir(TransactionId, debitcredit, fininstid, units, price, customerid, accountid, valuedate, initialmarketdate, initialMarketSessionSel, EndingMarketSessionSel, orderMaxlot, tip, gecerlilik, lak); } else { Borsadan_Iyilestir(TransactionId, price, units, units, gecerlilik, initialmarketdate); } } } System.Threading.Thread.Sleep(500); FIYAT = Convert.ToDecimal(yenifiyat.Text); yenifiyat.Text = ""; frmana.HisseAlSat_Ekran_Tazele(); PasiftekiEmirler_Islem(); //* Close(); }
//******************************************************************************************************************** public void Borsadan_Iyilestir(string TransactionId, decimal improveprice, decimal improveunits, decimal oldunits, string gecerlilik, string initialmarketdate) { OrderOperations op = new OrderOperations(this); string donus = op.Save_Improve_Order(TransactionId, improveprice, improveunits, oldunits, gecerlilik, initialmarketdate); }
public ActionResult <string> CreateOrder(CreateOrderRequest request) { return(Ok(OrderOperations.CreateOrder(request.customerId, request.addressId))); }
//******************************************************************************************************************* private void simpleButton2_Click(object sender, EventArgs e) { DataTable Tablo1; string BugunkuTarih = "", TakasTarihi = "", alsat = "", menkul = "", debitcredit = "", fininstid = "", custId = "", accId = "", donus = ""; string EquityTransactionTypeId = "0000-000001-ETT"; //* defaultu LOT olsun. string OrderType = "0000-000001-ETT"; string TimeInForce = "0"; //Gün decimal adet, fyt; Int32 maxlot = 0; Int32 InitialMarketSessionSel = 1, EndingMarketSessionSel = 2; int satirsayisi = gridView1.RowCount; if (satirsayisi == 0) { System.Windows.Forms.MessageBox.Show("Aktarım yapılacak hiçbir kayıt bulunamadı."); return; } if ((musteri.Text == null) || (musteri.Text.Trim().Length == 0)) { System.Windows.Forms.MessageBox.Show("Müşteri seçiniz."); return; } if ((!piyasa.Checked) && (!piyasadanlimite.Checked) && (!denge.Checked)) { System.Windows.Forms.MessageBox.Show("'Piyasa , Piyasadan Limite , Denge' birini seçiniz ! "); return; } if (piyasa.Checked) { TimeInForce = "3"; //* Piyasa emrinde TimeInForce=3 KİE olmalı. } else if (piyasadanlimite.Checked) { if (gunluk.Checked) { TimeInForce = "0"; //* TimeInForce=0 günlük yaptım. TimeInForce=3 KİE de olabilirdi } else if (kie.Checked) { TimeInForce = "3"; //* Piyasa emrinde TimeInForce=3 KİE olmalı. } } else if (denge.Checked) { TimeInForce = "9"; //* Denge emirlerinde TimeInForce=9 EFG olmalı } System.Windows.Forms.DialogResult dialogResult2 = System.Windows.Forms.MessageBox.Show("Toplu Aktarım İşlemi Yapıyorsunuz. İşlemi Onaylıyormusunuz ?", "Onay", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult2 == System.Windows.Forms.DialogResult.No) { return; } OrderOperations op = new OrderOperations(); op.TarihBilgileri_Al(this, ref BugunkuTarih, ref TakasTarihi); string hangiseanstayiz = op.HangiSeanstayiz(); //* sql server üzerinden zamanı alalım. if (hangiseanstayiz == "1") //* Eğer 1. seanstaysak { InitialMarketSessionSel = 1; EndingMarketSessionSel = 2; } else if (hangiseanstayiz == "2") //* 2. seanstaysak { InitialMarketSessionSel = 1; EndingMarketSessionSel = 1; } if (piyasa.Checked) { EquityTransactionTypeId = "0000-000010-ETT"; OrderType = "0000-000010-ETT"; } else if (piyasadanlimite.Checked) { EquityTransactionTypeId = "0000-000011-ETT"; OrderType = "0000-000011-ETT"; } else if (denge.Checked) { EquityTransactionTypeId = "0000-000012-ETT"; OrderType = "0000-000012-ETT"; } label2.Visible = true; label2.Refresh(); for (int i = 0; i < gridView1.RowCount; i++) { alsat = gridView1.GetRowCellValue(i, "ALSAT").ToString(); menkul = gridView1.GetRowCellValue(i, "MENKUL").ToString(); if (alsat == "S") { debitcredit = "DEBIT"; } else { debitcredit = "CREDIT"; } Tablo1 = op.FiyatKademeListesi_Al(this, menkul); if (Tablo1.Rows.Count > 0) //* sadece ilk recordu alalım. En son seansa aitttir. { fininstid = Convert.ToString(Tablo1.Rows[0]["FIN_INST_ID"]); maxlot = Convert.ToInt32(Tablo1.Rows[0]["MAX_LOT"]); } op.MusteriBilgisi_Detay(this, musteri.Text, ref custId, ref accId); fyt = Convert.ToDecimal("0"); adet = Convert.ToDecimal(gridView1.GetRowCellValue(i, "ADET").ToString()); donus = op.Save_Equity_Order(BugunkuTarih, TakasTarihi, fininstid, debitcredit, custId, accId, maxlot, fyt, adet, InitialMarketSessionSel, EndingMarketSessionSel, EquityTransactionTypeId, OrderType, TimeInForce); if (donus.Trim().Length == 0) { gridView1.SetRowCellValue(i, "AKIBET", "OK"); } else { gridView1.SetRowCellValue(i, "AKIBET", donus); } } label2.Visible = false; label2.Refresh(); }
public MainMenu(OrderOperations oops) { _oops = oops; }
public void AddOrder() { OrderOperations orderOps = new OrderOperations(); CustomerInput custIn = new CustomerInput(); bool isValidName = false; Console.Clear(); Console.WriteLine("Add Order"); Console.WriteLine("***************************\n"); while (!isValidName) { Console.Write("Please enter the customer name: "); custIn.CustName = Console.ReadLine(); isValidName = !string.IsNullOrEmpty(custIn.CustName); } bool isValidState = false; while (!isValidState) { Console.Write("\nPlease enter a state: "); custIn.State = Console.ReadLine().ToUpper(); TaxRateOperations taxOps = new TaxRateOperations(); if (taxOps.IsAllowedState(custIn.State)) { Console.WriteLine("\nThat is a valid state"); TaxRate rate = taxOps.GetTaxRateFor(custIn.State); isValidState = true; Console.WriteLine("\nThe tax rate for {0} is {1:p}", rate.State, rate.TaxPercent); } else { Console.WriteLine("\nThat is not a valid state"); } } bool isValidProduct = false; while (!isValidProduct) { Console.Write("\nPlease enter a product type: "); custIn.ProductType = Console.ReadLine(); ProductOperations prodOps = new ProductOperations(); if (prodOps.IsExistingProduct(custIn.ProductType)) { Console.WriteLine("\nThat is a valid product."); Product prod = prodOps.GetProductFor(custIn.ProductType); isValidProduct = true; } else { Console.WriteLine("\nThat is not one of our products."); } } bool isValidArea = false; while (!isValidArea) { Console.Write("\nPlease enter flooring area in square feet: "); decimal floorArea; bool isDecimal = decimal.TryParse(Console.ReadLine(), out floorArea); if (isDecimal) { isValidArea = true; custIn.Area = floorArea; } } Console.Write("\nReady to create new order? Y/N "); if (Console.ReadLine().ToUpper() == "N") { MenuDisplay(); } custIn.OrderNumber = 0; DateTime orderDate = default(DateTime); orderOps.CreateNewOrder(custIn, orderDate); Console.WriteLine("\nOk, your order has been created!"); Console.ReadLine(); }
private static void PromptDisplayOrders() { DateTime?date = PromptForValidOrderDate(); if (date == null) { return; } List <Order> potentialOrders = OrderOperations.GetOrdersByDate((DateTime)date); Order orderToDisplay = SelectFromOrders(potentialOrders); bool validInput = false; bool error = false; while (!validInput) { DisplayOrder(orderToDisplay); //give options to edit or remove the order Console.ForegroundColor = EmphasisColor; Console.Write("\t1. "); Console.ResetColor(); Console.WriteLine("Edit this order"); Console.ForegroundColor = EmphasisColor; Console.Write("\t2. "); Console.ResetColor(); Console.WriteLine("Remove this order"); Console.ForegroundColor = EmphasisColor; Console.Write("\t3. "); Console.ResetColor(); Console.WriteLine("Return to the main menu"); Console.WriteLine(); if (error) { Console.ForegroundColor = ErrorColor; Console.WriteLine("Enter 1, 2, or 3."); Console.ResetColor(); Console.WriteLine(); } Console.ForegroundColor = PromptColor; Console.Write("\tEnter an option: "); Console.ForegroundColor = EmphasisColor; string userInput = Console.ReadLine().Trim(); Console.ResetColor(); Console.Clear(); switch (userInput) { case "1": case "1.": PromptEditOrder(orderToDisplay); validInput = true; break; case "2": case "2.": PromptRemoveOrder(orderToDisplay); validInput = true; break; case "3": case "3.": case "": return; default: error = true; continue; } } }
public void DeleteOrder() { Console.Clear(); Console.WriteLine("Delete Order"); Console.WriteLine("***************************\n"); bool validDate = false; DateTime orderDate = new DateTime(); int orderNumber = 0; while (!validDate) { Console.Write("Enter a date (MM/DD/YYYY): "); validDate = DateTime.TryParse(Console.ReadLine(), out orderDate); if (!validDate) { Console.WriteLine("\nInvalid Date"); } } OrderOperations orderOperations = new OrderOperations(); OrdersResult result = orderOperations.RetrieveOrdersFor(orderDate); bool validEntry = false; if (result.Success) { while (!validEntry) { bool validNumber = false; while (!validNumber) { Console.Write("\nPlease enter an order number: "); validNumber = int.TryParse(Console.ReadLine(), out orderNumber); if (!validNumber) { Console.WriteLine("\nInvalid order number"); } else { bool reply = orderOperations.CheckIfExistingOrder(orderNumber, orderDate); if (reply) { validEntry = true; } else { Console.WriteLine("\nThere is no order for that number on that date!"); } } } } Order fullOrder = orderOperations.RetrieveOrderByNumber(orderNumber, orderDate); Console.WriteLine("\n{0} {1} {2} {3} {4} {5} {6:c} {7:c} {8:c} {9:c} {10:c} {11:c}", fullOrder.OrderNumber, fullOrder.CustomerName, fullOrder.State, fullOrder.TaxRate, fullOrder.ProductType, fullOrder.Area, fullOrder.CostPerSquareFoot, fullOrder.LaborCostPerSquareFoot, fullOrder.MaterialCost, fullOrder.LaborCost, fullOrder.Tax, fullOrder.Total); Console.Write("\nAre you sure you want to delete this file? Y/N "); if (Console.ReadLine().ToUpper() == "Y") { if (orderOperations.CallDelete(fullOrder, orderDate)) { Console.WriteLine("\nThe order has been deleted."); Console.WriteLine("\nPress Enter to return to Main Menu"); Console.ReadLine(); } else { Console.WriteLine("\nFor some reason the order failed to delete..."); Console.WriteLine("\nPress Enter to return to Main Menu"); Console.ReadLine(); } } else { MenuDisplay(); } } else { Console.WriteLine("\nUnable to display orders: {0}", result.Message); } }
//order selection/display methods ********************************************************* private static DateTime?PromptForValidOrderDate() { DateTime dateToReturn = DateTime.Today; //initialized value should never be used DateTime dateToGenerateSuggestions = DateTime.Today; List <DateTime> closeValidDates; bool validInput = false; bool wasCorrectFormat = true; bool noOrdersFound = false; while (!validInput) { Console.Clear(); OffsetTop(); closeValidDates = DisplayCloseValidDates(dateToGenerateSuggestions); if (closeValidDates.Count == 0) { Console.SetCursorPosition(0, Console.CursorTop - 1); Console.ForegroundColor = ErrorColor; Console.WriteLine("\tThere are no orders in the system."); Console.WriteLine("\tPlease add an order."); Console.WriteLine(); Console.ForegroundColor = PromptColor; Console.Write("\tPress enter to continue..."); Console.ResetColor(); Console.ReadLine(); Console.Clear(); return(null); } Console.WriteLine("\t(Press enter for most recent valid date)"); Console.WriteLine(); if (!wasCorrectFormat) { Console.ForegroundColor = ErrorColor; Console.WriteLine("\tPlease format your date as MM/DD/YYYY\n"); Console.ResetColor(); } wasCorrectFormat = true; if (noOrdersFound) { Console.ForegroundColor = ErrorColor; Console.WriteLine("\tNo orders were found for that date."); Console.WriteLine("\tTry one of the dates above."); Console.WriteLine(); Console.ResetColor(); } noOrdersFound = false; //prompt Console.ForegroundColor = PromptColor; Console.Write("\tWhat date is the order? "); //get user input Console.ForegroundColor = EmphasisColor; string userInput = Console.ReadLine().Trim(); Console.ResetColor(); int userNumberSelection = 0; if (String.IsNullOrEmpty(userInput)) { //If input is empty then use most recent date. validInput = true; dateToReturn = OrderOperations.GetValidDates().Last(); } else if (int.TryParse(userInput, out userNumberSelection) && userNumberSelection > 0 && userNumberSelection <= closeValidDates.Count) { //they selected one of the displayed dates dateToReturn = closeValidDates[userNumberSelection - 1]; validInput = true; } else { wasCorrectFormat = DateTime.TryParse(userInput, out dateToReturn); if (wasCorrectFormat) { if (OrderOperations.GetOrdersByDate(dateToReturn).Any()) {//orders were found and we got a valid date validInput = true; } else { noOrdersFound = true; dateToGenerateSuggestions = DateTime.Parse(userInput); } } } } Console.Clear(); return(dateToReturn); }
private static Order EditOrder(Order orderToEdit) { bool doneEditing = false; bool hadError = false; int fieldChanged = 0; while (!doneEditing) { //display order info with edit options, coloring items that have been changed OffsetTop(); int fieldNameFormatter = -18; int fieldValueLength = 0; Console.ForegroundColor = EmphasisColor; Console.WriteLine("\tEdit Order"); Console.WriteLine("\t-----------------------------------"); Console.ResetColor(); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + "}", "Order Date:", orderToEdit.Date.ToString("d")); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + "}", "Order #:", orderToEdit.Number); Console.ForegroundColor = EmphasisColor; Console.Write("\t1. "); Console.ResetColor(); if (fieldChanged == 1) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("{0," + fieldNameFormatter + "}{1," + fieldValueLength + "}", "Customer Name:", orderToEdit.CustomerName); Console.ForegroundColor = EmphasisColor; Console.Write("\t2. "); Console.ResetColor(); if (fieldChanged == 2) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("{0," + fieldNameFormatter + "}{1," + fieldValueLength + "}", "State:", orderToEdit.State); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":P}", "Tax Percent:", orderToEdit.TaxPercent * 0.01M); Console.ForegroundColor = EmphasisColor; Console.Write("\t3. "); Console.ResetColor(); if (fieldChanged == 3) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("{0," + fieldNameFormatter + "}{1," + fieldValueLength + "}", "Product Type:", orderToEdit.ProductType); Console.ForegroundColor = EmphasisColor; Console.Write("\t4. "); Console.ResetColor(); if (fieldChanged == 4) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("{0," + fieldNameFormatter + "}{1," + fieldValueLength + ":n0}" + " sq feet", "Area:", orderToEdit.Area); Console.ResetColor(); if (fieldChanged == 3) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Cost per sq ft:", orderToEdit.CostPerSquareFoot); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Labor cost/sq ft:", orderToEdit.LaborCostPerSquareFoot); if (fieldChanged == 4) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Material Cost:", orderToEdit.MaterialCost); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Labor Cost:", orderToEdit.LaborCost); if (fieldChanged == 2) { Console.ForegroundColor = SuccessColor; } Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Tax:", orderToEdit.Tax); Console.WriteLine("\t" + " {0," + fieldNameFormatter + "}{1," + fieldValueLength + ":C}", "Total:", orderToEdit.Total); Console.ResetColor(); Console.ForegroundColor = EmphasisColor; Console.WriteLine("\t-----------------------------------"); //display confirm/cancel options Console.ForegroundColor = EmphasisColor; Console.Write("\t5. "); Console.WriteLine("Confirm edit"); Console.Write("\t6. "); Console.WriteLine("Cancel and return to menu"); Console.ResetColor(); Console.WriteLine(); //display error message if (hadError) { Console.ForegroundColor = ErrorColor; Console.WriteLine("\tInvalid entry."); Console.WriteLine(); Console.ResetColor(); } // get user input Console.ForegroundColor = PromptColor; Console.Write("\tEnter an option: "); Console.ForegroundColor = EmphasisColor; string userInput = Console.ReadLine().Trim(); Console.ResetColor(); switch (userInput) { case "1": case "1.": //enter new name Console.Clear(); string newName = ""; while (string.IsNullOrEmpty(newName)) { Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = PromptColor; Console.Write("\tEnter the new customer name: "); Console.ForegroundColor = EmphasisColor; newName = Console.ReadLine(); Console.ResetColor(); Console.Clear(); } orderToEdit.CustomerName = newName; fieldChanged = 1; hadError = false; break; case "2": case "2.": //enter new state Console.Clear(); orderToEdit.State = PromptForValidState("Enter the new state: "); orderToEdit = OrderOperations.CalculateRemainingOrderFields(orderToEdit, false); Console.Clear(); fieldChanged = 2; hadError = false; break; case "3": case "3.": //enter new product type Console.Clear(); orderToEdit.ProductType = PromptForValidProductType("Enter the new product type: ").Type; orderToEdit = OrderOperations.CalculateRemainingOrderFields(orderToEdit, false); Console.Clear(); fieldChanged = 3; hadError = false; break; case "4": case "4.": //enter new area Console.Clear(); ProductType currentProductType = ProductTypeOperations.GetProductType(orderToEdit.ProductType); orderToEdit.Area = PromptForValidArea(currentProductType); orderToEdit = OrderOperations.CalculateRemainingOrderFields(orderToEdit, false); Console.Clear(); fieldChanged = 4; hadError = false; break; case "5": case "5.": //confirm order Console.Clear(); doneEditing = true; break; case "6": case "6.": //cancel and return to main menu Console.Clear(); return(null); default: //invalid input Console.Clear(); hadError = true; break; } } return(orderToEdit); }
public OrderOperationsController(AppDbContext appDbContext) { orderOperationsBusinessLogic = new OrderOperations(appDbContext); }