コード例 #1
0
        public IActionResult Create([FromForm] PathArtikelAddVM pathArtikelVM)
        {
            if (pathArtikelVM !=null && ModelState.IsValid)
            {
                //Directory.GetCurrentDirectory(),
                var filePath = Path.Combine("Uploads", pathArtikelVM.Path.FileName);

                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    pathArtikelVM.Path.CopyToAsync(stream);
                }

                PathArtikel pathArtikel = new PathArtikel() 
                {
                    Path = pathArtikelVM.Path.FileName,
                    Tanggal = DateTime.Now
                };

                _pathArtikelRepository.Add(pathArtikel);

                //Message = $"Upload document {UploadFile.FilePath} has been successfully!";

                return RedirectToAction(nameof(Index));
            }

            pathArtikelVM.Init(Repository);

            return View(pathArtikelVM);
        }
コード例 #2
0
        public IActionResult Create()
        {
            var viewModel = new PathArtikelAddVM();

            viewModel.Init(Repository);

            return View(viewModel);
        }