Esempio n. 1
0
        public OperationResult AddSectionConfig(SectionConfigDto dto)
        {
            var article = ArticleConfig.FindById(dto.ArticleId);

            if (article != null)
            {
                var section = Mapper.Map <SectionConfigDto, SectionConfig>(dto);
                section.ArticleId = article.Id;
                SectionConfig.Insert(section);
                return(UnitOfWork.Commit() > 0
                    ? new OperationResult(StatusCode.Okey)
                    : new OperationResult(StatusCode.Failed));
            }
            return(new OperationResult(StatusCode.NotFound, "失败了耶~刷新一下页面看看,会有惊喜哦"));
        }
Esempio n. 2
0
        public OperationResult UpdateSectionConfig(SectionConfigDto dto)
        {
            var section = SectionConfig.FindById(dto.Id);

            if (section == null)
            {
                return(new OperationResult(StatusCode.NotFound));
            }
            else
            {
                section.Name         = dto.Name;
                section.Index        = dto.Index;
                section.IsRepeatable = dto.IsRepeatable;
                SectionConfig.Update(section);
                return(UnitOfWork.Commit() > 0
                           ? new OperationResult(StatusCode.Okey)
                           : new OperationResult(StatusCode.Error, "没有做过任何修改吧?"));
            }
        }