示例#1
0
        public async Task <ServiceResult> PostEditBlockRssBind([FromBody] ViewModel.ContentManager.CategoryRssBindEditVM model)
        {
            try
            {
                //Clean All Blocks Then Add BlockRssIdBind
                var res = await ContentManagerRepository.DeleteUserCategoriesBlocks();

                foreach (var CategoryGroup in model.BlockRssBind.GroupBy(q => q.CategoryId))
                {
                    foreach (var BlockCodeGroup in CategoryGroup.GroupBy(q => q.BlockCode))
                    {
                        var BlockModel = new Models.ContentManager.Block
                        {
                            code         = BlockCodeGroup.FirstOrDefault().BlockCode,
                            blockrssbind = (from b in BlockCodeGroup select b.RssId).ToList()
                        };
                        res = await ContentManagerRepository.EditCategoryBlocks(BlockCodeGroup.FirstOrDefault().CategoryId, BlockModel);
                    }
                }
                return(new ViewModel.ServiceResult()
                {
                    ServiceResultStatus = (int)Rdio.Util.Common.ServiceResultStatus.OK,
                    ServiceResultMassage = Util.Common.ServiceResultMessage.OKMessage.ToString()
                });
            }
            catch (Exception ex)
            {
                return(new ViewModel.ServiceResult()
                {
                    ServiceResultStatus = (int)Rdio.Util.Common.ServiceResultStatus.Error,
                    ServiceResultMassage = ex.GetBaseException().Message
                });
            }
        }
示例#2
0
        public void InitializePlaceholders()
        {
            List <Object> Temp = new List <Object>();

            IEnumerable <Object> SortedContents;

            switch (Rucksack.SortProperty)
            {
            case SortingProperty.Time:
                SortedContents = Rucksack.Contents;
                break;

            case SortingProperty.Name:
                SortedContents = Rucksack.Contents.OrderBy(x => x.DisplayName);
                break;

            case SortingProperty.Id:
                SortedContents = Rucksack.Contents.OrderBy(x => x.bigCraftable.Value).ThenBy(x => x.ParentSheetIndex);
                break;

            case SortingProperty.Category:
                //SortedContents = Rucksack.Contents.OrderBy(x => x.getCategorySortValue());
                SortedContents = Rucksack.Contents.OrderBy(x => x.getCategoryName());
                break;

            case SortingProperty.Quantity:
                SortedContents = Rucksack.Contents.OrderBy(x => x.Stack);
                break;

            case SortingProperty.SingleValue:
                SortedContents = Rucksack.Contents.OrderBy(x => ItemBag.GetSingleItemPrice(x));
                break;

            case SortingProperty.StackValue:
                SortedContents = Rucksack.Contents.OrderBy(x => ItemBag.GetSingleItemPrice(x) * x.Stack);
                break;

            case SortingProperty.Similarity:
                //Possible TODO: Maybe SortingProperty.Similarity shouldn't exist - maybe it should just be a "bool GroupBeforeSorting"
                //that only groups by ItemId (and maybe also sorts by Quality after). Then the grouping can be applied to any of the other sorting properties.
                //So it could just be a togglebutton to turn on/off like the Autofill Toggle

                SortedContents = Rucksack.Contents
                                 .OrderBy(Item => Item.getCategoryName()).GroupBy(Item => Item.getCategoryName()) // First sort and group by CategoryName
                                 .SelectMany(
                    CategoryGroup =>
                    CategoryGroup.GroupBy(Item => Item.ParentSheetIndex)             // Then Group by item Id
                    .SelectMany(IdGroup => IdGroup.OrderBy(y => y.Quality))          // Then sort by Quality
                    );
                break;

            default: throw new NotImplementedException(string.Format("Unexpected SortingProperty: {0}", Rucksack.SortProperty.ToString()));
            }
            if (Rucksack.SortOrder == SortingOrder.Descending)
            {
                SortedContents = SortedContents.Reverse();
            }

            //Possible TODO Add filtering?
            //For EX: if you only wanted to show Fish,
            //SortedContents = SortedContents.Where(x => x.Category == <WhateverTheIdIsForFishCategory>);

            TempVisualFeedback = new Dictionary <Object, DateTime>();
            foreach (Object Item in SortedContents)
            {
                bool WasRecentlyModified = Bag.RecentlyModified.TryGetValue(Item, out DateTime ModifiedTime);

                int NumSlots     = (Item.Stack - 1) / Rucksack.MaxStackSize + 1;
                int RemainingQty = Item.Stack;
                for (int i = 0; i < NumSlots; i++)
                {
                    Object Copy = ItemBag.CreateCopy(Item);
                    ItemBag.ForceSetQuantity(Copy, Math.Min(RemainingQty, Rucksack.MaxStackSize));
                    Temp.Add(Copy);
                    RemainingQty -= Copy.Stack;

                    if (WasRecentlyModified)
                    {
                        TempVisualFeedback.Add(Copy, ModifiedTime);
                    }
                }
            }

            this.PlaceholderItems = Temp.AsReadOnly();
        }
示例#3
0
        public void LinqQuery06()
        {
            var products = new LinqSamples().GetProductList();
            var result   = products.GroupBy(p => p.Category).Select(CategoryGroup => new { Category = CategoryGroup.Key, CatGroup = CategoryGroup.GroupBy(s => s.UnitsInStock).Select(StockGroup => new { CountStock = StockGroup.Key, CountStockGroup = StockGroup.GroupBy(cost => cost.UnitPrice).Select(CostGroup => new { Cost = CostGroup.Key, CostGroup }) }) });

            ObjectDumper.Write(result, 5);
            var result2 = from p in products
                          group p by p.Category into CategoryGroup
                          select new
            {
                Category      = CategoryGroup.Key,
                CategoryGroup =
                    from s in CategoryGroup
                    group s by s.UnitsInStock into CountStockGroup
                    select new
                {
                    CountStock      = CountStockGroup.Key,
                    CountStockGroup =
                        from c in CountStockGroup
                        group c by c.UnitPrice into CostGroup
                        select new { Cost = CostGroup.Key, CostGroup }
                }
            };

            ObjectDumper.Write(result2, 5);
        }