public IActionResult New(NewViewModel viewModel, string submitButton)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", viewModel));
            }

            var post = new BlogPost
            {
                Title        = viewModel.NewPost.Title,
                Body         = viewModel.NewPost.Body,
                LastModified = DateTimeOffset.Now,
                IsDeleted    = false,
            };

            if (submitButton == "Publish")
            {
                post.PubDate  = DateTimeOffset.Now;
                post.IsPublic = true;
            }

            if (Request != null)
            {
                _dataStore.SaveFiles(Request.Form.Files.ToList());
            }

            _dataStore.SavePost(post);

            if (submitButton == "Save Draft")
            {
                return(RedirectToAction("Drafts", "Admin"));
            }
            ;

            return(RedirectToAction("Blog", "Home"));
        }
        public void SaveFiles_CreatesFilesInUploadsFolder()
        {
            FakeFormFile file1 = new FakeFormFile();

            file1.FileName = "file1";
            file1.Length   = 5;
            FakeFormFile file2 = new FakeFormFile();

            file2.FileName = "file2";
            file2.Length   = 5;
            List <IFormFile> files = new List <IFormFile>();

            files.Add(file1);
            files.Add(file2);
            IFileSystem   testFileSystem = new FakeFileSystem();
            BlogDataStore testDataStore  = new BlogDataStore(testFileSystem);

            testDataStore.SaveFiles(files);

            Assert.True(testFileSystem.FileExists("wwwroot\\Uploads\\file1"));
            Assert.True(testFileSystem.FileExists("wwwroot\\Uploads\\file2"));
        }