public IActionResult Edit(Computer computer, IFormFile file) { try { if (ModelState.IsValid) { if (file.Length > 0) { var path = Path.Combine("wwwroot/images", file.FileName); var stream = new FileStream(path, FileMode.Create); file.CopyToAsync(stream); computer.Photo = "images/" + file.FileName; _service.Edit(computer); return(RedirectToAction("Index")); } else { ViewBag.Msg = "Fail..."; } } } catch (Exception ex) { ViewBag.Msg = ex.Message; } return(View()); }