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); }
public IActionResult Create() { var viewModel = new PathArtikelAddVM(); viewModel.Init(Repository); return View(viewModel); }