private static IFieldable GetCategoryField(CategoryProductDisplayOrder order) { var numericField = new NumericField(GetCategoryFieldName(order.Category.Id), Field.Store.YES, true); numericField.SetIntValue(order.DisplayOrder); return(numericField); }
public void Update(Category category, List <ProductSortData> productSortData) { var categoryProductDisplayOrders = _session.QueryOver <CategoryProductDisplayOrder>() .Where(order => order.Category.Id == category.Id) .Cacheable() .List(); using (new NotificationDisabler()) { _session.Transact(session => { foreach (var sortData in productSortData) { var displayOrder = categoryProductDisplayOrders.FirstOrDefault(order => order.Product.Id == sortData.Id); if (displayOrder != null) { displayOrder.DisplayOrder = sortData.DisplayOrder; session.Update(displayOrder); continue; } displayOrder = new CategoryProductDisplayOrder { Category = category, Product = session.Get <Product>(sortData.Id), DisplayOrder = sortData.DisplayOrder }; session.Save(displayOrder); } }); } }