private IdNameDTO TODTO(PostTypeEntity entity)
        {
            IdNameDTO dto = new IdNameDTO();

            dto.CreateTime  = entity.CreateTime;
            dto.Description = entity.Description;
            dto.Id          = entity.Id;
            dto.Name        = entity.Name;
            return(dto);
        }
        public async Task <long> AddNewAsync(AddIdNameDTO dto)
        {
            PostTypeEntity entity = new PostTypeEntity();

            entity.Description = dto.Description;
            entity.Name        = dto.Name;
            using (PostContext ctx = new PostContext())
            {
                BaseService <PostTypeEntity> bs = new BaseService <PostTypeEntity>(ctx);
                var status = await bs.GetAll().SingleOrDefaultAsync(e => e.Name == dto.Name);

                if (status != null)
                {
                    throw new Exception("帖子类型已存在");
                }
                await ctx.PostTypes.AddAsync(entity);

                await ctx.SaveChangesAsync();

                return(entity.Id);
            }
        }