public AppConfig( string name, string rootDirectory, string outputDirectory, OrderInformation orderInformation, bool includeLowercase) { this.Name = name; this.RootDirectory = rootDirectory; this.OutputDirectory = outputDirectory; var orderInformationItems = new List <OrderInformationItem>(); foreach (var key in orderInformation.Keys) { orderInformationItems.Add(new OrderInformationItem(key, orderInformation[key])); } this.OrderInformationItems = orderInformationItems; this.IncludeLowercase = includeLowercase; }
public IActionResult Create([FromBody] OrderInformation orderInformation) { if (!ModelState.IsValid) { return(BadRequest()); } var client = Request.GetClient(context); var basket = (from i in context.Basket where i.ClientId == client.Id select new OrderDtl { Price = i.Price, Product = i.Product, Qty = i.Qty, Status = OrderDtlStatus.Wait }).ToList(); if (basket.Count == 0) { return(BadRequest()); } //Todo: нужно подключить Automapper OrderHdr orderHdr = new OrderHdr(); orderHdr.Client = client; orderHdr.CreatedDate = DateTime.Now; orderHdr.Status = OrderHdrStatus.Requested; orderHdr.ClientName = orderInformation.ClientName; orderHdr.Phone = orderInformation.Phone; orderHdr.Address = orderInformation.Address; orderHdr.Latitude = orderInformation.Latitude; orderHdr.Longtitude = orderInformation.Longtitude; orderHdr.Sum = basket.Sum(a => a.Price * a.Qty); orderHdr.DeliveryDateTime = orderInformation.DeliveryDateTime.LocalDateTime; orderHdr.OrderDtls = basket; context.OrderHdrs.Add(orderHdr); context.Basket.RemoveRange(context.Basket.Where(a => a.ClientId == client.Id)); context.SaveChanges(); return(Json(new { orderID = orderHdr.Id, clientName = orderHdr.ClientName, sum = orderHdr.Sum, address = orderHdr.Address, orderDate = orderHdr.DeliveryDateTime.ToString("dd-MM-yyyy"), orderTime = orderHdr.DeliveryDateTime.ToString("hh:mm") })); }
public async Task PostAsync_GetAsync_CustomerOrderComplex_ReturnsOK() { // Arrange var model = new OrderModel(); var order = model.CustomerOrder_Sample1; order.OrderID = GetMaxOrderID() + 1; var requestContent = base.GetSerializedContent(order); var expectedResult = new OrderInformation(model.OrderItems_Complex, model.RequiredBinWidth_Complex); //Act await base.Client.PostAsync(this._postUrl, requestContent); var result = await base.Client.GetAsync(string.Format(this._getUrl, order.OrderID)); // Assert var content = await base.GetDeserializedContent <OrderInformation>(result); Assert.AreEqual(result.StatusCode, HttpStatusCode.OK, "error in returning correct response"); TestHelper.AreEqualEntities(expectedResult, content, "error in returning correct content type"); }
public static bool UpdateOrder(OrderInformation currentOrderInformation) { Order order = new Order(); if (order.LoadByPrimaryKey(currentOrderInformation.orderID)) { AddressInfo addressInfo = new AddressInfo(); addressInfo.Address1 = currentOrderInformation.billingAddress; addressInfo.City = currentOrderInformation.city; addressInfo.State = currentOrderInformation.state; addressInfo.PostalCode = currentOrderInformation.zipCode; addressInfo.PhoneNumber = currentOrderInformation.phone; addressInfo.FirstName = currentOrderInformation.firstName; addressInfo.LastName = currentOrderInformation.lastName; addressInfo.AddressId = order.BillingAddressId; string SQL = "UPDATE ADDRESSINFO SET FIRSTNAME = '{0}', LASTNAME = '{1}', CITY = '{2}', STATE = '{3}', POSTALCODE = '{4}', ADDRESS1 = '{5}', PHONENUMBER = '{6}' WHERE ADDRESSID = {7}"; ExecuteSQLString(string.Format(SQL, addressInfo.FirstName, addressInfo.LastName, addressInfo.City, addressInfo.State, addressInfo.PostalCode, addressInfo.Address1, addressInfo.PhoneNumber, addressInfo.AddressId)); } return(true); }
public override void Execute(object parameter) { List <OrderDetail> orderDetails = DB.OrderDetailRepository.GetOrderDetails(orderViewModel.CurrentOrder.Id); List <OrderDetailModel> orderDetailModels = new List <OrderDetailModel>(); OrderDetailMapper orderDetailMapper = new OrderDetailMapper(); for (int i = 0; i < orderDetails.Count; i++) { OrderDetail orderDetail = orderDetails[i]; OrderDetailModel orderDetailModel = orderDetailMapper.Map(orderDetail); orderDetailModel.No = i + 1; orderDetailModels.Add(orderDetailModel); } orderViewModel.OrderDetails = orderDetailModels; OrderInformation orderInformation = new OrderInformation(); orderInformation.DataContext = orderViewModel; orderInformation.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; orderInformation.ShowDialog(); }
public string SamplePaymentsData() { //Create the Sample Data using Model Classes of Payments API var clientReferenceInformation = new ClientReferenceInformation { code = "TC50171_3" }; var processingInformation = new ProcessingInformation { commerceIndicator = "internet" }; var subMerchant = new SubMerchant { cardAcceptorID = "1234567890", country = "US", phoneNumber = "650-432-0000", address1 = "900 Metro Center", postalCode = "94404-2775", locality = "Foster Cit", name = "Visa Inc", administrativeArea = "CA", region = "PEN", email = "*****@*****.**" }; var aggregatorInformation = new AggregatorInformation { subMerchant = subMerchant, name = "V-Internatio", aggregatorID = "123456789" }; var billTo = new BillTo { country = "US", lastName = "VDP", address2 = "Address 2", address1 = "201 S. Division St.", postalCode = "48104-2201", locality = "Ann Arbor", administrativeArea = "MI", firstName = "RTS", phoneNumber = "999999999", district = "MI", buildingNumber = "123", company = "Visa", email = "*****@*****.**" }; var amountDetails = new AmountDetails { totalAmount = "102.21", currency = "USD" }; var orderInformation = new OrderInformation { billTo = billTo, amountDetails = amountDetails }; var card = new Card { expirationYear = "2031", number = "5555555555554444", securityCode = "123", expirationMonth = "12", type = "002" }; var paymentInformation = new PaymentInformation { card = card }; var payments = new Payments { clientReferenceInformation = clientReferenceInformation, processingInformation = processingInformation, aggregatorInformation = aggregatorInformation, orderInformation = orderInformation, paymentInformation = paymentInformation }; return(JsonConvert.SerializeObject(payments, Formatting.Indented)); }
public async Task EditOrder(OrderInformation orderInformation) { await _repository.EditOrder(orderInformation); }
public async Task AddOrder(OrderInformation orderInformation) { await _repository.AddOrder(orderInformation); }
public async Task <OrderInformation> GetOrderInformation(string orderId) { ///http://{{accountName}}.vtexcommercestable.com.br/api/checkout/pvt/orders/order-group/727553409798 ///http://{{accountName}}.vtexcommercestable.com.br/api/checkout/pvt/orders/604441449285-01 OrderInformation orderInformation = new OrderInformation { hasError = true, message = "Unknown Error." }; try { var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri($"http://{this._httpContextAccessor.HttpContext.Request.Headers[HEADER_VTEX_ACCOUNT]}.{ENVIRONMENT}.com.br/api/checkout/pvt/orders/{orderId}-01") //RequestUri = new Uri($"https://{this._httpContextAccessor.HttpContext.Request.Headers[HEADER_VTEX_ACCOUNT]}.{ENVIRONMENT}.com.br/api/checkout/pvt/orders/order-group/{orderId}") }; string authToken = this._httpContextAccessor.HttpContext.Request.Headers[HEADER_VTEX_CREDENTIAL]; if (authToken != null) { request.Headers.Add(AUTHORIZATION_HEADER_NAME, authToken); request.Headers.Add(VTEX_ID_HEADER_NAME, authToken); } //StringBuilder sb = new StringBuilder(); var client = _clientFactory.CreateClient(); var response = await client.SendAsync(request); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { orderInformation.hasError = false; Models.VtexOrder.VtexOrder vtexOrder = JsonConvert.DeserializeObject <Models.VtexOrder.VtexOrder>(responseContent); if (vtexOrder.customData != null) { Models.VtexOrder.CustomApp customApp = vtexOrder.customData.customApps.Where(c => c.id.Equals(FlowFinanceConstants.CustomTokenId)).FirstOrDefault(); if (customApp != null) { orderInformation.offerToken = customApp.fields.chosenLoanToken; orderInformation.email = vtexOrder.clientProfileData.email; } else { orderInformation.hasError = true; orderInformation.message = $"Custom App not Found. {JsonConvert.SerializeObject(vtexOrder.customData)}"; } } else { orderInformation.hasError = true; orderInformation.message = "Custom Data field is Null."; } } else { orderInformation.hasError = true; orderInformation.message = $"Reason: '{response.ReasonPhrase}'"; } } catch (Exception ex) { orderInformation.hasError = true; orderInformation.message = $"Error: {ex.Message} {ex.InnerException}"; } return(orderInformation); }
/// <summary> /// Displays list of store's order history /// </summary> /// <param name="storeOrders"></param> /// <returns>store order history view</returns> public IActionResult _StoreOrderHistory(Stores store) { //user selected to see store history, selected store now utilized int storeSelection = store.StoreId; //Select all the orders associated with logged in customer var storeOrders = (from Orders in _db.Orders where Orders.StoreOrderedFrom == store.StoreId select new { Orders.OrderDate, Orders.OrderId, Orders.OrderedProduct, Orders.OrderedProductAmount, Orders.StoreOrderedFrom, Orders.WhoOrdered, Orders.OrderTotal }).ToList(); //Select all the product info var orderItems = (from Products in _db.Products where Products.IsInBundle == false select new { Products.Skunum, Products.ProductName, Products.UnitPrice, Products.ProductDiscount }).ToList(); //Get product info on all items in the order var storeOrderInfo = (from Orders in storeOrders from Products in orderItems where Orders.OrderedProduct == Products.Skunum orderby Orders.OrderDate descending select new { Orders.OrderId, Orders.OrderedProduct, Products.ProductName, Orders.OrderedProductAmount, Products.UnitPrice, Products.ProductDiscount, Orders.StoreOrderedFrom, Orders.WhoOrdered, Orders.OrderDate, Orders.OrderTotal }).ToList(); //Fresh instantiation of the OrderInfo list for populating orderInfo = new List <OrderInformation>(); foreach (var order in storeOrderInfo) { //Create and add a new order to the list of order information to be displayed OrderInformation item = new OrderInformation(); item.OrderId = order.OrderId; item.OrderedProduct = order.OrderedProduct; item.ProductName = order.ProductName; item.OrderedProductAmount = order.OrderedProductAmount; item.UnitPrice = order.UnitPrice; item.ProductDiscount = order.ProductDiscount; item.StoreOrderedFrom = order.StoreOrderedFrom; item.WhoOrdered = order.WhoOrdered; item.OrderDate = order.OrderDate; item.OrderTotal = order.OrderTotal; orderInfo.Add(item); } return(View(orderInfo)); }
/// <summary> /// This method will process and return Mocked Verification Response for EPC /// </summary> /// <param name="response"></param> /// <param name="loanInformation"></param> private JArray ProcessVerificationResponse(JObject response, JToken loanInformation) { _Logger.LogInformation("[" + _ClassName + "] - ProcessVerificationResponse - [STARTS]"); JToken result = response.SelectToken("$.result"); string orderId = ""; var random = new System.Random(); JToken tokenoptions = loanInformation.SelectToken("$.product.options"); // building payload for Partner API Create Response dynamic responsePayload = new JObject(); dynamic orders = new JArray(); dynamic order = null; //var orderDate = DateTime.Now.ToUniversalTime(); var orderDate = DateTime.Now; if (tokenoptions != null) { foreach (JProperty prop in tokenoptions) { string sProductName = ""; if (!string.IsNullOrEmpty(prop.Name) && _MockRequestHelper.IsValidProduct(prop.Name)) { sProductName = _MockRequestHelper.GetProductDescription(prop.Name); } if (!string.IsNullOrEmpty(sProductName)) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - ProductName is " + sProductName); orderId = random.Next(10000, 80000).ToString(); OrderInformation orderInfo = new OrderInformation() { TransactionId = _WebhookBody.meta != null ? _WebhookBody.meta.resourceId : string.Empty, ProductName = sProductName, ProductCode = prop.Name.ToString(), OrderId = orderId.ToString(), OrderStatus = response.SelectToken("$.status").ToString(), LoanInformation = loanInformation }; TransactionInformationCache.Instance.Add(orderInfo, true); order = new JObject(); order.id = orderId.ToString(); order.orderDateTime = orderDate.ToString("yyyy-MM-ddTHH:mm-ss:ff"); // result["orderDate"]; order.orderStatus = response["status"]; order.orderMessage = result["orderMessage"]; order.product = sProductName; order.documents = new JArray(); orders.Add(order); } } } _Logger.LogInformation("[" + _ClassName + "] - ProcessVerificationResponse - [ENDS]"); return(orders); }
/// <summary> /// Adds item to cart when user clicks button /// </summary> /// <returns></returns> public IActionResult AddItemToCart(InventoryProductInfo selectedItem, int?numOrdered) { if (numOrdered == null) { numOrdered = (int)1; } else { numOrdered = (int)numOrdered; } //TODO Add a check to make sure quantity isnt more than whats available //Not returning anything, just altering the cart list //Cart is a list of OrderInformation because that model contains all the relevant info on the ordered Product var loggedIn = _cache.Get("loggedInCustomer"); loggedInCustomer = (Customers)loggedIn; var itemCart = _cache.Get("Cart"); List <OrderInformation> cart = new List <OrderInformation>(); cart = (List <OrderInformation>)itemCart; //Check to see if the product is already in the cart or a new cart item OrderInformation newSKU = new OrderInformation(); newSKU.OrderedProduct = selectedItem.Skunum; newSKU.OrderedProductAmount = selectedItem.OrderedAmt; int matchWasFound = 0; foreach (var item in cart) { if (newSKU.OrderedProduct == item.OrderedProduct) { matchWasFound++; } } if (matchWasFound != 0) { //Grab the item from the cart var existingItem = StoreMethods.SelectCartItem(newSKU, cart); //Update the existing item's ordered amount and the total price for the item existingItem.OrderedProductAmount += newSKU.OrderedProductAmount; existingItem.UnitPrice = existingItem.OrderedProductAmount * (existingItem.UnitPrice * (1 - existingItem.ProductDiscount)); _cache.Set("Cart", cart); return(RedirectToAction("GetCustomerStoreInventory")); } else //If this is the first time this item has been added, create a new cart object { OrderInformation newCartItem = new OrderInformation(); newCartItem.OrderedProduct = selectedItem.Skunum; newCartItem.OrderedProductAmount = (int)numOrdered; newCartItem.ProductName = selectedItem.ProductName; newCartItem.UnitPrice = (int)numOrdered * (selectedItem.UnitPrice * (1 - selectedItem.ProductDiscount)); //Total price of that item given the discount and num ordered newCartItem.WhoOrdered = loggedInCustomer.CustomerId; newCartItem.StoreOrderedFrom = loggedInCustomer.DefaultStore; newCartItem.IsBundle = selectedItem.IsBundle; newCartItem.IsInBundle = selectedItem.IsInBundle; newCartItem.BundleId = selectedItem.BundleId; cart.Add(newCartItem); //Add new cart item to our cart _cache.Set("Cart", cart); //Set our cart to be the new cart return(RedirectToAction("GetCustomerStoreInventory")); } }
/// <summary> /// This method will build the payload required for Creating Response in the Partner API /// </summary> /// <param name="response"></param> /// <param name="loanInformation"></param> /// <param name="transactionId"></param> private void SubmitAcknowledgementToPartnerAPI(JObject response, JToken loanInformation, string transactionId) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - [STARTS]"); try { if (response != null) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Submitting Response to Partner API "); if (response.SelectToken("$.result") != null && loanInformation != null) { JToken result = response.SelectToken("$.result");; JToken productName = null; JToken productId = null; JToken existingOrderId = null; string orderId = ""; var random = new System.Random(); // building payload for Partner API Create Response dynamic responsePayload = new JObject(); dynamic orders = new JArray(); dynamic order = null; //var orderDate = DateTime.Now.ToUniversalTime(); var orderDate = DateTime.Now; // assuming the response is of type JToken if (string.Compare(_AppSettings.IntegrationType, "Verification", true) == 0) { JToken tokenoptions = loanInformation.SelectToken("$.product.options"); if (tokenoptions != null) { foreach (JProperty prop in tokenoptions) { string sProductName = ""; if (!string.IsNullOrEmpty(prop.Name) && _MockRequestHelper.IsValidProduct(prop.Name)) { sProductName = _MockRequestHelper.GetProductDescription(prop.Name); } if (!string.IsNullOrEmpty(sProductName)) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - ProductName is " + sProductName); orderId = random.Next(10000, 80000).ToString(); OrderInformation orderInfo = new OrderInformation() { TransactionId = transactionId, ProductName = sProductName, ProductCode = prop.Name.ToString(), OrderId = orderId.ToString(), OrderStatus = response.SelectToken("$.status").ToString(), LoanInformation = loanInformation }; TransactionInformationCache.Instance.Add(orderInfo, true); order = new JObject(); order.id = orderId.ToString(); order.orderDateTime = orderDate.ToString("yyyy-MM-ddTHH:mm-ss:ff"); // result["orderDate"]; order.orderStatus = response["status"]; order.orderMessage = result["orderMessage"]; order.product = sProductName; order.documents = new JArray(); orders.Add(order); } } } } else if (string.Compare(_AppSettings.IntegrationType, "DataDocs", true) == 0) { orderId = random.Next(10000, 80000).ToString(); // responsePayload = new JObject(); //responsePayload.orders = new JArray(); dynamic orderResponse = new JObject(); orderResponse.id = orderId.ToString(); orderResponse.orderDateTime = orderDate.ToString("yyyy-MM-ddTHH:mm-ss:ff"); // result["orderDate"]; orderResponse.orderStatus = "Delivered"; orderResponse.message = result["orderMessage"]; orders.Add(orderResponse); } else { productName = loanInformation.SelectToken("$.product.options.productName"); productId = loanInformation.SelectToken("$.product.options.productId"); existingOrderId = loanInformation.SelectToken("$.product.options.existingOrderId"); // setting the order id to existingOrderId if the payload has it otherwise setting it to a random number orderId = existingOrderId != null?existingOrderId.ToString() : random.Next(10000, 80000).ToString(); var orderInfo = new OrderInformation() { TransactionId = transactionId, ProductName = productName != null?productName.ToString() : string.Empty, ProductCode = productId != null?productId.ToString() : string.Empty, OrderId = existingOrderId != null?existingOrderId.ToString() : orderId.ToString(), // adding existing order id if it exists in the response object, OrderStatus = response.SelectToken("$.status").ToString(), LoanInformation = loanInformation }; // Adding Transaction Information in the local In Memory cache. This would be implemented by the partner in their own way to track transactions and their order statuses TransactionInformationCache.Instance.Add(orderInfo); order = new JObject(); order.id = orderId.ToString(); order.orderDateTime = orderDate.ToString("yyyy-MM-ddTHH:mm-ss:ff"); // result["orderDate"]; order.orderStatus = response["status"]; order.orderMessage = result["orderMessage"]; order.product = productName; order.documents = new JArray(); orders.Add(order); } _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Order Date time is " + orderDate.ToString("o")); responsePayload.orders = orders; var responsePayloadString = Convert.ToString(responsePayload); var partnerAPIWrapper = new PartnerAPIWrapper(this._AppSettings); // This is the POST call to the Partner API (Create Response call) | partner/v1/transactions/{{transactionId}}/response var isResponseCreated = partnerAPIWrapper.CreateResponse(responsePayloadString, transactionId); if (isResponseCreated) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - isResponseCreated flag is true"); TransactionStatusCache.Instance.Add(transactionId, response); } } } } catch (Exception ex) { _Logger.LogError("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Exception - " + ex.Message); _Logger.LogError("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - StackTrace - " + ex.StackTrace); } _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - [ENDS]"); }
public async Task <IActionResult> EditOrder(OrderInformation orderInformation) { await _service.EditOrder(orderInformation); return(Ok()); }
public void CalculateTotalPrice() { TotalPrice = OrderInformation.Select(o => o.Price).Sum(); }
public void AddItemOrderInfo(ItemOrderInfo orderInfo) { OrderInformation.Add(orderInfo); }
/// <summary> /// 修改借货数量 /// </summary> /// <param name="deliveryUserSysNo">配送员系统编号</param> /// <param name="orderItem">商品销售数据</param> /// <param name="lastUpdateBySysNo">最后更新人系统编号</param> /// <returns></returns> /// <remarks>2013-11-15 周唐炬 创建</remarks> private void ProductReturn(int deliveryUserSysNo, OrderInformation orderItem, int lastUpdateBySysNo) { if (orderItem.ProductOrderNumber <= 0) { throw new HytException("补单商品数量必需大于0个"); } //配送员所有未完结借货单明细 var list = IProductLendDao.Instance.GetWhProductLendItemList(new ParaWhProductLendItemFilter() { DeliveryUserSysNo = deliveryUserSysNo, ProductSysNo = orderItem.ProductSysNo, Status = (int)WarehouseStatus.借货单状态.已出库 }); if (list == null || !list.Any()) { throw new HytException("没有可补单的商品"); } var productlends = new List <int>();//借货单系统编号列表 //本次销售数量 var saleQuantity = orderItem.ProductOrderNumber; //所有需要销售的数量 var allQuantity = 0; list.ForEach(x => { //销售数量用完直接跳出 if (saleQuantity <= 0) { return; } var model = IProductLendDao.Instance.GetWhProductLendItem(x); if (model == null) { return; } //计算该借货明细完成需要销售数量的 var quantity = model.LendQuantity - model.ReturnQuantity - model.SaleQuantity; allQuantity += quantity; //该条借货明细记录可销售数量大于或等于本次销售数量 if (quantity > saleQuantity) { model.SaleQuantity += saleQuantity; saleQuantity = 0; } else //该条借货明细记录的可销售数量小于本次销售数量 { //补满销售数量 model.SaleQuantity += quantity; saleQuantity = saleQuantity - quantity; } IProductLendDao.Instance.UpdateWhProductLendItem(model); //借货数量等于销售数量加还货数量,该条记录表于需要检查借货单完成情况 if (model.SaleQuantity + model.ReturnQuantity != model.LendQuantity) { return; } if (productlends.All(c => c != model.ProductLendSysNo)) { productlends.Add(model.ProductLendSysNo); } }); if (saleQuantity > allQuantity) { throw new HytException("补单的商品数量超过本商品最大可销售商品数量,操作失败!"); } // 完结销售完的借货单 if (productlends.Any()) { productlends.ForEach(x => ProductLendBo.Instance.CompleteProductLend(x, lastUpdateBySysNo)); } }
/// <summary> /// Creates a new order item, calculates order total and updates inventory /// </summary> public IActionResult Checkout() { //Takes our Cart, creates a new order item, calculates orderTotal, and updates the inventory //get the logged in customer var loggedIn = _cache.Get("loggedInCustomer"); loggedInCustomer = (Customers)loggedIn; //Retrieve the cart contents var itemCart = _cache.Get("Cart"); List <OrderInformation> cart = new List <OrderInformation>(); cart = (List <OrderInformation>)itemCart; //Get new order id var orderList = StoreMethods.GetAllOrderIds(_db); int newOrderId = StoreMethods.GetNewOrderId(orderList); if (cart.Count == 0) { _logger.LogInformation("Cart was empty"); return(View("_Checkout")); } else //Begin checkout { _logger.LogInformation("Cart had items, beginning checkout..."); decimal orderTotal = 0; foreach (var product in cart) { //Update the item quantities var allItemsInventory = StoreMethods.GetAllProducts(_db); var storeInventory = (from Inventory in _db.Inventory where Inventory.StoreInventory == loggedInCustomer.DefaultStore && Inventory.ItemInInventory == product.OrderedProduct select new { Inventory.InventoryId, Inventory.ItemInInventory, Inventory.StoreInventory, Inventory.ProductCurrentQuantity }).ToList(); //Gets only the user's default store's inventory //var allInventories = (from Inventory in _db.Inventory // select new // { // Inventory.InventoryId, // Inventory.ItemInInventory, // Inventory.StoreInventory, // Inventory.ProductCurrentQuantity // }).ToList(); foreach (var Inventory in _db.Inventory) //Update the ordered product's quantity { foreach (var storeInv in storeInventory) { if (storeInv.StoreInventory == Inventory.StoreInventory && Inventory.ItemInInventory == product.OrderedProduct) { Inventory.ProductCurrentQuantity -= product.OrderedProductAmount; //New quantity set for ordered product _logger.LogInformation($"Amount decremented"); } } } _db.SaveChanges(); if (product.IsBundle == true) //if the ordered product is a bundle, update associated items { foreach (var inventory in _db.Inventory) { foreach (var items in allItemsInventory) { if (items.BundleId == product.BundleId && inventory.ItemInInventory == items.Skunum && items.IsInBundle == true && inventory.StoreInventory == loggedInCustomer.DefaultStore) //if the item is InBundle, is part of the orderedProduct's bundle, and available at the same store { inventory.ProductCurrentQuantity -= product.OrderedProductAmount; //Decrement items that are a part of the bundle as well _logger.LogInformation("Bundle included item decremented"); } } } } _db.SaveChanges(); //Because the 'unit price' of each item is calculated with ordered# and discount, just add item totals orderTotal += product.UnitPrice; orderTotal = Math.Round(orderTotal, 2); //2 decimal points } //Need a uniform order total, so we need another foreach loop foreach (var product in cart) { Orders newOrder = new Orders(); newOrder.OrderDate = DateTime.Now; newOrder.OrderedProduct = product.OrderedProduct; newOrder.OrderedProductAmount = product.OrderedProductAmount; newOrder.OrderTotal = orderTotal; newOrder.StoreOrderedFrom = loggedInCustomer.DefaultStore; newOrder.WhoOrdered = loggedInCustomer.CustomerId; newOrder.OrderId = newOrderId; _db.Orders.Add(newOrder); _db.SaveChanges(); } //Empty out the cart, set the cache's cart to be the new empty cart, then return the checkout screen List <OrderInformation> emptyCart = new List <OrderInformation>(); List <OrderInformation> checkoutCart = new List <OrderInformation>(); foreach (var item in cart) { OrderInformation purchased = new OrderInformation(); purchased = item; purchased.OrderDate = DateTime.Now; purchased.OrderTotal = orderTotal; checkoutCart.Add(purchased); } _cache.Set("Cart", emptyCart); return(View("_Checkout", checkoutCart)); } }
/// <summary> /// 根据订单号查询门信息 /// </summary> /// <param name="orderNum">订单号</param> /// <returns>门信息</returns> public static OrderInformation SearchOrderInfoByOrderNum(string orderNum) { OrderInformation orderInformation = null; string sql = DB_SQL.Sel_InfoByOrderNum(orderNum); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; orderInformation = new OrderInformation { OrderNum = objSqlReader[0].ToString().Trim(), OrderQuantity = objSqlReader[1].ToString().Trim(), ProductLine = objSqlReader[2].ToString().Trim(), DoorThickness = objSqlReader[3].ToString().Trim(), DoorStructure = objSqlReader[4].ToString().Trim(), SpecificationsWide = objSqlReader[5].ToString().Trim(), SpecificationHigh = objSqlReader[6].ToString().Trim(), FacadeStyle = objSqlReader[7].ToString().Trim(), ChildDoorStyle = objSqlReader[8].ToString().Trim(), Lock = objSqlReader[9].ToString().Trim(), Overdye = objSqlReader[10].ToString().Trim(), Doorframe = objSqlReader[11].ToString().Trim(), OpenTo = objSqlReader[12].ToString().Trim(), Buckles = objSqlReader[13].ToString().Trim(), ColorCategories = objSqlReader[14].ToString().Trim(), PictureDoorSpecification = objSqlReader[15].ToString().Trim(), CustomerSpecialRequirements = objSqlReader[16].ToString().Trim() }; } if (n == 0) { MessageBox.Show("订单号" + orderNum + "不存在!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(orderInformation); }
protected override string Build() => $"{PatientId.Build()}{OrderId.Build()}" + $"{OrderInformation.Build()}{SampleName.Build()}" + $"{GetTests()}";
private void DoorChooseBtn_Click(object sender, RoutedEventArgs e) { string orderNoTxt = OrderNum.Text.Trim(); if (orderNoTxt == "") { MessageBox.Show("订单编号不可为空"); } else { string ponputChooseTxt = PonputChoose.Text.Trim(); string doorMoldCombTxt = DoorMoldComb.Text.Trim(); string stackPositionCombTxt = StackPositionComb.Text.Trim(); string doorNumChooseTxt = DoorNumChoose.Text.Trim(); string PerliteStackPositionTxt = PerliteStackPosition.Text.Trim(); doorInformation = new DoorInformation(); doorInformation.LoadBatchID = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); doorInformation.OrderNum = orderNoTxt; doorInformation.DoorMold = doorMoldCombTxt; doorInformation.PlacementMode = ponputChooseTxt; doorInformation.ThicknessDistinguish = "厚板"; doorInformation.StackPosition = stackPositionCombTxt; doorInformation.PerlitePosition = PerliteStackPositionTxt; int.TryParse(doorNumChooseTxt, out int num); doorInformation.LoadNum = num; doorInformation.SentNum = 0; doorInformation.Status = "0"; OrderInformation orderInformation = DB_OrderInfo.SearchOrderInfoByOrderNum(orderNoTxt); if (orderInformation != null) { if (orderInformation.ProductLine == doorMoldCombTxt) { doorInformation.OpenDirection = orderInformation.OpenTo; int.TryParse(orderInformation.DoorThickness, out int thickness); doorInformation.Thickness = thickness; int.TryParse(orderInformation.OrderQuantity, out int quantity); doorInformation.OrderQuantity = quantity; DoorInfoCalculate.DoorModel(orderInformation, out int thinPlateLength, out int thinPlateWidth, out int thickPlateLength, out int thickPlateWidth); doorInformation.ThinPlateLength = thinPlateLength; doorInformation.ThinPlateWidth = thinPlateWidth; doorInformation.ThickPlateLength = thickPlateLength; doorInformation.ThickPlateWidth = thickPlateWidth; doorInformation.LaminationDosage = DoorInfoCalculate.Lamination(orderInformation); DoorInfoCalculate.Gluing(orderInformation, out int thinPlateKeyholeX, out int thinPlateKeyholeY, out int thickPlateKeyholeX, out int thickPlateKeyholeY, out int thinPlateViewerX, out int thinPlateViewerY, out int thickPlateViewerX, out int thickPlateViewerY, out int lockWidth, out int lockLength); doorInformation.ThinPlateKeyholeX = thinPlateKeyholeX; doorInformation.ThinPlateKeyholeY = thinPlateKeyholeY; doorInformation.ThickPlateKeyholeX = thickPlateKeyholeX; doorInformation.ThickPlateKeyholeY = thickPlateKeyholeY; doorInformation.ThinPlateViewerX = thinPlateViewerX; doorInformation.ThinPlateViewerY = thinPlateViewerY; doorInformation.ThickPlateViewerX = thickPlateViewerX; doorInformation.ThickPlateViewerY = thickPlateViewerY; doorInformation.LockWidth = lockWidth; doorInformation.LockLength = lockLength; if (doorInformation.DoorMold == "防火门") { DoorInfoCalculate.PerliteFilling(orderInformation, out int perliteLength, out int perliteWidth); doorInformation.PerliteLength = perliteLength; doorInformation.PerliteWidth = perliteWidth; doorInformation.PerliteThickness = thickness - 2; } else { doorInformation.PerliteLength = 0; doorInformation.PerliteWidth = 0; doorInformation.PerliteThickness = 0; } DoorInfoCalculate.GrindingWelding(orderInformation, thickPlateLength, thickPlateWidth, out int[] weldSpacingUpDown, out int[] weldSpacingHinge, out int[] weldSpacingKeyhole, out int weldNumUpDown, out int weldNumHinge, out int weldNumKeyhole); doorInformation.WeldNumUpDown = weldNumUpDown; doorInformation.WeldSpacingUpDown = weldSpacingUpDown; doorInformation.WeldNumHinge = weldNumHinge; doorInformation.WeldSpacingHinge = weldSpacingHinge; doorInformation.WeldNumKeyhole = weldNumKeyhole; doorInformation.WeldSpacingKeyhole = weldSpacingKeyhole; string spacingUpDown = doorInformation.WeldSpacingUpDown[0].ToString(); for (int i = 1; i < doorInformation.WeldNumUpDown; i++) { spacingUpDown = spacingUpDown + ","; spacingUpDown = spacingUpDown + doorInformation.WeldSpacingUpDown[i].ToString(); } doorInformation.WeldSpacingUpDownStr = spacingUpDown; string spacingHinge = doorInformation.WeldSpacingHinge[0].ToString(); for (int i = 1; i < doorInformation.WeldNumHinge; i++) { spacingHinge = spacingHinge + ","; spacingHinge = spacingHinge + doorInformation.WeldSpacingHinge[i].ToString(); } doorInformation.WeldSpacingHingeStr = spacingHinge; string spacingKeyhole = doorInformation.WeldSpacingKeyhole[0].ToString(); for (int i = 1; i < doorInformation.WeldNumKeyhole; i++) { spacingKeyhole = spacingKeyhole + ","; spacingKeyhole = spacingKeyhole + doorInformation.WeldSpacingKeyhole[i].ToString(); } doorInformation.WeldSpacingKeyholeStr = spacingKeyhole; DoorInfoShow(doorInformation); } else { MessageBox.Show("该订单门类型不符!"); } } } }
public void SendMail(OrderInformation orderInformation, int orderNumber) { string orderPrice = (orderInformation.GoodsTotalPrice + orderInformation.DeliveryPrice).ToString(); string productsHTML = ""; for (int i = 0; i < orderInformation.GoodNameArray.Count(); i++) { productsHTML += @" <!-- Product --> <tr> <td> <table width = '100%' style = 'border-collapse:collapse; border-top:1px solid #E5E5E5;'> <tr><td height='24' colspan ='5'></td></tr> <tr> <td width='24'></td> <td width='80'><img src='http://*****:*****@"' width='80' alt='" + orderInformation.GoodNameArray[i] + @"'></td> <td width='24'></td> <td > <a href='#' style='font-size:20px; color:#424A5B; text-decoration:none'>" + orderInformation.GoodNameArray[i] + @"</span><br> <span style='font-size:12px; color:#939CA2;'>Purchased: " + DateTime.Now.ToUniversalTime() + @"</span > </td> <td width='124'> <table style = 'border-collapse:collapse'> <tr> <td width='24'></td> <td width='80' style = 'color:#424A5B; text-align: right;'> " + orderInformation.GoodQuantityArray[i] + @" X $" + orderInformation.GoodPriceArray[i] + @"<br> $" + orderInformation.GoodTotalPriceArray[i] + @" </td > <td width='24'></td> </tr> </table> </td> </tr> <tr><td height='24' colspan='5'></td></tr> </table> </td> </tr> <!-- Product end --> "; } string mailBody = @" <table align='center' bgcolor='#f9f8fb' style='font-family:Helvetica;border-collapse:collapse;width:100%;'> <tr> <td colspan='3' height='24'></td> </tr> <tr align='center'> <td width='24'></td> <td> <!-- Mail information --> <table style='border-collapse:collapse; width:100%;'> <!-- Header --> <tr align='center'> <td> <table> <tr width='100%' height='24'><td></td></tr> <tr><td><a href='http://*****:*****@"</span>!<br> <span style='font-size: 14px;'>You have made an order! Order information is shown below.</span> </td> </tr> </table> </td> <td width='162'> <table> <tr> <td width='18'></td> <td width='126'> <a href='http://*****:*****@" <!-- Delivery method --> <tr> <td> <table width='100%' style='height:49px; border-collapse:collapse; border-top:1px solid #E5E5E5;'> <tr> <td width='24'></td> <td align='left' style='font-size:12px; color:#939CA2;'>" + orderInformation.DeliveryMethods + @"</td> <td align='right' style='font-size:16px; color:#424A5B;'>$ " + orderInformation.DeliveryPrice + @"</td> <td width='24'></td> </tr> </table> </td> </tr> <!-- Delivery method end --> <!-- Total price --> <tr> <td> <table width='100%' style='height:49px; border-collapse:collapse; border-top:1px solid #E5E5E5;'> <tr> <td width='24'></td> <td align='left' style='font-size:12px; color:#939CA2;'>TOTAL</td> <td align='right' style='font-size:16px; color:#424A5B;'>$ " + orderPrice + @"</td> <td width='24'></td> </tr> </table> </td> </tr> <!-- Total price end --> </table> </td> </tr> <tr> <td align='center'> <table> <tr width='100%' height='24'><td></td></tr> <tr><td align='center' style='font-size:12px; color:#7E8993;'><a href='http://*****:*****@gmail.com", orderInformation.AddresseeEmail)) { mm.Subject = "Order №" + orderNumber.ToString(); mm.Body = mailBody; mm.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "ShakuroMarketplace2018"); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); } } }
/// <summary> /// This method will build the payload required for Creating Response in the Partner API /// </summary> /// <param name="response"></param> /// <param name="loanInformation"></param> /// <param name="transactionId"></param> private void SubmitAcknowledgementToPartnerAPI(JObject response, JToken loanInformation, string transactionId) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - [STARTS]"); try { if (response != null) { _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Submitting Resposne to Partner API "); // assuming the response is of type JToken if (response.SelectToken("$.result") != null && loanInformation != null) { var result = response.SelectToken("$.result"); var productName = loanInformation.SelectToken("$.product.options.productName"); var productId = loanInformation.SelectToken("$.product.options.productId"); var existingOrderId = loanInformation.SelectToken("$.product.options.existingOrderId"); var random = new System.Random(); // setting the order id to existingOrderId if the payload has it otherwise setting it to a random number var orderId = existingOrderId != null?existingOrderId.ToString() : random.Next(10000, 80000).ToString(); var orderInfo = new OrderInformation() { TransactionId = transactionId, ProductName = productName != null?productName.ToString() : string.Empty, ProductCode = productId != null?productId.ToString() : string.Empty, OrderId = existingOrderId != null?existingOrderId.ToString() : orderId.ToString(), // adding existing order id if it exists in the response object, OrderStatus = response.SelectToken("$.status").ToString(), LoanInformation = loanInformation }; // Adding Transaction Information in the local In Memory cache. This would be implemented by the partner in their own way to track transactions and their order statuses TransactionInformationCache.Instance.Add(orderInfo); // building payload for Partner API Create Response dynamic responsePayload = new JObject(); dynamic orders = new JArray(); dynamic order = new JObject(); //var orderDate = DateTime.Now.ToUniversalTime(); var orderDate = DateTime.Now; _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Order Date time is " + orderDate.ToString("o")); order.id = orderId.ToString(); order.orderDateTime = orderDate.ToString("yyyy-MM-ddTHH:mm-ss:ff"); // result["orderDate"]; order.orderStatus = response["status"]; order.orderMessage = result["orderMessage"]; order.product = productName; order.documents = new JArray(); orders.Add(order); responsePayload.orders = orders; var responsePayloadString = Convert.ToString(responsePayload); var partnerAPIWrapper = new PartnerAPIWrapper(this._AppSettings); // This is the POST call to the Partner API (Create Response call) | partner/v1/transactions/{{transactionId}}/response var isResponseCreated = partnerAPIWrapper.CreateResponse(responsePayloadString, transactionId); if (isResponseCreated) { TransactionStatusCache.Instance.Add(transactionId, response); } } } } catch (Exception ex) { _Logger.LogError("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - Exception - " + ex.Message); _Logger.LogError("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - StackTrace - " + ex.StackTrace); } _Logger.LogInformation("[" + _ClassName + "] - SubmitAcknowledgementToPartnerAPI - [ENDS]"); }
/// <summary> /// Processes user's history type selection input /// </summary> /// <param name="orderHistoryType"></param> /// <param name="store"></param> /// <returns>Appropriate order history list view</returns> public IActionResult GetOrderHistorySelection(int orderHistoryType, Stores store = null) { if (orderHistoryType == 1) //User selects to see their order history { //Return the customer order history view which always prints out the order history of the currently logged in customer var loggedIn = _cache.Get("loggedInCustomer"); loggedInCustomer = (Customers)loggedIn; //Select all the orders associated with logged in customer var custOrders = (from Orders in _db.Orders where Orders.WhoOrdered == loggedInCustomer.CustomerId select new { Orders.OrderDate, Orders.OrderTotal, Orders.OrderId, Orders.OrderedProduct, Orders.OrderedProductAmount, Orders.StoreOrderedFrom, Orders.WhoOrdered }).ToList(); //Select all the product info var orderItems = (from Products in _db.Products where Products.IsInBundle == false select new { Products.Skunum, Products.ProductName, Products.UnitPrice, Products.ProductDiscount }).ToList(); //Get product info on all items in the order var custOrderInfo = (from Orders in custOrders from Products in orderItems where Orders.OrderedProduct == Products.Skunum orderby Orders.OrderDate descending select new { Orders.OrderId, Orders.OrderTotal, Orders.OrderedProduct, Products.ProductName, Orders.OrderedProductAmount, Products.UnitPrice, Products.ProductDiscount, Orders.StoreOrderedFrom, Orders.WhoOrdered, Orders.OrderDate, }).ToList(); //Fresh instantiation of the OrderInfo list for populating orderInfo = new List <OrderInformation>(); foreach (var order in custOrderInfo) { OrderInformation item = new OrderInformation(); item.OrderId = order.OrderId; item.OrderedProduct = order.OrderedProduct; item.ProductName = order.ProductName; item.OrderedProductAmount = order.OrderedProductAmount; item.UnitPrice = order.UnitPrice; item.ProductDiscount = order.ProductDiscount; item.StoreOrderedFrom = order.StoreOrderedFrom; item.WhoOrdered = order.WhoOrdered; item.OrderDate = order.OrderDate; item.OrderTotal = order.OrderTotal; orderInfo.Add(item); } return(View("_CustomerOrderHistory", orderInfo)); } return(View("_GetOrderHistorySelection")); }