private void PrepareBreadcrumbs(LocationModel parentLocation = null, bool isSearch = false) { AddBreadcrumb("Locations", "list", "location", new { area = "admin" }); if (isSearch) { AddBreadcrumb("Search Results", null); } else { var currentLocation = parentLocation; while (currentLocation != null) { AddBreadcrumb(currentLocation.Name, Url.Action("list", new {area = "admin", id = currentLocation.Id}), 1); currentLocation = currentLocation.ParentLocation; } } }
public static LocationModel ToModel(this Location entity) { if (entity == null) return null; var model = new LocationModel { Active = entity.Active, CreatedDate = entity.CreatedDate, Deleted = entity.Deleted, LastModifiedBy = entity.LastModifiedBy, LastModifiedDate = entity.LastModifiedDate, HashTag = entity.HashTag, Id = entity.Id, Name = entity.Name, ParentLocation = entity.ParentLocation.ToModel(), SeoName = entity.GetSeoName() }; return model; }
public ActionResult Edit(LocationModel model) { if (!_permissionService.Authorize(PermissionProvider.ManageLocations)) return AccessDeniedView(); // get the location var location = _locationService.GetLocationById(model.Id); // check we have a location and they are not deleted if (location == null || location.Deleted) return RedirectToAction("list"); location.LastModifiedBy = _workContext.CurrentUser.Id; if (ModelState.IsValid) { try { location.HashTag = model.HashTag; _locationService.UpdateLocation(location); SuccessNotification("The location details have been updated successfully."); return RedirectToAction("Edit", location.Id); } catch (Exception) { ErrorNotification("An error occurred saving the user details, please try again."); } } PrepareBreadcrumbs(model.ParentLocation); AddBreadcrumb("Edit Location", null); return View(model); }