public async Task <IActionResult> MekanGuncelle(int id, Mekan mekan) { ModelState.Clear(); mekan.user = await _userManager.GetUserAsync(HttpContext.User); TryValidateModel(mekan); if (ModelState.IsValid) { var files = HttpContext.Request.Form.Files; foreach (var Image in files) { if (Image != null && Image.Length > 0) { var file = Image; var uploads = Path.Combine(_appEnvironment.WebRootPath, "img\\mekan"); if (file.Length > 0) { var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName); using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create)) { await file.CopyToAsync(fileStream); mekan.mekanResim = fileName; } } } } _depo.MekanGuncelle(id, mekan); return(RedirectToAction("BenimMekanlar", "Mekan")); } else { return(View()); } }