public string Resolve(IUrlable source, IUrlableViewModel destination, string destMember, ResolutionContext context) { var cmsUrlBuilder = _urlBuilderFactory.GetUrlBuilder(source); var url = cmsUrlBuilder.Generate(source); return(url); }
public string Resolve(MenuItem source, IMenuItemMapped destination, string destMember, ResolutionContext context) { switch (source.TargetType) { case MenuItemTargetType.CustomLink: return(source.Url); case MenuItemTargetType.Category: var category = _categoryDataService.Query.Include(x => x.Scheme).FirstOrDefault(x => x.Id == source.TargetId.Value); if (category is null) { return("item not found"); } var caturl = _cmsUrlBuilderFactory.GetUrlBuilder(category).GenerateFull(category); return(caturl); case MenuItemTargetType.Entity: var entity = _entityDataService.Query.Include(x => x.Scheme).FirstOrDefault(x => x.Id == source.TargetId.Value); if (entity is null) { return("item not found"); } return(_cmsUrlBuilderFactory.GetUrlBuilder(entity).GenerateFull(entity)); case MenuItemTargetType.UserProfile: var user = _userDataService.Query.FirstOrDefault(x => x.Id == source.TargetId.Value); if (user is null) { return("item not found"); } return(_cmsUrlBuilderFactory.GetUrlBuilder(user).GenerateFull(user)); case MenuItemTargetType.Page: var page = _pageDataService.Query.FirstOrDefault(x => x.Id == source.TargetId.Value); if (page is null) { return("item not found"); } var url = _cmsUrlBuilderFactory.GetUrlBuilder(page).GenerateFull(page); return(url); case MenuItemTargetType.Product: var product = _productDataService.Query.FirstOrDefault(x => x.Id == source.TargetId); if (product is null) { return("item not found"); } return(_cmsUrlBuilderFactory.GetUrlBuilder(product).GenerateFull(product)); case MenuItemTargetType.ProductCategory: var cat = _productCategoryDataService.Query.FirstOrDefault(x => x.Id == source.TargetId); if (cat is null) { return("item not found"); } return(_cmsUrlBuilderFactory.GetUrlBuilder(cat).GenerateFull(cat)); default: return(""); } }