Ejemplo n.º 1
0
        public IActionResult ArtAdd(Article Article)
        {
            Request.Cookies.TryGetValue("lang", out string info);
            var user = JsonConvert.DeserializeObject <User>(info);

            Article.UserId = user.Id;
            if (Article.Id == 0)
            {
                Article.CreateTime = DateTime.Now;
            }
            bool b = _articleRepository.AddArt(Article);

            if (b)
            {
                return(Ok(new
                {
                    code = 1,
                    msg = "添加成功"
                }));
            }
            return(Ok(new
            {
                code = 0,
                msg = "添加失败"
            }));
        }