public EbayOrdersListModel GetUnfulfilledOrders() { var response = _service.GetRequest("/sell/fulfillment/v1/order" + "?limit=1000&filter=orderfulfillmentstatus:{NOT_STARTED | IN_PROGRESS}"); var obj = JsonConvert.DeserializeObject <GetOrdersResponseModel>(response); var items = obj.orders.Where(x => x.cancelStatus.cancelState == "NONE_REQUESTED" && x.orderPaymentStatus == "PAID").Select(data => { var mod = new EbayOrdersListItemModel(data); var entity = _dataService.AddOrder(data); mod.Items = mod.Items.Select(x => { var ent = entity.OrderItems.Cast <EbayOrderItem>().FirstOrDefault(y => y.LegacyItemId == x.LegacyItemId && y.LineItemId == x.LineItemId && y.LegacyVariationId == x.LegacyVariationId); if (ent == null) { return(x); } x.OrderItemId = ent.Id; if (!string.IsNullOrEmpty(ent.Image)) { x.Image = ent.Image; x.Character = ent.CharacterName; return(x); } var itemFromApi = GetItem(x.LegacyItemId, x.LegacyVariationId); x.Image = itemFromApi.Image; x.Character = itemFromApi.Character; return(x); }); entity = _dataService.AddOrder(data); return(mod); }).Where(x => x.OrderDate > DateTime.UtcNow.AddDays(-30)).OrderByDescending(x => x.OrderDate).ToList(); var model = new EbayOrdersListModel(items, 0, 1000); return(model); }
/// <summary> /// Gets a page of orders /// </summary> /// <param name="limit">How many to return per page</param> /// <param name="page">Page number</param> /// <returns></returns> public EbayOrdersListModel GetOrders(int limit, int page) { //$"?filter=orderfulfillmentstatus:{{{status}}}" + {FULFILLED|IN_PROGRESS} {NOT_STARTED|IN_PROGRESS} int offset = (page - 1) * 50; var response = _service.GetRequest("/sell/fulfillment/v1/order" + $"?limit={limit}" + $"&offset={offset}"); var obj = JsonConvert.DeserializeObject <GetOrdersResponseModel>(response); var items = obj.orders.Select(data => { var mod = new EbayOrdersListItemModel(data); var entity = _dataService.AddOrder(data); mod.Items = mod.Items.Select(x => { var ent = entity.OrderItems.Cast <EbayOrderItem>().FirstOrDefault(y => y.LegacyItemId == x.LegacyItemId && y.LineItemId == x.LineItemId && y.LegacyVariationId == x.LegacyVariationId); if (ent == null) { return(x); } x.OrderItemId = ent.Id; if (!string.IsNullOrEmpty(ent.Image)) { x.Image = ent.Image; x.Character = ent.CharacterName; } return(x); }); return(mod); }); var model = new EbayOrdersListModel(items, page, limit); return(model); }