示例#1
0
        public async Task <ActionResult <Post> > PostPost(Post post)
        {
            var lastPost = await _context.Post.OrderByDescending(postToDes => postToDes.Id).FirstOrDefaultAsync();

            var lastPostNumber = Base62Converter.BaseToLong(lastPost.UniqueUrl);

            post.UniqueUrl = Base62Converter.LongToBase(lastPostNumber + 1);
            _context.Post.Add(post);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPost", new { id = post.Id }, post));
        }