public static string CallWebAPIOrderWithReceipt(Order order, bool htmlReceipt) { CleanNavigationPropertys(order); string orderToSend = Newtonsoft.Json.JsonConvert.SerializeObject(order); string parameter = "htmlRecept"; string value = htmlReceipt.ToString(); string FullUrl = GetURlWithParameter(GenerateOrderWithReceptUrl, parameter, value); string result = ""; string jsonResult = ""; try { using (WebClient client = new WebClient()) { client.Headers.Add("Content-Type", "application/json"); client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; jsonResult = client.UploadString(FullUrl, "=" + orderToSend); } if (jsonResult != null && jsonResult != "") { result = Newtonsoft.Json.JsonConvert.DeserializeObject<String>(jsonResult); } } catch (Exception ex) { log.Error(ex, ex.Message); } return result; }
public static void SendSuccessNotification(Order order) { // TODO Временно заигнорил все номера, кроме номера оператора. Вернуть. //SendNotification(order.Customer.PhoneNumber, string.Format(CustomerMessage, order.Customer.Name, order.StartGame.ToString(), OperatorNumber)); SendNotification(OperatorNumber, string.Format(OperatorSuccessMessage, order.StartGame, order.Customer.Name, order.Customer.PhoneNumber)); //SendNotification(AdministratorNumber, string.Format(AdministratorMessage, order.StartGame, order.Customer.Name, order.Customer.PhoneNumber)); }
public void HtmlReceiptOneDefyDLLUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(DefyLocal, 1)); OrderApplication orderApplication = new OrderApplication(); string receipt = orderApplication.orderService.GenerateOrderWithRecept(order, true); Assert.AreEqual(HtmlResultStatementOneDefy, receipt); }
public void ReceiptOndeDefyWebAPIUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(DefyLocal, 1)); string receipt = OrderAPIClient.CallWebAPIOrderWithReceipt(order, false); Assert.AreEqual(ResultStatementOneDefy, receipt); }
public void HtmlReceiptOneDuraAceWebAPIUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(DuraAceLocal, 1)); string receipt = OrderAPIClient.CallWebAPIOrderWithReceipt(order, true); Assert.AreEqual(HtmlResultStatementOneDuraAce, receipt); }
public void ReceiptOneDefyDLLUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(DefyLocal, 1)); OrderApplication orderApplication = new OrderApplication(); string receipt = orderApplication.orderService.GenerateOrderWithRecept(order, false); Assert.AreEqual(ResultStatementOneDefy, receipt); }
private static void CleanNavigationPropertys(Order order) { foreach (Line line in order.Line) { line.Order = null; if (line.Bike != null) { line.Bike.Line = null; } } }
public string DoHtmlReceipt(Order order) { var totalAmount = 0d; var result = new StringBuilder(string.Format("<html><body><h1>Order Receipt for {0}</h1>", order.Company)); if (order.Line != null && order.Line.Count > 0) { result.Append("<ul>"); foreach (var line in order.Line) { var thisAmount = 0d; if (line.Bike != null && line.Bike.Price != null) { switch (line.Bike.PriceRange) { case NumericValues.OneThousand: if (line.Quantity >= 20) thisAmount += line.Quantity * line.Bike.Price.Value * .9d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; case NumericValues.TwoThousand: if (line.Quantity >= 10) thisAmount += line.Quantity * line.Bike.Price.Value * .8d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; case NumericValues.FiveThousand: if (line.Quantity >= 5) thisAmount += line.Quantity * line.Bike.Price.Value * .8d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; } } result.Append(string.Format("<li>{0} x {1} {2} = {3}</li>", line.Quantity, line.Bike.Brand, line.Bike.Model, thisAmount.ToString("C"))); totalAmount += thisAmount; } result.Append("</ul>"); } result.Append(string.Format("<h3>Sub-Total: {0}</h3>", totalAmount.ToString("C"))); var tax = totalAmount * order.TaxRate.Value; result.Append(string.Format("<h3>Tax: {0}</h3>", tax.ToString("C"))); result.Append(string.Format("<h2>Total: {0}</h2>", (totalAmount + tax).ToString("C"))); result.Append("</body></html>"); return result.ToString(); }
public void HtmlReceiptOneDefyWebAPIUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(DefyLocal, 1)); string receipt = OrderAPIClient.CallWebAPIOrderWithReceipt(order, true); Assert.AreEqual(HtmlResultStatementOneDefy, receipt); }
public void ReceiptOneEliteWebAPIUsage() { var order = new Domain.Entity.Order("Anywhere Bike Shop"); order.AddLine(LineInstance.NewLine(EliteLocal, 1)); string receipt = OrderAPIClient.CallWebAPIOrderWithReceipt(order, false); Assert.AreEqual(ResultStatementOneElite, receipt); }
/// <summary> /// 保存实体信息 /// </summary> /// <param name="pEntity">实体对象</param> /// <returns>是否成功</returns> public void Save(Order pEntity) { HibernateDaoHelp.SaveOrUpdate(pEntity); }
public int CreateOrder(Domain.Entity.Order order) { return(orderApplication.orderService.CreateOrder(order)); }
public string GenerateOrderWithRecept(Order order, bool htmlRecept) { CreateOrder(order); if (htmlRecept) { return DoHtmlReceipt(order); } else { return DoReceipt(order); } }
private String DoReceipt(Order order) { var totalAmount = 0d; var result = new StringBuilder(string.Format("Order Receipt for {0}{1}", order.Company, Environment.NewLine)); if (order.Line != null && order.Line.Count > 0) { foreach (var line in order.Line) { var thisAmount = 0d; if (line.Bike != null && line.Bike.Price != null) { switch (line.Bike.PriceRange) { case NumericValues.OneThousand: if (line.Quantity >= 20) thisAmount += line.Quantity * line.Bike.Price.Value * .9d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; case NumericValues.TwoThousand: if (line.Quantity >= 10) thisAmount += line.Quantity * line.Bike.Price.Value * .8d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; case NumericValues.FiveThousand: if (line.Quantity >= 5) thisAmount += line.Quantity * line.Bike.Price.Value * .8d; else thisAmount += line.Quantity * line.Bike.Price.Value; break; } } result.AppendLine(string.Format("\t{0} x {1} {2} = {3}", line.Quantity, line.Bike.Brand, line.Bike.Model, thisAmount.ToString("C"))); totalAmount += thisAmount; } } result.AppendLine(string.Format("Sub-Total: {0}", totalAmount.ToString("C"))); var tax = totalAmount * order.TaxRate.Value; result.AppendLine(string.Format("Tax: {0}", tax.ToString("C"))); result.Append(string.Format("Total: {0}", (totalAmount + tax).ToString("C"))); return result.ToString(); }