public ActionResult EditBranch(EditBranchViewModel editedBranch) { if (ModelState.IsValid) { var originBranch = _context.branchRepository.GetBranchById(editedBranch.BranchIdentificator); originBranch = _mapper.Map <EditBranchViewModel, Branch>(editedBranch, originBranch); _context.branchRepository.UpdateBranch(originBranch); #region EntityLogs var logInfoUpdateBranch = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateBranch"]); _logger.AddBranchLog(originBranch, logInfoUpdateBranch); #endregion #region PersonalUserLogs var logInfoPersonalUpdateBranch = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["updateBranch"], "Nazwa: " + editedBranch.Name); _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalUpdateBranch); #endregion return(RedirectToAction("ConfirmationOfActionOnBranch", "Branches", new { branchIdentificator = originBranch.BranchIdentificator, typeOfAction = "Update" })); } return(View(editedBranch)); }
public IActionResult EditBranch(EditBranchViewModel model) { var branch = _branch.GetById(model.Id); if (ModelState.IsValid) { branch.Id = model.Id; branch.Name = model.Name; branch.Address = model.Address; branch.Telephone = model.Telephone; branch.Description = model.Description; branch.OpenDate = model.OpenDate; if (model.ImageUrl != null) { //if (model.ExistingImageName != null) //{ // var filepath = _hostingEnvironment.WebRootPath; // string name = model.ExistingImageName; // string filepaths = Path.Combine(filepath, name); // System.IO.File.Delete(filepaths); //} branch.ImageUrl = UploadFileMethod(model); _branch.Update(branch); return(RedirectToAction("Detail", new { id = model.Id })); } branch.ImageUrl = model.ExistingImageName; //call the update method _branch.Update(branch); return(RedirectToAction("Detail", new { id = model.Id })); } return(View()); }
public ActionResult EditBranch(string branchIdentificator) { var branch = _context.branchRepository.GetBranchById(branchIdentificator); EditBranchViewModel branchToUpdate = _mapper.Map <EditBranchViewModel>(branch); return(View(branchToUpdate)); }
public IActionResult EditBranch(int id) { var branch = _branch.GetById(id); var editbranchViewModel = new EditBranchViewModel { Id = branch.Id, Name = branch.Name, Address = branch.Address, Telephone = branch.Telephone, Description = branch.Description, OpenDate = branch.OpenDate, ExistingImageName = branch.ImageUrl }; return(View(editbranchViewModel)); }