public async Task <IActionResult> Edit(int id, Edit_AboutUS_ViewModel aboutUs) { if (id != aboutUs.Id) { return(NotFound()); } if (ModelState.IsValid) { try { #region Image Checking Process if (aboutUs.Image != null) { if (aboutUs.Image.FileName != aboutUs.ImageLink) { Helpers.Methods.DeleteItem(aboutUs.ImageLink); } Helpers.Methods.CreateItem(aboutUs.Image); } #endregion _context.Update(CreateNewAboutUsObject(aboutUs)); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AboutUsExists(aboutUs.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aboutUs)); }
private AboutUs CreateNewAboutUsObject(Edit_AboutUS_ViewModel aboutUs) { return(new AboutUs() { Id = aboutUs.Id != default ? aboutUs.Id : default,