public IActionResult Update(BranchDetailModel branch, IFormFile ImageUrl) { string message = ""; var data = _branch.GetById(branch.Id); data.Id = branch.Id; data.Name = branch.Name; data.Address = branch.Address; data.Telephone = branch.Telephone; data.Description = branch.Description; data.OpenDate = branch.OpenDate; if (ImageUrl != null) { branch.ImageURL = "/images/branch/" + ImageUrl.FileName; data.ImageUrl = branch.ImageURL; var fileName = Path.Combine(he.WebRootPath + "/images/branch", Path.GetFileName(ImageUrl.FileName)); ImageUrl.CopyTo(new FileStream(fileName, FileMode.Create)); } bool result = _branch.Update(data); if (result) { message += "Update succesfully!"; } else { message += "Fail to update"; } //return Content(message); return(RedirectToAction("ListBranch")); }