Пример #1
0
        public ActionResult <ReplyModel> Add([FromBody] CategoryParam msg)
        {
            ReplyModel replyModel = new ReplyModel();
            Expression <Func <Category, bool> > func = w => w.Title == msg.Title;
            CategoryDto category = CategoryDto.GetCategoryInfo(_categoryQuery, msg.Title);

            if (category == null)
            {
                Category.Add(_categoryRepository, msg.Title, msg.Description);
                bool result = ServiceProvider.GetService <IUnitOfWork>().Commit();
                if (result)
                {
                    replyModel.Status = "002";
                    replyModel.Msg    = "添加标题成功";
                }
                else
                {
                    replyModel.Msg = "添加标题失败";
                }
            }
            else
            {
                replyModel.Msg = "该分类已经存在";
            }
            return(replyModel);
        }