public Form_OrderManage() { InitializeComponent(); UserManager_Client = (UserManagerClient)ClientFactory.GetClient(ClientType.Type.UserManager); Type_Client = (TypeClient)ClientFactory.GetClient(ClientType.Type.Type); Action_Client = (ActionClient)ClientFactory.GetClient(ClientType.Type.Action); Version_Client = (VersionClient)ClientFactory.GetClient(ClientType.Type.Version); Order_Client = (OrderClient)ClientFactory.GetClient(ClientType.Type.Order); OrderSummery_Client = (OrderSummeryClient)ClientFactory.GetClient(ClientType.Type.OrderSummery); ShopID = GlobalParams.ShopID; if (ShopID < 0) { MessageBox.Show("您不属于任何店铺,请联系系统管理员分配您的店铺所属!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.Close(); } else { List_Version = Version_Client.SelectAllVersions().Where(P => P.Version_Shop == ShopID).ToList(); } List_Action = Action_Client.SelectAllActions().ToList(); List_Type = Type_Client.SelectAllTypes().ToList(); List_UserEX = UserManager_Client.SelectUserEXInfo_All().ToList(); List_User = UserManager_Client.SelectUserInfo_All().ToList(); PL_NewUser.Visible = false; PL_UserResult.Visible = false; Bind_Action(); Bind_Type(); Bind_Version(); }
private static void GetMatchResults() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); var request = new GetRequest() .AddParam("symbol", "btcusdt"); var response = tradeClient.GetMatchResultsAsync(request).Result; switch (response.status) { case "ok": { if (response.data != null) { foreach (var r in response.data) { Console.WriteLine($"Match result symbol: {r.symbol}, amount: {r.filledAmount}, fee: {r.filledFees}"); } Console.WriteLine($"There are total {response.data.Length} match results"); } break; } case "error": { Console.WriteLine($"Get mattch result fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public IHttpActionResult PostOrder(OrderClient orderClient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Order orderDB = new Order(); orderDB.Concepts = new List <Concept>(); orderDB.Fecha = orderClient.Fecha; orderDB.Status = Status.Solicitado; foreach (var conceptClient in orderClient.ConceptClients) { Product product = db.Products.FirstOrDefault(x => x.ProductId == conceptClient.ConceptId); Concept concept = new Concept() { Product = product, Cantidad = conceptClient.Cantidad }; //product.Vendido += concept.Cantidad; orderDB.Concepts.Add(concept); } db.Orders.Add(orderDB); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = orderDB.OrderId }, orderClient)); }
private static void GetLast48hOrders() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new GetRequest() .AddParam("symbol", "btcusdt"); var response = tradeClient.GetLast48hOrdersAsync(request).Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { foreach (var o in response.data) { AppLogger.Info($"Order symbol: {o.symbol}, amount: {o.amount}, state: {o.state}"); } AppLogger.Info($"There are total {response.data.Length} history orders"); } break; } case "error": { AppLogger.Info($"Get history orders fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public OrderModel(IOrderEntityFactory entityFactory, coreModel.Order innerItem, OrderClient client, IOrderService orderService) { _entityFactory = entityFactory; _innerItem = innerItem; _OrderClient = client; _orderService = orderService; }
public ActionResult Index() { try { if (Session["accountID"] != null) { List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList(); List<ProductOrder> allPO = new List<ProductOrder>(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetWarrantyUnexpiredOrdersByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } return View("Index", allPO); } else { return RedirectToAction("Login", "Login"); } } catch (Exception e) { ViewBag.Error = "An error has occured."; return View("Index", new List<ProductOrder>()); } }
private static void GetOpenOrders() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); var request = new GetRequest() .AddParam("account-id", Config.AccountId); var response = tradeClient.GetOpenOrdersAsync(request).Result; switch (response.status) { case "ok": { if (response.data != null) { foreach (var o in response.data) { Console.WriteLine($"Order symbol: {o.symbol}, price: {o.price}, amount: {o.amount}"); } Console.WriteLine($"There are total {response.data.Length} open orders"); } break; } case "error": { Console.WriteLine($"Query open orders fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
private static void CancelOrdersByCriteria() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new CancelOrdersByCriteriaRequest { AccountId = Config.AccountId }; var response = tradeClient.CancelOrdersByCriteriaAsync(request).Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { var d = response.data; AppLogger.Info($"Cancel success: {d.successCount}, fail: {d.failedCount}, next: {d.nextId}"); } break; } case "error": { AppLogger.Info($"Cancel orders fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public ActionResult FilterTransactions(string dateFrom, string dateTo) { if ((dateFrom != null || dateFrom != "") && (dateTo != null || dateTo != "")) { DateTime from = Convert.ToDateTime(dateFrom); DateTime to = Convert.ToDateTime(dateTo); if (Session["accountID"] != null) { List<Order> orderList = new OrderClient().getOrdersByAccountAndDates((int)Session["accountID"], from, to).ToList(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } return View("PurchaseHistory", allPO); } else { return RedirectToAction("Login", "Login"); } } else { return View("PurchaseHistory", allPO); } }
private static void GetTransactFeeRate() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new GetRequest() .AddParam("symbols", "btcusdt,eosht"); var response = tradeClient.GetTransactFeeRateAsync(request).Result; _logger.StopAndLog(); if (response.code == (int)ResponseCode.Success) { if (response.data != null) { foreach (var f in response.data) { AppLogger.Info($"Symbol: {f.symbol}, maker-taker fee: {f.makerFeeRate}-{f.takerFeeRate}"); } } } else { AppLogger.Info($"Get transact fee rate error: {response.message}"); } }
public static void ShowClient(OrderClient client) { if (client != null) { Console.WriteLine("{0}:{1}", client.ClientName, client.Address); } }
private static void GetHistoryOrders() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); var request = new GetRequest() .AddParam("symbol", "btcusdt") .AddParam("states", "canceled"); var response = tradeClient.GetHistoryOrdersAsync(request).Result; switch (response.status) { case "ok": { if (response.data != null) { foreach (var o in response.data) { Console.WriteLine($"Order symbol: {o.symbol}, amount: {o.amount}, state: {o.state}"); } Console.WriteLine($"There are total {response.data.Length} history orders"); } break; } case "error": { Console.WriteLine($"Get history orders fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public ReturnBuilder(IOrderEntityFactory entityFactory, IPricelistRepository priceListRepository, OrderClient client, IOrderService service) { _entityFactory = entityFactory; _priceListRepository = priceListRepository; _client = client; _orderService = service; }
private static void ReteriveOrdersAndEditUsingDisconnectedEntityOverWire() { OrderClient orderservice = new OrderClient(); Order order = orderservice.GetOrderDetailsByKey(6); // Order Edit order.Comment = "Comment2"; order.State = State.Modified; // Line Item Edit order.LineItems.Where(i => i.LineItemId == 1).FirstOrDefault().OrderQty = 900; order.LineItems.Where(i => i.LineItemId == 1).FirstOrDefault().State = State.Modified; //Line Item Delete order.LineItems.Where(i => i.LineItemId == 4).FirstOrDefault().State = State.Deleted; //New Line Item Added var orderlineitem = new LineItem { OrderQty = 999, ProductId = 1, Order = order, UnitPrice = 5000, State = State.Added }; order.LineItems.Add(orderlineitem); orderservice.AddUpdateOrders(order); }
private static void PlaceAnOrder(string symbol, string price, string amount) { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); var request = new PlaceOrderRequest { AccountId = Config.AccountId, type = "sell-limit", symbol = symbol, source = "spot-api", amount = amount, price = price }; var response = tradeClient.PlaceOrderAsync(request).Result; switch (response.status) { case "ok": { AppLogger.Info($"Place order successfully, order id: {response.data}"); break; } case "error": { AppLogger.Info($"Place order fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public MolliePaymentsProcessor(IWebHelper webHelper, ILocalizationService localizationService, ISettingService settingService, IHttpContextAccessor httpContextAccessor, IAddressService addressService, IStateProvinceService stateProvinceService, ICountryService countryService, ICurrencyService currencyService, IProductService productService, IOrderService orderService, CurrencySettings currencySettings, MollieStandardPaymentSettings mollieStandardPaymentSettings) { _webHelper = webHelper; _localizationService = localizationService; _settingService = settingService; _httpContextAccessor = httpContextAccessor; _addressService = addressService; _stateProvinceService = stateProvinceService; _countryService = countryService; _currencyService = currencyService; _currencySettings = currencySettings; _productService = productService; _orderService = orderService; _mollieStandardPaymentSettings = mollieStandardPaymentSettings; _mollieOrderClient = MollieAPIClients.MollieOrderClient( _mollieStandardPaymentSettings.UseSandbox, GetKeysDictionary()); _refundClient = MollieAPIClients.MollieRefundClient( _mollieStandardPaymentSettings.UseSandbox, GetKeysDictionary()); }
private static void GetMatchResults() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new GetRequest() .AddParam("symbol", "htusdt") .AddParam("start-date", "2020-11-02"); var response = tradeClient.GetMatchResultsAsync(request).Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { foreach (var r in response.data) { AppLogger.Info($"Match result order id: {r.orderId}, symbol: {r.symbol}, price: {r.price}, amount: {r.filledAmount}, fee: {r.filledFees}, state: {r.feeDeductState}"); } AppLogger.Info($"There are total {response.data.Length} match results"); } break; } case "error": { AppLogger.Info($"Get mattch result fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
private static void PlaceOrder() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new PlaceOrderRequest { AccountId = Config.AccountId, type = "buy-limit", symbol = "btcusdt", source = "spot-api", amount = "1", price = "1.1" }; var response = tradeClient.PlaceOrderAsync(request).Result; _logger.StopAndLog(); switch (response.status) { case "ok": { AppLogger.Info($"Place order successfully, order id: {response.data}"); break; } case "error": { AppLogger.Info($"Place order fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
public OrderController() { _productClient = new ProductClient(); _employeeClient = new EmployeeClient(); _orderClient = new OrderClient(); _customerClient = new CustomerClient(); }
private static void GetOrderById() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var response = tradeClient.GetOrderByIdAsync("1").Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { var o = response.data; AppLogger.Info($"Order symbol: {o.symbol}, price: {o.price}, amount: {o.amount}," + $" filled amount: {o.filledAmount}, filled cash amount: {o.filledCashAmount}, filled fees: {o.filledFees}"); } break; } case "error": { AppLogger.Info($"Get order fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
private static void GetOrderByClient() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var request = new GetRequest() .AddParam("clientOrderId", "cid1234"); var response = tradeClient.GetOrderByClientAsync(request).Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { var o = response.data; AppLogger.Info($"Order symbol: {o.symbol}, price: {o.price}, amount: {o.amount}"); } break; } case "error": { AppLogger.Info($"Get order fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
private static void GetMatchResultsById() { var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey); _logger.Start(); var response = tradeClient.GetMatchResultsByIdAsync("137534048832590").Result; _logger.StopAndLog(); switch (response.status) { case "ok": { if (response.data != null) { foreach (var r in response.data) { AppLogger.Info($"Match result symbol: {r.symbol}, amount: {r.filledAmount}, fee: {r.filledFees}, state: {r.feeDeductState}"); } AppLogger.Info($"There are total {response.data.Length} match results"); } break; } case "error": { AppLogger.Info($"Get match result fail, error code: {response.errorCode}, error message: {response.errorMessage}"); break; } } }
// the below will take your starting bid amount and your total amount, divide in half and place ten bids in increment private async void Button_ClickPlaceIncrementedOrder(object sender, RoutedEventArgs e) { // todo: add exception handling, place methods into client Authenticate authenticate = new Authenticate(); OrderClient orderClient = authenticate.MakeOrderClient(); decimal holdings = Convert.ToDecimal(StartingAmount.Text); decimal holdingsDivided = holdings / 10; decimal price = Convert.ToDecimal(StartingPrice.Text); string side = BuySell.SelectedValue.ToString(); string pair = PairsBuySell.SelectedValue.ToString(); try { for (decimal i = price; i < 1100; i = i + 10) { await orderClient.PlaceOrderAsync(side, pair, holdingsDivided, i, "limit"); } Label.Content = "Successfully placed limit order."; } catch (Exception ex) { Label.Content = ex.ToString(); } }
public void CreateOrderAsync() { var order = new Types.Order( new Types.MerchantSettings( "https://test.se/terms", "https://test.se/checkout", "https://test.se/confirmation", "https://test.se/push", "https://test.se/callback", null, null), new Types.Cart( new List <Types.OrderRow>() { new Types.OrderRow("testSku1", "Test Article 1", 1, 10000, null, 2500, "st", String.Empty, null) } ), "sv-SE", "SEK", "SE", "1", null); var orderClient = new OrderClient(Mode.Test, "MerchantId", "SharedSecret"); //var resp = orderClient.Create(order).Result; }
public AccountDetailForm(long id) { InitializeComponent(); accountSV = new AccountClient(); groupSV = new GroupClient(); orderSV = new OrderClient(); threadInit.RunWorkerAsync(id); }
public async Task CanRetrieveOrderList() { // When: Retrieve payment list with default settings ListResponse <OrderResponse> response = await OrderClient.GetOrderListAsync(); // Then Assert.IsNotNull(response); Assert.IsNotNull(response.Items); }
public AddOrder() { InitializeComponent(); accountService = new AccountClient(); orderService = new OrderClient(); productService = new ProductClient(); detail = new List <DetailOrder>(); }
static void Main(string[] args) { OrderClient client = new OrderClient(); ((IContextChannel)client.InnerChannel).OperationTimeout = new TimeSpan(0, 30, 0); string data = File.ReadAllText("Trip.xml"); TripFolder request = (TripFolder)DataContractDeSerialize(data, typeof(TripFolder)); var response = client.ProcessOrderAsync(request); }
public AddOrder() { InitializeComponent(); accountService = new AccountClient(); orderService = new OrderClient(); productService = new ProductClient(); detail = new List<DetailOrder>(); }
public Order() { InitializeComponent(); orderService = new OrderClient(); accountService = new AccountClient(); productService = new ProductClient(); orders = new List<OrderModel>(); threadInit.RunWorkerAsync(); }
public Order() { InitializeComponent(); orderService = new OrderClient(); accountService = new AccountClient(); productService = new ProductClient(); orders = new List <OrderModel>(); threadInit.RunWorkerAsync(); }
public OrderViewModel( IViewModelsFactory <IOrderContactViewModel> contactVmFactory, IViewModelsFactory <IOrderAddressViewModel> addressVmFactory, IViewModelsFactory <ICreateRefundViewModel> wizardRefundVmFactory, IViewModelsFactory <ICreateExchangeViewModel> wizardExchangeVmFactory, IViewModelsFactory <ICreateRmaRequestViewModel> wizardRmaVmFactory, IViewModelsFactory <ICreatePaymentViewModel> wizardPaymentVmFactory, IViewModelsFactory <IShipmentViewModel> shipmentVmFactory, IViewModelsFactory <IRmaRequestViewModel> rmaRequestVmFactory, IRepositoryFactory <IOrderRepository> repositoryFactory, IShippingRepository shippingRepository, ICustomerRepository customerRepository, IOrderEntityFactory entityFactory, INavigationManager navManager, Foundation.Orders.Model.Order item, OrderClient client, IOrderService service) : base(entityFactory, item) { _contactVmFactory = contactVmFactory; _addressVmFactory = addressVmFactory; _wizardRefundVmFactory = wizardRefundVmFactory; _wizardExchangeVmFactory = wizardExchangeVmFactory; _wizardRmaVmFactory = wizardRmaVmFactory; _wizardPaymentVmFactory = wizardPaymentVmFactory; _shipmentVmFactory = shipmentVmFactory; _rmaRequestVmFactory = rmaRequestVmFactory; _repositoryFactory = repositoryFactory; _customerRepository = customerRepository; _shippingRepository = shippingRepository; _navManager = navManager; _client = client; _orderService = service; _innerModel = new OrderModel(InnerItem, client, service); OpenItemCommand = new DelegateCommand(() => _navManager.Navigate(NavigationData)); CommonOrderCommandConfirmRequest = new InteractionRequest <Confirmation>(); DisableableCommandConfirmRequest = new InteractionRequest <Confirmation>(); CommonOrderWizardDialogInteractionRequest = new InteractionRequest <Confirmation>(); CancelOrderCommand = new DelegateCommand(RaiseCancelOrderInteractionRequest, () => _innerModel.IsOrderCancellable); HoldOrderCommand = new DelegateCommand(RaiseHoldOrderInteractionRequest, () => _innerModel.IsOrderHoldable); ReleaseHoldCommand = new DelegateCommand(RaiseReleaseHoldInteractionRequest, () => _innerModel.IsOrderHoldReleaseable); CreateRmaRequestCommand = new DelegateCommand(RaiseCreateRmaRequestInteractionRequest, () => _innerModel.CurrentStatus == (int)OrderStatus.Completed); CreateExchangeCommand = new DelegateCommand(RaiseCreateExchangeInteractionRequest, () => _innerModel.CurrentStatus == (int)OrderStatus.Completed); CreateRefundCommand = new DelegateCommand(RaiseCreateRefundInteractionRequest, () => _innerModel.CurrentStatus == (int)OrderStatus.Completed); CreatePaymentCommand = new DelegateCommand(RaiseCreatePaymentInteractionRequest); EditAddressCommand = new DelegateCommand <OrderAddress>(RaiseEditAddressInteractionRequest); ViewTitle = new ViewTitleBase() { Title = "Orders", SubTitle = (item != null && !string.IsNullOrEmpty(item.CustomerName)) ? item.CustomerName.ToUpper(CultureInfo.InvariantCulture) : null }; OpenCustomerProfileCommand = new DelegateCommand(RaiseOpenCustomerProfileInteractionRequest, () => InnerItem.CustomerId != null); }
public async Task <Order> Post(string id, [FromBody] OrderRequestModel request) { _logger.LogInformation($"Placing a market buy order for {id.ToUpper()}"); var client = new OrderClient(_appSettings.BaseUri, _authenticator); var response = await client.PlaceMarketBuyOrderAsync($"{id.ToUpper()}-EUR", request.Funds); _logger.LogInformation($"The order id is {response.Value.id}"); return(response.Value); }
// Cancel Most Recent Button private void Button_Click_3(object sender, RoutedEventArgs e) { // todo: add exception handling Authenticate authenticate = new Authenticate(); OrderClient orderClient = authenticate.MakeOrderClient(); orderClient.CancelMostRecent(); //Label.Content = message.Message; }
public ActionResult Delete(int productID) { if (Session["accountID"] != null) { Order order = new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], new OrderClient().GetOrderStatusByName("Cart").ID); new OrderClient().DeleteProductOrder(order.ID, productID); return RedirectToAction("Index"); } else { return RedirectToAction("Login", "Login"); } }
public ActionResult CheckOut() { if (Session["accountID"] != null) { Order order = new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], new OrderClient().GetOrderStatusByName("Cart").ID); OrderStatus status = new OrderClient().GetOrderStatusByName("Bought"); order.StatusID = status.ID; new OrderClient().UpdateOrder(order); return RedirectToAction("Index"); } else { return RedirectToAction("Login", "Login"); } }
public ActionResult Buy(ViewAllProductModel model) { OrderStatus os = new OrderClient().GetOrderStatusByName("Cart"); int accountID = (int)Session["accountID"]; if (Session["accountID"] != null) { if (new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], os.ID) == null) { //Create new Order. DateTime now = DateTime.Today; Order orderToAdd = new Order(); orderToAdd.AccountID = accountID; orderToAdd.DateOfOrder = now; orderToAdd.StatusID = os.ID; new OrderClient().AddOrder(orderToAdd); Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID); int productID = model.myProduct.ID; int quantityToBuy = Convert.ToInt32(model.quantity); ProductOrder po = new ProductOrder(); po.ProductID = productID; po.OrderID = order.ID; po.Quantity = quantityToBuy; po.WarrantyExpiry = DateTime.Today.AddYears(2); new OrderClient().AddProductOrder(po); } else { //Add to current Order. Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID); int productID = model.myProduct.ID; int quantityToBuy = Convert.ToInt32(model.quantity); ProductOrder po; if (new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID) != null) { po = new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID); po.Quantity = po.Quantity + quantityToBuy; new OrderClient().UpdateProductOrder(po); } else { po = new ProductOrder(); po.ProductID = productID; po.OrderID = order.ID; po.Quantity = quantityToBuy; po.WarrantyExpiry = DateTime.Today.AddYears(2); new OrderClient().AddProductOrder(po); } } } return RedirectToAction("Index", "ShoppingCart"); }
public static OrderClient CreateOrderClient(this CommerceClients source, string serviceUrl) { var client = new OrderClient(new Uri(serviceUrl), source.CreateMessageProcessingHandler()); return client; }
public ActionResult FilterTransactions(string dateFrom, string dateTo) { try { if ((dateFrom != null || dateFrom != "") && (dateTo != null || dateTo != "")) { try { from = Convert.ToDateTime(dateFrom); to = Convert.ToDateTime(dateTo); } catch (Exception e) { List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } ViewBag.Error = "Dates not in correct format (2014/01/01)"; return View("PurchaseHistory", allPO); } if (Session["accountID"] != null) { List<Order> orderList = new OrderClient().getOrdersByAccountAndDates((int)Session["accountID"], from, to).ToList(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } return View("PurchaseHistory", allPO); } else { return RedirectToAction("Login", "Login"); } } else { return View("PurchaseHistory", allPO); } } catch (Exception e) { ViewBag.Error = "An error has occured."; return RedirectToAction("PurchaseHistory", allPO); } }
public ActionResult ShowReport(int pID, int oID) { try { PrintStatementModel model = new PrintStatementModel(); Order o = new OrderClient().GetOrderByID(oID); model.myOrder = o; ProductOrder po = new OrderClient().GetProductOrderByOrderIDAndProductID(o.ID, pID); model.myProductOrder = po; List<FaultLog> fl = new List<FaultLog>(); Product p = new ProductClient().GetProductByID(pID); model.myProduct = p; List<Fault> f = new FaultClient().GetFaultsByAccountIDandProductID((int)Session["accountID"], pID).ToList(); model.myFaultList = f; Common.FaultLog faultLog = new Common.FaultLog(); List<Common.FaultLog> faultLogList = new List<Common.FaultLog>(); List<Common.Fault> flist = new List<Common.Fault>(); flist = new DSA_Assignment1_Sit1.FaultServ.FaultClient().GetFaultsByAccountIDandProductID((int)Session["accountID"], pID).ToList(); foreach (Common.Fault fa in flist) { List<Common.FaultLog> flTemp = new DSA_Assignment1_Sit1.FaultServ.FaultClient().GetAllFaultLogsByFaultID(fa.ID).ToList(); model.myFaultLog = flTemp; } if (model.myFaultLog == null) { List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList(); foreach (Order or in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(or.ID).ToList(); foreach (ProductOrder por in productOrderlist) { allPO.Add(por); } } ViewBag.Error = "No fault logs recorded."; return RedirectToAction("PurchaseHistory", allPO); } //SEND EMAIL //get user email User user = new UserAccountClient().GetUserByAccountID((int)Session["accountID"]); //Render email Document document = new Document(); MemoryStream memoryStream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); document.Open(); document.Add(new Paragraph("Electros Ltd.")); document.Add(new Paragraph()); document.Add(new Paragraph("Item: ")); document.Add(new Paragraph("Product ID " + "Name " + "Price " + "Date Of Purchase " + "Warranty Expiry")); document.Add(new Paragraph(model.myProduct.ID + " " + model.myProduct.Name + " " + model.myProduct.Price + " " + model.myOrder.DateOfOrder.ToShortDateString() + " " + model.myProductOrder.WarrantyExpiry.ToShortDateString())); document.Add(new Paragraph()); document.Add(new Paragraph("Faults: ")); document.Add(new Paragraph("Fault ID Date Fault Details Status")); foreach (FaultLog flo in model.myFaultLog) { document.Add(new Paragraph(flo.FaultID + " " + flo.DateOfReport.ToShortDateString() + " " + flo.Description + " " + flo.Status)); } writer.CloseStream = false; document.Close(); memoryStream.Position = 0; MailMessage newMessage = new MailMessage(); newMessage.From = new MailAddress("*****@*****.**"); newMessage.To.Add(new MailAddress(user.Email)); newMessage.Subject = "Print Statement"; newMessage.Body = "Dear " + user.Name + " " + user.Surname + ", please find attached details of the product's faults."; Attachment attachment = new Attachment(memoryStream, "ReportStatement.pdf"); newMessage.Attachments.Add(attachment); SmtpClient smtpClient = new SmtpClient("smtp.go.net.mt"); smtpClient.Send(newMessage); return new RazorPDF.PdfResult(model, "ShowReport"); } catch (Exception e) { List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } ViewBag.Error = "An error has occured."; return RedirectToAction("PurchaseHistory" , allPO); } }
public ActionResult PurchaseHistory(ViewAllProductModel model) { try { if (Session["accountID"] != null) { List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList(); foreach (Order o in orderList) { List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList(); foreach (ProductOrder po in productOrderlist) { allPO.Add(po); } } return View("PurchaseHistory", allPO); } else { return RedirectToAction("Login", "Login"); } } catch (Exception e) { ViewBag.Error = "An error has occured."; return View("PurchaseHistory", new List<ProductOrder>()); } }
public PartialViewResult ProductDetails(int pID, int oID) { ProductOrder po = new OrderClient().GetProductOrderByOrderIDAndProductID(oID, pID); return PartialView("_productDetails", po); }
public ActionResult Index() { if (Session["accountID"] != null) { Order order = new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], new OrderClient().GetOrderStatusByName("Cart").ID); if (order != null) { List<ProductOrder> productList = new OrderClient().GetProductOrderByOrderID(order.ID).ToList(); double totalPrice = 0.0; foreach (ProductOrder po in productList) { Product p = new ProductClient().GetProductByID(po.ProductID); totalPrice += (Convert.ToDouble(p.Price) * po.Quantity); } ViewBag.TotalPrice = "Total Order Price: " + totalPrice.ToString(); return View("Index", productList); } else { return View("Index", new List<ProductOrder>()); } } else { return RedirectToAction("Login", "Login"); } }
public static OrderClient CreateOrderClient(this CommerceClients source, string serviceUrl, string appId, string secretKey) { var client = new OrderClient(new Uri(serviceUrl), appId, secretKey); return client; }
public ActionResult Buy(ViewAllProductModel model) { OrderStatus os = new OrderClient().GetOrderStatusByName("Cart"); int accountID = (int)Session["accountID"]; if (Session["accountID"] != null) { if (new OrderClient().GetOrderByAccountAndStatus((int)Session["accountID"], os.ID) == null) { //Create new Order. DateTime now = DateTime.Today; Order orderToAdd = new Order(); orderToAdd.AccountID = accountID; orderToAdd.DateOfOrder = now; orderToAdd.StatusID = os.ID; new OrderClient().AddOrder(orderToAdd); Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID); int productID = model.myProduct.ID; int quantityToBuy; try { quantityToBuy = Convert.ToInt32(model.quantity); } catch (Exception e) { ViewAllProductModel m = new ViewAllProductModel(); m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID); m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID); ViewBag.Error = "Please provide a valid quantity amount"; return View("Details", m); } if (quantityToBuy <= 0) { ViewAllProductModel m = new ViewAllProductModel(); m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID); m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID); ViewBag.Error = "Please provide a valid quantity amount"; return View("Details", m); } else { ProductOrder po = new ProductOrder(); po.ProductID = productID; po.OrderID = order.ID; po.Quantity = quantityToBuy; po.WarrantyExpiry = DateTime.Today.AddYears(2); new OrderClient().AddProductOrder(po); } } else { //Add to current Order. Order order = new OrderClient().GetOrderByAccountAndStatus(accountID, os.ID); int productID = model.myProduct.ID; int quantityToBuy; try { quantityToBuy = Convert.ToInt32(model.quantity); } catch (Exception e) { ViewAllProductModel m = new ViewAllProductModel(); m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID); m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID); ViewBag.Error = "Please provide a valid quantity amount"; return View("Details", m); } if (quantityToBuy <= 0) { ViewAllProductModel m = new ViewAllProductModel(); m.myProduct = new ProductClient().GetProductByID(model.myProduct.ID); m.rating = new ProductClient().GetRatingsByProduct(model.myProduct.ID); ViewBag.Error = "Please provide a valid quantity amount"; return View("Details", m); } else { ProductOrder po; if (new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID) != null) { po = new OrderClient().GetProductOrderByOrderIDAndProductID(order.ID, productID); po.Quantity = po.Quantity + quantityToBuy; new OrderClient().UpdateProductOrder(po); } else { po = new ProductOrder(); po.ProductID = productID; po.OrderID = order.ID; po.Quantity = quantityToBuy; po.WarrantyExpiry = DateTime.Today.AddYears(2); new OrderClient().AddProductOrder(po); } } } } return RedirectToAction("Index", "ShoppingCart"); }