/// <summary> /// Gets a list of orders of a status. Some order details /// </summary> /// <param name="status">Status to search for</param> /// <returns>Model - list of orders, also status</returns> public OrdersModel GetOrders(string status) { var result = _apiService.GetRequest($"orders?direction=in&status={status.ToUpper()}"); var responseModel = JsonConvert.DeserializeObject <GetOrdersResponseModel>(result); var model = new OrdersModel(responseModel, status); foreach (var order in model.Orders) { var orderEntity = _dataService.GetOrder(order.OrderId) as Data.Entities.BricklinkOrder; if (orderEntity != null) { order.RealName = orderEntity.BuyerRealName; order.OrderIsLoaded = orderEntity.OrderItems.Any(); order.Id = orderEntity.Id; order.Weight = PostageHelper.FormatWeight(orderEntity.Weight); order.PackageSize = PostageHelper.GetPackageSize(orderEntity.ShippingMethod); order.ShippingMethod = PostageHelper.GetServiceCode(orderEntity.ShippingMethod); order.InternationalOrder = PostageHelper.IsInternational(orderEntity.ShippingMethod); } else { order.Id = _dataService.AddInitialOrder(order); } } return(model); }
public OrderCsvModel(GetOrderResponseModel model) { var data = model.data; if (data.shipping == null) { Name = "ERROR: Shipping was null!"; return; } if (data.shipping.address == null) { Name = "ERROR: Shipping address was null!"; return; } Name = data.shipping.address.name.full.HtmlDecode(); Address1 = data.shipping.address.address1.HtmlDecode(); Address2 = data.shipping.address.address2.HtmlDecode(); AddressCity = data.shipping.address.city.HtmlDecode(); AddressPostcode = data.shipping.address.postal_code.HtmlDecode(); AddressCounty = data.shipping.address.state.HtmlDecode(); AddressCountry = data.shipping.address.country_code; OrderReference = data.order_id.ToString(); OrderValue = StaticFunctions.FormatCurrency(data.cost?.grand_total ?? "0").ToString(); ShippingCost = StaticFunctions.FormatCurrency(data.cost?.shipping ?? "0").ToString(); Weight = PostageHelper.FormatWeight(data.total_weight); ServiceCode = PostageHelper.GetServiceCode(data.shipping.method); PackageSize = PostageHelper.GetPackageSize(data.shipping.method); ProductName = "Mixed Lego (No Batteries)"; UnitPrice = StaticFunctions.FormatCurrency(data.cost?.subtotal ?? "0").ToString(); Quantity = "1"; UnitWeight = Weight; //EmailAddress = data.buyer_email; //EmailNotification = !string.IsNullOrEmpty(data.buyer_email); CountryOfOrigin = "Denmark"; }