Beispiel #1
0
 public async override Task <CreateBlogReply> CreateBlog(CreateBlogRequest request, ServerCallContext context)
 {
     InitBlogs();
     if (!string.IsNullOrWhiteSpace(request.Code) && !blogs.Any(b => b.Code.Equals(request.Code)))
     {
         blogs.Add(new BlogModel
         {
             Code       = request.Code,
             Name       = request.Name,
             Title      = request.Title,
             Descript   = request.Descript,
             NumberWord = request.NumberWord,
             Id         = Guid.NewGuid().ToString()
         });
         redisManager.SetString(nameof(BlogService), JsonConvert.SerializeObject(blogs));
         return(new CreateBlogReply
         {
             Success = true,
             RequestValues = JsonConvert.SerializeObject(request)
         });
     }
     return(new CreateBlogReply
     {
         Success = false,
         RequestValues = "已存在相同的博客或者请求blog code is empty"
     });
 }