/// <summary> /// 根据配送方式,配送地址,读取邮费价格【按单个商品独立计算运费】 /// 如买了2件商品,一件商品买了2个,一件商品买了1个,则需计算两次,第一次重量叠加计算(相同商品购买多个则叠加计算) /// </summary> /// <returns></returns> public static decimal ReadShippingMoney(ShippingInfo shipping, ShippingRegionInfo shippingRegion, CartInfo cart) { decimal shippingMoney = 0; switch (shipping.ShippingType) { case (int)ShippingType.Fixed: shippingMoney = shippingRegion.FixedMoeny; break; case (int)ShippingType.Weight: decimal cartProductWeight = cart.BuyCount * cart.Product.Weight; if (cartProductWeight <= shipping.FirstWeight) { shippingMoney = shippingRegion.FirstMoney; } else { shippingMoney = shippingRegion.FirstMoney + Math.Ceiling((cartProductWeight - shipping.FirstWeight) / shipping.AgainWeight) * shippingRegion.AgainMoney; } break; case (int)ShippingType.ProductCount: int cartProductCount = cart.BuyCount; shippingMoney = shippingRegion.OneMoeny + (cartProductCount - 1) * shippingRegion.AnotherMoeny; break; default: break; } return(shippingMoney); }
public async Task <IActionResult> Edit(int id, [Bind("ShippingId,DeliveryBoyId,ShippingCost,ShippingDate")] ShippingInfo shippingInfo) { if (id != shippingInfo.ShippingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shippingInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShippingInfoExists(shippingInfo.ShippingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DeliveryBoyId"] = new SelectList(_context.DeliveryBoys, "DeliveryBoyId", "DeliveryBoyName", shippingInfo.DeliveryBoyId); return(View(shippingInfo)); }
public void ChangeShippingInfoRepo(string userId, ChangeShippingInputModel newShippingInfo) { var change = (from u in _db.shipingInfo where u.aspUserIdForShipping == userId select u).FirstOrDefault(); if (change == null) { ShippingInfo shiping = new ShippingInfo { address = newShippingInfo.address, city = newShippingInfo.city, country = newShippingInfo.country, zipCode = newShippingInfo.zipCode, aspUserIdForShipping = userId }; addShippingAddresToDataBase(shiping); } else { change.address = newShippingInfo.address; change.city = newShippingInfo.city; change.country = newShippingInfo.country; change.zipCode = newShippingInfo.zipCode; } _db.SaveChanges(); }
public void GetShippingStatus_GivenAnOrderID_ReturnsTheShippingStatus() { // arrange var request = new ShippingInfo() { Name = "Not Relevant!", City = "Not Relevant!", Country = "Not Relevant!", Email = "Not Relevant!", Phone = "Not Relevant!", PostalCode = "Irrelevant", Province = "Not Relevant!", StreetAddress = "Not Relevant!", Status = ShippingStatus.None, OrderID = 1212, WarehouseID = 7, ServiceID = 4 }; shippingClient.RequestShipping(request); // act var actual = shippingClient.GetShippingStatus(1212); // assert Assert.AreEqual(ShippingStatus.ReceivedOrder, actual); }
public void CreateOrder(List <Product> orderItems, ShippingInfo shippingInfo) { var order = Order.NewOrder(Guid.NewGuid()); order.Create(orderItems, shippingInfo); _eventStoreRepository.Save(order); }
public void OrderFactoryCreateValidOrder() { //Arrange string shippingName = "shippingName"; string shippingCity = "shippingCity"; string shippingZipCode = "shippingZipCode"; string shippingAddress = "shippingAddress"; Customer customer = new Customer(); customer.GenerateNewIdentity(); //Act Order order = OrderFactory.CreateOrder(customer, shippingName, shippingCity, shippingAddress, shippingZipCode); var validationContext = new ValidationContext(order, null, null); var validationResult = order.Validate(validationContext); //Assert ShippingInfo shippingInfo = new ShippingInfo(shippingName, shippingAddress, shippingCity, shippingZipCode); Assert.AreEqual(shippingInfo, order.ShippingInformation); Assert.AreEqual(order.Customer, customer); Assert.AreEqual(order.CustomerId, customer.Id); Assert.IsFalse(order.IsDelivered); Assert.IsNull(order.DeliveryDate); Assert.IsTrue(order.OrderDate != default(DateTime)); Assert.IsFalse(validationResult.Any()); }
protected void Page_Load(object sender, EventArgs e) { PaymentInfo p = (PaymentInfo)Session["PaymentInfo"]; ShippingInfo s = (ShippingInfo)Session["ShippingInfo"]; infoLbl.Text = "Your credit card of type " + p.ccType + " will be charged a total of $" + Session["Total"] + ". Please click on the confirm button below to confirm this purchase."; }
protected virtual ShippingInfo setPickupInfo(DeliveryOption deliveryOption, DeliveryOptionType deliveryOptionType) { ShippingInfo shippingInfo = ShoppingCart.DeliveryInfo; int deliveryOptionID = 0, shippingAddressID = 0; if (shippingInfo != null) { shippingAddressID = deliveryOptionType == DeliveryOptionType.Shipping ? deliveryOption.Id : shippingInfo.Address.ID; deliveryOptionID = deliveryOptionType == DeliveryOptionType.Shipping ? shippingInfo.Id : deliveryOption.Id; } else { shippingAddressID = deliveryOptionType == DeliveryOptionType.Shipping ? deliveryOption.Id : 0; deliveryOptionID = deliveryOptionType == DeliveryOptionType.Shipping ? 0 : deliveryOption.Id; } updateShippingInfo(shippingAddressID, deliveryOptionID, deliveryOptionType); return(shippingInfo); }
public async Task <IActionResult> PutShippingInfo([FromRoute] int id, [FromBody] ShippingInfo shippingInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shippingInfo.ShippingInfoId) { return(BadRequest()); } _context.Entry(shippingInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShippingInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private IDictionary <Warehouse, IEnumerable <OrderItem> > SegmentOrderOnAvailability( IEnumerable <OrderItem> itemsList, ShippingInfo shipping) { List <OrderItem> items = new List <OrderItem>(itemsList); Dictionary <Warehouse, IEnumerable <OrderItem> > orderSegments = new Dictionary <Warehouse, IEnumerable <OrderItem> >(); var warehouses = locationService.GetNearestWarehousesTo(shipping.City, shipping.Province, shipping.Country); foreach (Warehouse w in warehouses) { if (items.Count > 0) { CheckOrderItems(items, w, orderSegments); } else { // no other item is left break; } } return(orderSegments); }
public static Order Given_OrderIsReady(List <Product> orderItems, ShippingInfo shippingInfo) { var order = Order.NewOrder(Guid.NewGuid()); order.Create(orderItems, shippingInfo); return(order); }
protected override void PageLoad() { base.PageLoad(); int orderid = RequestHelper.GetQueryString <int>("orderid"); if (orderid > 0) { tempOrder = OrderBLL.Read(orderid); ShippingInfo tempShipping = ShippingBLL.Read(tempOrder.ShippingId); string show = RequestHelper.GetQueryString <string>("show"); //string apiurl = "http://api.kuaidi100.com/api?id=2815b2d431fdfd26&com=" + typeCom + "&nu=" + nu + "&show=" + show + "&muti=1&order=asc"; string apiurl = "http://www.kuaidi100.com/applyurl?key=2815b2d431fdfd26&com=" + tempShipping.ShippingCode + "&nu=" + tempOrder.ShippingNumber + "&show=" + show + "&muti=1&order=desc"; //Response.Write (apiurl); WebRequest request = WebRequest.Create(@apiurl); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); Encoding encode = Encoding.UTF8; StreamReader reader = new StreamReader(stream, encode); shippingStr = reader.ReadToEnd(); } }
public ShipOrderCommand(int orderId, int warehouseEmployeeId, DateTime updateTime, ShippingInfo shippingInfo) { OrderId = orderId; WarehouseEmployeeId = warehouseEmployeeId; UpdateTime = updateTime; ShippingInfo = shippingInfo; }
protected override void PageLoad() { base.PageLoad(); int orderid = RequestHelper.GetQueryString <int>("orderid"); if (orderid > 0) { tempOrder = OrderBLL.Read(orderid); ShippingInfo tempShipping = ShippingBLL.Read(tempOrder.ShippingId); string show = RequestHelper.GetQueryString <string>("show"); //string apiurl = "http://api.kuaidi100.com/api?id=2815b2d431fdfd26&com=" + typeCom + "&nu=" + nu + "&show=" + show + "&muti=1&order=asc"; string apiurl = "https://m.kuaidi100.com/index_all.html?type=" + tempShipping.ShippingCode + "&postid=" + tempOrder.ShippingNumber + "&callbackurl=" + "http://" + HttpContext.Current.Request.Url.Host + "/mobile/User/OrderDetail.html?ID=" + orderid; ////Response.Write (apiurl); //WebRequest request = WebRequest.Create(@apiurl); //WebResponse response = request.GetResponse(); //Stream stream = response.GetResponseStream(); //Encoding encode = Encoding.UTF8; //StreamReader reader = new StreamReader(stream, encode); //shippingStr = reader.ReadToEnd(); // Response.Redirect(apiurl); Response.Write("<script>window.location.href='" + apiurl + "'</script>"); Response.End(); } }
public void RequestShipping_GivenANewShipping_AddsTheRequestToTheDatabase() { // arrange var request = new ShippingInfo() { Name = "Not Relevant!", City = "Not Relevant!", Country = "Not Relevant!", Email = "Not Relevant!", Phone = "Not Relevant!", PostalCode = "Irrelevant", Province = "Not Relevant!", StreetAddress = "Not Relevant!", Status = ShippingStatus.None, OrderID = 4141, WarehouseID = 7, ServiceID = 4 }; // act shippingClient.RequestShipping(request); // assert var status = shippingClient.GetShippingStatus(4141); Assert.AreEqual(ShippingStatus.ReceivedOrder, status); }
public static List <ShippingInfo> GetShippingInfo(int shippingRegionId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "CommerceLibShippingGetInfo"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@ShippingRegionId"; param.Value = shippingRegionId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // obtain the results DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); List <ShippingInfo> result = new List <ShippingInfo>(); foreach (DataRow row in table.Rows) { ShippingInfo rowData = new ShippingInfo(); rowData.ShippingID = int.Parse(row["ShippingId"].ToString()); rowData.ShippingType = row["ShippingType"].ToString(); rowData.ShippingCost = double.Parse(row["ShippingCost"].ToString()); rowData.ShippingRegionId = shippingRegionId; result.Add(rowData); } return(result); }
/// <summary> /// 买1件商品,根据配送方式,配送地址,读取邮费价格【按单个商品独立计算运费】 /// </summary> /// <param name="shipping"></param> /// <param name="shippingRegion"></param> /// <param name="product"></param> /// <returns></returns> public static decimal ReadShippingMoney(int shippingId, string regionId, ProductInfo product) { decimal shippingMoney = 0; ShippingInfo shipping = ShippingBLL.Read(shippingId); ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shippingId, regionId); switch (shipping.ShippingType) { case (int)ShippingType.Fixed: shippingMoney = shippingRegion.FixedMoeny; break; case (int)ShippingType.Weight: decimal cartProductWeight = 1 * product.Weight; if (cartProductWeight <= shipping.FirstWeight) { shippingMoney = shippingRegion.FirstMoney; } else { shippingMoney = shippingRegion.FirstMoney + Math.Ceiling((cartProductWeight - shipping.FirstWeight) / shipping.AgainWeight) * shippingRegion.AgainMoney; } break; case (int)ShippingType.ProductCount: int cartProductCount = 1; shippingMoney = shippingRegion.OneMoeny + (cartProductCount - 1) * shippingRegion.AnotherMoeny; break; default: break; } return(shippingMoney); }
public async Task ShipOrder() { var bolApiCaller = new BolApiCaller(testClientId, testClientSecret, true); var response = await bolApiCaller.Orders.GetOpenOrders(1, FulFilmentMethod.FBR); var requestWasSend = false; foreach (var order in response.Orders) { foreach (var orderItem in order.OrderItems) { var shippingInfo = new ShippingInfo(); shippingInfo.OrderItems = new List <OrderItemIdContainer>() { new OrderItemIdContainer() { OrderItemId = orderItem.OrderItemId } }; var shipmentResponse = await bolApiCaller.Orders.ShipOrderItem(shippingInfo); requestWasSend = true; Assert.IsTrue(shipmentResponse.EventType == "CONFIRM_SHIPMENT"); //The BOL api limits the amount of calls on this endpoint await Task.Delay(100); } } Assert.IsTrue(requestWasSend); Assert.IsTrue(response.Orders.Length > 0); }
public void SendOrders(Cart cart, ShippingInfo shipinfo) { int maxId = context.Orders.Max(r => r.Id); maxId++; context.Orders.Add(new Order { Id = maxId, DateOfOrder = DateTime.Today.Date, City = shipinfo.City, ShippAddress = shipinfo.AddressLine, Country = shipinfo.Country, Status = "Send", UserId = HttpContext.Current.User.Identity.GetUserId().ToString() } ); context.SaveChanges(); foreach (var line in cart.Lines) { context.OrderProducts.Add(new OrderProduct { OrderId = context.Orders.Max(r => r.Id), ProductId = line.Product.Id, Size = line.Size, } ); //context.Products.Where(x => x.Id == line.Product.Id).First().Amount -= line.Quantity; } ; context.SaveChanges(); }
private Customer GetAllCustomerFromComponents() { Customer aCustomer = new Customer(); aCustomer.CustomerId = Int32.Parse(txt_id.Text); aCustomer.Street = txt_Add.Text; aCustomer.State = txt_State.Text; aCustomer.Phone = txt_Phone.Text; aCustomer.City = txt_City.Text; aCustomer.CustLastName = txt_ln.Text; aCustomer.CustFirstName = txt_fn.Text; aCustomer.PostCode = txt_post.Text; aCustomer.DiscountRate = float.Parse(cb_Rate.Text); aCustomer.CUSTNAME = txt_Name.Text; if (!chk_ship.Checked) { aCustomer.MutiAddress = "N"; ShippingInfo aInfo = new ShippingInfo(); aInfo.CustosmerId = aCustomer.CustomerId; aInfo.ShippingStreet = m_address.Text; aInfo.ShippingCity = m_city.Text; aInfo.ShippingFirstName = m_first.Text; aInfo.ShippingLastName = m_last.Text; aInfo.ShipppingPost = m_postcode.Text; aInfo.ShippingState = m_state.Text; aInfo.ShippingPhone = m_Phone.Text.ToString(); aCustomer.ShipInfo = aInfo; } else { aCustomer.MutiAddress = "Y"; } return(aCustomer); }
protected void SubmitButton_Click(object sender, EventArgs e) { ShippingInfo shipping = new ShippingInfo(); shipping.ID = RequestHelper.GetQueryString <int>("ID"); shipping.Name = this.Name.Text; shipping.Description = this.Description.Text; shipping.IsEnabled = Convert.ToInt32(this.IsEnabled.Text); shipping.ShippingType = Convert.ToInt32(this.ShippingType.Text); shipping.FirstWeight = Convert.ToInt32(this.FirstWeight.Text); shipping.AgainWeight = Convert.ToInt32(this.AgainWeight.Text); string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (shipping.ID == -2147483648) { base.CheckAdminPower("AddShipping", PowerCheckType.Single); int id = ShippingBLL.AddShipping(shipping); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Shipping"), id); } else { base.CheckAdminPower("UpdateShipping", PowerCheckType.Single); ShippingBLL.UpdateShipping(shipping); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Shipping"), shipping.ID); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl); }
private async Task <IActionResult> inputShippingInfo(ShippingInfoDto shippingInfo, int?orderId) { if (shippingInfo == null || orderId == null) { return(NotFound("No shipping address or order_id!")); } shippingInfo.orderId = orderId.GetValueOrDefault(); var newShipping = new ShippingInfo(); newShipping.orderId = shippingInfo.orderId; newShipping.sender = shippingInfo.sender; newShipping.sender_phone = shippingInfo.sender_phone; newShipping.sender_address = shippingInfo.sender_address; newShipping.sender_city = shippingInfo.sender_city; newShipping.sender_country = shippingInfo.sender_country; newShipping.receiver = shippingInfo.receiver; newShipping.receiver_phone = shippingInfo.receiver_phone; newShipping.receiver_address1 = shippingInfo.receiver_address1; newShipping.receiver_address2 = shippingInfo.receiver_address2; newShipping.receiver_address3 = shippingInfo.receiver_address3; newShipping.receiver_city = shippingInfo.receiver_city; newShipping.receiver_country = shippingInfo.receiver_country; newShipping.receiver_company = shippingInfo.receiver_company; newShipping.receiver_contact = shippingInfo.receiver_contact; newShipping.note = shippingInfo.note; await _context.ShippingInfo.AddAsync(newShipping); await _context.SaveChangesAsync(); return(Ok()); }
protected void SubmitButton_Click(object sender, EventArgs e) { ShippingInfo shipping = new ShippingInfo(); shipping.Id = RequestHelper.GetQueryString <int>("Id"); shipping.Name = Name.Text; shipping.Description = Description.Text; shipping.IsEnabled = RequestHelper.GetForm <int>("IsEnabled"); shipping.ShippingType = RequestHelper.GetForm <int>("ShippingType"); shipping.FirstWeight = Convert.ToInt32(FirstWeight.Text); shipping.AgainWeight = Convert.ToInt32(AgainWeight.Text); shipping.ShippingCode = ShippingCode.Text.Trim(); string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (shipping.Id == int.MinValue) { CheckAdminPower("AddShipping", PowerCheckType.Single); int id = ShippingBLL.Add(shipping); AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Shipping"), id); } else { CheckAdminPower("UpdateShipping", PowerCheckType.Single); ShippingBLL.Update(shipping); AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Shipping"), shipping.Id); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl); }
//Upplisingar sendingarupplýsingar public bool ShippingInfo(ShippingInfoInputModel shipping, string user, int cartId) { if (cartId == 0) { return(false); } //Bý til nýjar sendinarupplýsingar //Á eftir að útfæra ef notandi hefur þegar gert pöntun og hann vill breyta //Get séð út frá nýjasta ID með pöntuninni hvað á að nota var userInfo = new ShippingInfo { UserId = user, OrderId = cartId, FullName = shipping.FullName, Country = shipping.Country, Zipcode = shipping.Zipcode, City = shipping.City, Adress = shipping.Adress, PhoneNumber = shipping.PhoneNumber }; //ef næst ekki í notanda if (userInfo == null) { return(false); } //bæti við í gangagrunninn _db.ShippingInfos.Add(userInfo); _db.SaveChanges(); return(true); }
private void showShippingMethodReadonly() { ShippingInfo shippingInfo = ShoppingCart.DeliveryInfo; if (shippingInfo != null) { DeliveryTypeReadonly.Text = (string)GetLocalResourceObject("DeliveryOptionType_" + shippingInfo.Option.ToString()); if (shippingInfo.Option == DeliveryOptionType.Shipping) { if (!String.IsNullOrEmpty(shippingInfo.Address.Alias)) { DropdownNickNameReadonly.Text = shippingInfo.Address.Alias; } else { DropdownNickNameReadonly.Text = shippingInfo.Address.Recipient; } } else if (shippingInfo.Option == DeliveryOptionType.Pickup) { DropdownNickNameReadonly.Text = shippingInfo.Description; } } }
private ShippingInfo InitializeModel(IRepository repo) { ApplicationUser prof = (ApplicationUser)Session["Profile"]; ShippingInfo shipInfo = new ShippingInfo(repo) { ShipDet = new ShippingDetails() { Name = prof.Name, Surname = prof.Surname, Email = prof.Email, Phone = prof.Phone } }; if (prof.ShippingAddressId != null) { ShippingAddress adr = prof.ShippingAddress.Where(p => p.RecordId == prof.ShippingAddressId).First(); // if address data is present fill the model shipInfo.ShipDet.UnitFlat = adr.UnitNumber; shipInfo.ShipDet.Town = adr.Town; shipInfo.ShipDet.StreetType = adr.StreetType; shipInfo.ShipDet.StreetNumber = adr.StreetNumber; shipInfo.ShipDet.StreetName = adr.StreetName; shipInfo.ShipDet.State = adr.State; shipInfo.ShipDet.PostCode = adr.PostCode; shipInfo.ShipDet.Country = adr.Country; } return(shipInfo); }
/// <summary> /// Create a new order /// </summary> /// <param name="customer">Associated customer</param> /// <param name="shippingName">The order shipping name</param> /// <param name="shippingCity">The order shipping city</param> /// <param name="shippingAddress">The order shipping address</param> /// <param name="shippingZipCode">The order shipping zip cocde</param> /// <returns>Associated order</returns> public static Order CreateOrder( Customer customer, string shippingName, string shippingCity, string shippingAddress, string shippingZipCode) { //create the order var order = new Order(); //create shipping var shipping = new ShippingInfo(shippingName, shippingAddress, shippingCity, shippingZipCode); //set default values order.OrderDate = DateTime.UtcNow; order.DeliveryDate = null; order.ShippingInformation = shipping; //set customer information order.SetTheCustomerForThisOrder(customer); //set identity order.GenerateNewIdentity(); return order; }
public ActionResult DeleteConfirmed(int id) { ShippingInfo shippingInfo = db.ShippingInfoes.Find(id); db.ShippingInfoes.Remove(shippingInfo); db.SaveChanges(); return(RedirectToAction("Index")); }
protected override void Given() { _sut = new PurchaseOrder(123); var shippingInfo = new ShippingInfo("foo", "bar"); _sut.AddShippingInfo(shippingInfo); }
/// <summary> /// Ship a single order item within a customer order by providing shipping information. /// In case you purchased a shipping label you can add the shippingLabelCode to this message. /// In that case the transport element must be left empty. /// If you ship the item(s) using your own transporter method you must omit the shippingLabelCode entirely. /// </summary> /// <param name="orderItemId">The order item being confirmed.</param> /// <param name="shippingInfo"></param> /// <returns></returns> public async Task <StatusResponse> ShipOrderItem(ShippingInfo shippingInfo) { using (var content = BolApiHelper.BuildContentFromObject(shippingInfo)) { var response = await Put($"/orders/shipment", content).ConfigureAwait(false); return(await BolApiHelper.GetContentFromResponse <StatusResponse>(response).ConfigureAwait(false)); } }
protected override void Given() { _sut = new PurchaseOrder(123); var existingShippingInfo = new ShippingInfo("Joe Bloggs", "High Street 1, NYC"); _sut.AddShippingInfo(existingShippingInfo); _shippingInfo = new ShippingInfo("foo", "bar"); }
private static IShippingRequest GenerateShippingRequest(ShippingInfo shippingInfo) { EcommerceConfig config = Config.Get<EcommerceConfig>(); var request = new GenericShippingRequest(config.ShippingFromCountry, config.ShippingFromZip, shippingInfo.ShippingToCountry, shippingInfo.ShippingToZip, config.DefaultBoxLength, config.DefaultBoxWidth, config.DefaultBoxHeight, shippingInfo.TotalCartWeight ); return request; }
/// <summary> /// Create a new order /// </summary> /// <param name="customerId">Associated customer identifier</param> /// <param name="shippingName">The order shipping name</param> /// <param name="shippingCity">The order shipping city</param> /// <param name="shippingAddress">The order shipping address</param> /// <param name="shippingZipCode">The order shipping zip cocde</param> /// <returns>Associated order</returns> public static Order CreateOrder(Guid customerId, string shippingName, string shippingCity, string shippingAddress, string shippingZipCode) { //create the order var order = new Order(); //create shipping var shipping = new ShippingInfo(shippingName, shippingAddress, shippingCity, shippingZipCode); //set default values order.OrderDate = DateTime.UtcNow; order.DeliveryDate = null; order.ShippingInformation = shipping; order.CustomerId = customerId; return order; }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId, ShippingInfo shippingInfo) { //var availableShippingMethods = new List<IShippingResponse>(); //JMABase.WriteLogFile("SH Count: " + Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Count().ToString(), "/importErrorLog.txt"); //foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) //{ // var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); // JMABase.WriteLogFile("Carrier Name: " + shippingCarrier.Name, "/importErrorLog.txt"); // IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); // JMABase.WriteLogFile("Shipping Country: " + shippingInfo.ShippingToCountry, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping zip: " + shippingInfo.ShippingToZip, "/importErrorLog.txt"); // JMABase.WriteLogFile("Cart weight: " + shippingInfo.TotalCartWeight, "/importErrorLog.txt"); // //genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); // genericShippingRequest.CartOrder = ordersManager.GetCartOrder(shoppingCartId); // ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); // JMABase.WriteLogFile("Cart details: " + genericShippingRequest.CartOrder.Details.Count(), "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping context error: " + shippingContext.ErrorMessage, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping responses: " + shippingContext.ShippingResponses.Count(), "/importErrorLog.txt"); // if (shippingContext.ShippingResponses != null) // { // availableShippingMethods.AddRange(shippingContext.ShippingResponses); // } //} // return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); List<ShippingMethod> methodsList = new List<ShippingMethod>(); var order = CartHelper.GetCartOrder(ordersManager, shoppingCartId); foreach (var a in shippingManager.GetShippingMethods().OrderBy(a => a.SortOrder)) { string[] sht = a.ShippingLimitToDisplay.Replace("total price:", "").Trim().Split('-'); decimal hLimit = 0; decimal.TryParse(sht[1], out hLimit); decimal lLimit = 0; decimal.TryParse(sht[0], out lLimit); if (hLimit <= order.Total && order.Total >= lLimit) { methodsList.Add(a); } } return methodsList; }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId,ShippingInfo shippingInfo) { var availableShippingMethods = new List<IShippingResponse>(); foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) { var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); if (shippingContext.ShippingResponses != null) { availableShippingMethods.AddRange(shippingContext.ShippingResponses); } } return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); }
public Order(OrderInfo orderInfo) { Name = orderInfo.Name; TermsAccepted = orderInfo.TermsAccepted; PaidDate = orderInfo.PaidDate; FulfillDate = orderInfo.FulfillDate; ConfirmDate = orderInfo.ConfirmDate; OrderLines = orderInfo.OrderLines.Select(line => new OrderLine(line)).ToList(); CouponCodes = orderInfo.CouponCodesData; CustomerInfo = orderInfo.CustomerInfo; ShippingInfo = orderInfo.ShippingInfo; PaymentInfo = orderInfo.PaymentInfo; StoreInfo = orderInfo.StoreInfo; CurrencyCode = orderInfo.Localization.CurrencyCode; // todo: onderstaand kan waarschijnlijk anders (geen check = dubbel) Discounts = orderInfo.Discounts.Select(discount => new OrderDiscount(orderInfo.Localization, discount, orderInfo)).ToList(); // todo: add/save used coupon code IncludingVAT = orderInfo.PricesAreIncludingVAT; VatCalculatedOverParts = orderInfo.VatCalculationStrategy is OverSmallestPartsVatCalculationStrategy; PaymentProviderPrice = orderInfo.PaymentProviderAmount; PaymentProviderOrderPercentage = orderInfo.PaymentProviderOrderPercentage; ShippingProviderPrice = orderInfo.ShippingProviderAmountInCents; RegionalVatAmount = orderInfo.RegionalVatInCents; VATCharged = orderInfo.VATCharged; ChargedAmount = orderInfo.ChargedAmountInCents; CorrespondingOrderDocumentId = orderInfo.OrderNodeId; RevalidateOrderOnLoad = orderInfo.RevalidateOrderOnLoad; // version 2.1 hack ReValidateSaveAction = orderInfo.ReValidateSaveAction; // version 2.1 hack StockUpdated = orderInfo.StockUpdated; CreatedInTestMode = orderInfo.CreatedInTestMode; }
/// <summary> /// To the shipping information. /// </summary> /// <param name="item">The item.</param> /// <returns>A CommerceShippingInfo.</returns> public static ShippingInfo ToShippingInfo(this ShippingMethodInputModelItem item) { var shippingInfo = new ShippingInfo { PartyID = item.PartyID, ShippingMethodID = item.ShippingMethodID, LineIDs = item.LineIDs != null ? item.LineIDs.AsReadOnly() : new List<string>().AsReadOnly() }; return shippingInfo; }
public decimal CalculateShipping() { ShippingInfo shippingInfo = new ShippingInfo(); return shippingInfo.CalculateShippingAmount(State.Alaska); }
/// <summary> /// Translates the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="sourceShipment">The source shipment.</param> /// <param name="destinationShippingInfo">The destination shipping information.</param> protected override void Translate(TranslateShipmentToEntityRequest request, Shipment sourceShipment, ShippingInfo destinationShippingInfo) { base.Translate(request, sourceShipment, destinationShippingInfo); destinationShippingInfo.Properties.Add("ShippingMethodName", sourceShipment.ShippingMethodName); }
public static List<ShippingInfo> GetShippingInfo( int shippingRegionId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "CommerceLibShippingGetInfo"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@ShippingRegionId"; param.Value = shippingRegionId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // obtain the results DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); List<ShippingInfo> result = new List<ShippingInfo>(); foreach (DataRow row in table.Rows) { ShippingInfo rowData = new ShippingInfo(); rowData.ShippingID = int.Parse(row["ShippingId"].ToString()); rowData.ShippingType = row["ShippingType"].ToString(); rowData.ShippingCost = double.Parse(row["ShippingCost"].ToString()); rowData.ShippingRegionId = shippingRegionId; result.Add(rowData); } return result; }
public void OrderFactoryCreateValidOrder() { //Arrange string shippingName = "shippingName"; string shippingCity = "shippingCity"; string shippingZipCode = "shippingZipCode"; string shippingAddress = "shippingAddress"; Customer customer = new Customer(); customer.Id = IdentityGenerator.NewSequentialGuid(); //Act Order order = OrderFactory.CreateOrder(customer, shippingName, shippingCity, shippingAddress, shippingZipCode); var validationContext = new ValidationContext(order, null, null); var validationResult = order.Validate(validationContext); //Assert ShippingInfo shippingInfo = new ShippingInfo(shippingName, shippingAddress, shippingCity, shippingZipCode); Assert.AreEqual(shippingInfo, order.ShippingInformation); Assert.AreEqual(order.Customer, customer); Assert.AreEqual(order.CustomerId, customer.Id); Assert.IsFalse(order.IsDelivered); Assert.IsNull(order.DeliveryDate); Assert.IsTrue(order.OrderDate != default(DateTime)); Assert.IsFalse(validationResult.Any()); }
public Product GetProductInfo(string ProductName) { Product p = new Product(); ShippingInfo s = new ShippingInfo(); p.ProductName = ProductName; s.Distributor = "Buggy Bits"; s.DaysToShip = 5; p.shippingInfo = s; Type[] extraTypes = new Type[1]; extraTypes[0] = typeof(ShippingInfo); MemoryStream ms = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(Product), extraTypes); xs.Serialize(ms, p); //Here we would save the data off to some xml file or similar but i'm skipping this part ms.Close(); return p; }
public CommerceLibOrderInfo(DataRow orderRow) { Shipping = new ShippingInfo(); Tax = new TaxInfo(); OrderID = Int32.Parse(orderRow["OrderID"].ToString()); DateCreated = orderRow["DateCreated"].ToString(); DateShipped = orderRow["DateShipped"].ToString(); Comments = orderRow["Comments"].ToString(); Status = Int32.Parse(orderRow["Status"].ToString()); AuthCode = orderRow["AuthCode"].ToString(); Reference = orderRow["Reference"].ToString(); Customer = Membership.GetUser( new Guid(orderRow["CustomerID"].ToString())); CustomerProfile = (HttpContext.Current.Profile as ProfileCommon) .GetProfile(Customer.UserName); CreditCard = new SecureCard(CustomerProfile.CreditCard); OrderDetails = CommerceLibAccess.GetOrderDetails( orderRow["OrderID"].ToString()); // Get Shipping Data if (orderRow["ShippingID"] != DBNull.Value && orderRow["ShippingType"] != DBNull.Value && orderRow["ShippingCost"] != DBNull.Value) { Shipping.ShippingID = Int32.Parse(orderRow["ShippingID"].ToString()); Shipping.ShippingType = orderRow["ShippingType"].ToString(); Shipping.ShippingCost = double.Parse(orderRow["ShippingCost"].ToString()); } else { Shipping.ShippingID = -1; } // Get Tax Data if (orderRow["TaxID"] != DBNull.Value && orderRow["TaxType"] != DBNull.Value && orderRow["TaxPercentage"] != DBNull.Value) { Tax.TaxID = Int32.Parse(orderRow["TaxID"].ToString()); Tax.TaxType = orderRow["TaxType"].ToString(); Tax.TaxPercentage = double.Parse(orderRow["TaxPercentage"].ToString()); } else { Tax.TaxID = -1; } // set info properties Refresh(); }