protected virtual void HandleException(ExceptionContext exceptionContext) { var dataSourceException = exceptionContext.Exception as InvalidDataSourceItemException; if (dataSourceException != null) { Log.Error(dataSourceException.Message, dataSourceException, this); if (Context.PageMode.IsNormal) { exceptionContext.Result = new EmptyResult(); } else { var viewData = new ViewDataDictionary() { Model = InfoMessage.Error(AlertTexts.InvalidDataSource) }; exceptionContext.Result = new ViewResult() { ViewName = ViewPath.InfoMessage, ViewData = viewData }; } exceptionContext.ExceptionHandled = true; } }
public ActionResult VisitedCategoryPage() { if (CatalogManager.CatalogContext == null || StorefrontContext.Current == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var lastCategoryId = GetLastVisitedCategory(CommerceUserContext.Current.UserId); var currentCategory = GetCurrentCategory(); if (currentCategory == null) { return(new EmptyResult()); } if (!string.IsNullOrWhiteSpace(lastCategoryId) && lastCategoryId.Equals(currentCategory.Name)) { return(new EmptyResult()); } CatalogManager.VisitedCategoryPage(currentCategory.Name, currentCategory.Title); SetLastVisitedCategory(CommerceUserContext.Current.UserId, currentCategory.Name); return(new EmptyResult()); }
public ActionResult ProductFacets( [Bind(Prefix = Constants.QueryString.Paging)] int?pageNumber, [Bind(Prefix = Constants.QueryString.PageSize)] int?pageSize, [Bind(Prefix = Constants.QueryString.Facets)] string facetValues, [Bind(Prefix = Constants.QueryString.Sort)] string sortField, [Bind(Prefix = Constants.QueryString.SortDirection)] SortDirection?sortDirection) { if (CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var currentCategory = GetCurrentCategory(); if (currentCategory == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } var searchOptions = GetCategorySearchOptions(currentCategory, pageNumber, facetValues, pageSize, sortField, sortDirection); var viewModel = GetProductFacetsViewModel(searchOptions, currentCategory, RenderingContext.Current.Rendering); return(View(viewModel)); }
public ActionResult Navigation() { if (CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var item = RenderingContext.Current.Rendering.Item; var dataSource = item.IsDerived(Foundation.Commerce.Templates.Commerce.NavigationItem.Id) ? item?.TargetItem(Foundation.Commerce.Templates.Commerce.NavigationItem.Fields.CategoryDatasource) : null; if (dataSource == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } var currentCategory = CatalogManager.GetCategory(dataSource); if (currentCategory == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } var viewModel = GetNavigationViewModel(currentCategory); return(View(viewModel)); }
public static MvcHtmlString PageEditorError(this HtmlHelper helper, string errorMessage) { Log.Error($@"Presentation error on '{helper.Sitecore()?.CurrentRendering?.RenderingItemPath}': {errorMessage}", typeof(AlertHtmlHelpers)); return(Context.PageMode.IsNormal ? new MvcHtmlString(string.Empty) : helper.Partial(Constants.InfoMessageView, InfoMessage.Error(errorMessage))); }
public ActionResult CheckGiftCardBalance() { if (CatalogManager.CatalogContext == null || StorefrontContext.Current == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } return(View()); }
public static MvcHtmlString PageEditorError(this HtmlHelper helper, string errorMessage, string friendlyMessage, ID contextItemId, ID renderingId) { Log.Error($@"Presentation error: {errorMessage}, Context item ID: {contextItemId}, Rendering ID: {renderingId}", typeof(AlertHtmlHelpers)); if (Context.PageMode.IsNormal) { return(new MvcHtmlString(string.Empty)); } return(helper.Partial(ViewPath.InfoMessage, InfoMessage.Error(friendlyMessage))); }
public static MvcHtmlString PageEditorError(this HtmlHelper helper, string errorMessage) { Log.Error($@"Presentation error: {errorMessage}", typeof(AlertHtmlHelpers)); if (Context.PageMode.IsNormal) { return(new MvcHtmlString(string.Empty)); } return(helper.Partial(ViewPath.InfoMessage, InfoMessage.Error(errorMessage))); }
public ActionResult ForgotPassword() { try { _accountsSettingsService.GetForgotPasswordMailTemplate(); } catch (Exception) { return(this.InfoMessage(InfoMessage.Error(ForgotPasswordEmailNotConfigured))); } return(View()); }
public ActionResult RelatedCatalogItems() { if (CatalogManager.CatalogContext == null || StorefrontContext.Current == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var isCatalogItem = RenderingContext.Current.Rendering.Item.IsDerived(Foundation.Commerce.Templates.Commerce.CatalogItem.Id); var catalogItem = isCatalogItem ? RenderingContext.Current.Rendering.Item : CatalogItemContext.Current?.Item; var relatedCatalogItemsModel = GetRelationshipsFromItem(catalogItem, RenderingContext.Current.Rendering); return(View(relatedCatalogItemsModel)); }
public ActionResult RelatedProducts([Bind(Prefix = Constants.QueryString.Sort)] string sortField) { if (StorefrontContext.Current == null || CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var viewModel = GetProductSearchViewModel(RenderingContext.Current.Rendering.Item, sortField); if (viewModel == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } return(View(viewModel)); }
public ActionResult EditProfile() { if (!Context.PageMode.IsNormal) { return(this.View(this.userProfileService.GetEmptyProfile())); } if (this.userProfileService.GetUserDefaultProfileId() != Context.User.Profile.ProfileItemId) { return(this.InfoMessage(InfoMessage.Error(Errors.ProfileMismatch))); } var profile = this.userProfileService.GetProfile(Context.User.Profile); return(this.View(profile)); }
public ActionResult Print(Guid brochure) { var brochureItem = Context.Database.GetItem(new ID(brochure)); var items = GetBrochureItemIDs(); if (brochureItem == null || items == null) { return(this.InfoMessage(InfoMessage.Error(DictionaryPhraseRepository.Current.Get("/Brochure/Print/No Brochure Specified", "No brochure was specified.")))); } var generatedBrochure = new GenerateBrochureService().GenerateBrochure(brochureItem, items); if (generatedBrochure == null) { return(this.InfoMessage(InfoMessage.Error(DictionaryPhraseRepository.Current.Get("/Brochure/Print/File Generation Failed", "The personalised file could not be generated. Please try again.")))); } return(File(generatedBrochure.Content, generatedBrochure.MimeType, generatedBrochure.Filename)); }
public ActionResult CategoryPageHeader() { if (CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var currentCategory = GetCurrentCategory(); if (currentCategory == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } var model = CategoryViewModelFactory.Create(currentCategory); return(View(model)); }
public ActionResult ChildCategoryNavigation() { if (CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } Assert.IsNotNull(CatalogItemContext.Current, "The Current Catalog Item must be set"); Assert.IsTrue(CatalogItemContext.IsCategory, "Current item must be a Category."); var category = CatalogManager.GetCategory(CatalogItemContext.Current.Item); var viewModel = GetNavigationViewModel(category); if (viewModel.ChildCategories.Count == 0) { category = CatalogManager.GetCategory(CatalogItemContext.Current.Item.Parent); viewModel = GetNavigationViewModel(category); } return(View(viewModel)); }
public virtual ActionResult EditProfile(EditProfile profile) { if (this.userProfileService.GetUserDefaultProfileId() != Context.User.Profile.ProfileItemId) { return(this.InfoMessage(InfoMessage.Error(Errors.ProfileMismatch))); } if (!this.userProfileService.ValidateProfile(profile, this.ModelState)) { profile.InterestTypes = this.userProfileService.GetInterests(); return(this.View(profile)); } this.userProfileService.SetProfile(Context.User.Profile, profile); if (this.contactProfileService != null) { this.contactProfileService.SetProfile(profile); } Session["EditProfileMessage"] = new InfoMessage(Captions.EditProfileSuccess); return(this.Redirect(Request.RawUrl)); }
public ActionResult VisitedProductDetailsPage() { if (CatalogManager.CatalogContext == null || StorefrontContext.Current == null) { return(Context.PageMode.IsExperienceEditor ? (ActionResult)this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context.")) : new EmptyResult()); } if (!ProductViewModelFactory.IsValid(RenderingContext.Current.Rendering.Item)) { return(Context.PageMode.IsExperienceEditor ? (ActionResult)this.InfoMessage(InfoMessage.Error("Invalid datasource. Please pick a product.")) : new EmptyResult()); } var model = ProductViewModelFactory.Create(RenderingContext.Current.Rendering.Item); if (model != null) { CatalogManager.VisitedProductDetailsPage(model.ProductId, model.ProductName, model.ParentCategoryId, model.ParentCategoryName); } return(new EmptyResult()); }
public ActionResult ProductRating() { if (CatalogManager.CatalogContext == null) { return(Context.PageMode.IsExperienceEditor ? (ActionResult)this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context.")) : new EmptyResult()); } if (!ProductViewModelFactory.IsValid(RenderingContext.Current.Rendering.Item)) { return(Context.PageMode.IsExperienceEditor ? (ActionResult)this.InfoMessage(InfoMessage.Error("Invalid datasource. Please pick a product.")) : new EmptyResult()); } var model = ProductViewModelFactory.Create(RenderingContext.Current.Rendering.Item); return(View(model)); }