コード例 #1
0
        public IActionResult Creat(CreatViewModel model)
        {
            string uniqueFileName = ProcessUploadedFile(model);

            if (ModelState.IsValid)
            {
                BogPost blogPost = new BogPost
                {
                    Name       = User.Identity.Name,
                    Category   = model.category,
                    WriteUp    = model.WriteUp,
                    Visible    = model.Visible,
                    Headline   = model.Title,
                    PhotoPaths = uniqueFileName,
                    PostTime   = DateTime.Now,
                };
                _blogPostRepository.Creat(blogPost);
                return(RedirectToAction("index", new { id = blogPost.Id }));
            }
            return(View());
        }