コード例 #1
0
        public async Task <ActionResult> CategoryManage(string id)
        {
            var categoryModel = await ContentManagerRepository.CategoryInfo(id);

            var UserId         = Util.Common.My.id;
            var UserCategories = await ContentManagerRepository.GetUserCategories(UserId);

            var ParentTitle = string.Empty;

            if (string.IsNullOrWhiteSpace(categoryModel.userid))
            {
                categoryModel.userid = Util.Common.My.id;
            }

            if (!string.IsNullOrEmpty(categoryModel.parentId) && categoryModel.parentId != "-1")
            {
                ParentTitle = (await ContentManagerRepository.CategoryInfo(categoryModel.parentId)).title;
            }
            var model = new ViewModel.ContentManager.SimpleCategoryManageVM()
            {
                blocks        = categoryModel.blocks,
                parentId      = categoryModel.parentId,
                parenttitle   = ParentTitle,
                allblocks     = Util.Configuration.AllBlocks(),
                _id           = categoryModel._id,
                title         = categoryModel.title,
                allcategories = UserCategories,
                userId        = categoryModel.userid
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <ViewModel.ServiceResult> PostEditCategory([FromBody] ViewModel.ContentManager.SimpleCategoryManageVM model)
        {
            try
            {
                var res = await ContentManagerRepository.EditCategory(new Models.ContentManager.Category()
                {
                    _id      = model._id,
                    title    = model.title,
                    parentId = model.parentId,
                    userid   = model.userId,
                    blocks   = model.blocks
                });

                if (res)
                {
                    return new ViewModel.ServiceResult()
                           {
                               ServiceResultStatus  = (int)Rdio.Util.Common.ServiceResultStatus.OK,
                               ServiceResultMassage = Util.Common.ServiceResultMessage.OKMessage.ToString()
                           }
                }
                ;
                else
                {
                    return new ViewModel.ServiceResult()
                           {
                               ServiceResultStatus  = (int)Rdio.Util.Common.ServiceResultStatus.Error,
                               ServiceResultMassage = Util.Common.ServiceResultMessage.FaildMessage.ToString()
                           }
                };
            }
            catch (Exception ex)
            {
                return(new ViewModel.ServiceResult()
                {
                    ServiceResultStatus = (int)Rdio.Util.Common.ServiceResultStatus.Error,
                    ServiceResultMassage = ex.GetBaseException().Message
                });
            }
        }