Я создаю пакеты в своем приложении, и пакет определяется следующим образом я пытаюсь написать запрос, чтобы найти "неполные" пакеты, ниже я нахожусь, но он дает мне второй в пакете каждый раз, поскольку я использую <3 </p>
Как я могу это изменить, чтобы что он дает мне последний «неполный» элемент пакета, то есть ItemInBasket, где есть менее 3 записей с одинаковыми идентификатором пакета и отделом, поэтому я могу добавить новый элемент в тот же набор
var itemInBasket = basketToUpdate.ItemsInBasket.OrderByDescending(c => c.ThisItemsCountWithinBundle)
.Where(s => !string.IsNullOrEmpty(s.BundleId))
.Where(i => i.ThisItemsCountWithinBundle < 3)
.Where(s => s.Item.Department == itemToAdd.Item.Department)
.FirstOrDefault();
модель класса выглядит так
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace slapi.Models
{
class BasketModel
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
public string UserId { get; set; }
public string Brand { get; set; }
public int BasketLevel { get; set; }
//Start New Basket props
public int MaxBasketLevel { get; set; } = 6;
public Nullable<decimal> BasketLevelProgress { get; set; }
public decimal BasketLevelDiscount { get; set; }
public decimal WhitePriceStoreSummary { get; set; }
public Nullable<decimal> RedPriceStoreSummary { get; set; }
public Nullable<decimal> CheckoutDiscount { get; set; }
public Nullable<decimal> CheckoutDiscountPercent { get; set; }
public string Currency { get; set; } = "SEK";
public List<XForYStatusInformation> XForYInformations { get; set; }
//End New Basket props
public string ConsumerName { get; set; }
public string StoreId { get; set; }
public bool IsRedeemed { get; set; } = false;
public bool IsDeleted { get; set; } = false;
public List<ItemInBasket> ItemsInBasket { get; set; }
public string CreatedDate { get; set; }
public string CreatedDateUtc { get; set; }
public string CreatedBy { get; set; }
public string UpdatedDate { get; set; }
public string UpdatedDateUtc { get; set; }
public string UpdatedBy { get; set; }
public Nullable<int> CountHistory { get; set; } = 0;
}
class ItemInBasket
{
public StorelensItemModel_V2 Item { get; set; }
public Nullable<int> ItemRowPosition { get; set; }
public bool UsedForWeightCalculation { get; set; }
public bool IsPaused { get; set; }
public string BundleId { get; set; }
public int ThisItemsCountWithinBundle { get; set; } = 0;
public int BundleNeededQty { get; set; } = 3;
}
class XForYStatusInformation
{
public string Sticker { get; set; }
public string Text { get; set; }
public string BundleId { get; set; }
public string Department { get; set; }
}
}