예제 #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
                });
            }
        }