I don't know how to best describe my requirement, but here goes. I'm trying to render a view from the following controller/model in a nopCommerce application:
CustomerController.cs snippet:
[NonAction]
protected CustomerNavigationModel GetCustomerNavigationModel(Customer customer)
{
var model = new CustomerNavigationModel();
model.HideAvatar = !_customerSettings.AllowCustomersToUploadAvatars;
model.HideRewardPoints = !_rewardPointsSettings.Enabled;
model.HideForumSubscriptions = !_forumSettings.ForumsEnabled || !_forumSettings.AllowCustomersToManageSubscriptions;
model.HideReturnRequests = !_orderSettings.ReturnRequestsEnabled || _orderService.SearchReturnRequests(customer.Id, 0, null).Count == 0;
model.HideDownloadableProducts = _customerSettings.HideDownloadableProductsTab;
model.HideBackInStockSubscriptions = _customerSettings.HideBackInStockSubscriptionsTab;
return model;
}
CustomerNavigationModel.cs:
public partial class CustomerNavigationModel : BaseNopModel
{
public bool HideInfo { get; set; }
public bool HideAddresses { get; set; }
public bool HideOrders { get; set; }
public bool HideBackInStockSubscriptions { get; set; }
public bool HideReturnRequests { get; set; }
public bool HideDownloadableProducts { get; set; }
public bool HideRewardPoints { get; set; }
public bool HideChangePassword { get; set; }
public bool HideAvatar { get; set; }
public bool HideForumSubscriptions { get; set; }
public CustomerNavigationEnum SelectedTab { get; set; }
}
public enum CustomerNavigationEnum
{
Info,
Addresses,
Orders,
BackInStockSubscriptions,
ReturnRequests,
DownloadableProducts,
RewardPoints,
ChangePassword,
Avatar,
ForumSubscriptions
}
MyAccountNavigation.cshtml snippet:
@model CustomerNavigationModel
@using Nop.Web.Models.Customer;
@if (!Model.HideInfo)
{
<li><a href="@Url.RouteUrl("CustomerInfo")" class="@if (Model.SelectedTab == CustomerNavigationEnum.Info)
{<text>active</text>}
else
{<text>inactive</text>}">@T("Account.CustomerInfo")</a></li>}
Views:
@Html.Partial("MyAccountNavigation", Model.NavigationModel, new ViewDataDictionary())
I am aware that it is unable to render MyAccountNavigation because it doesn't exist in the controller. However, depending on which page the syntax is placed it works. So is there a way to achieve that without changing the code in the controller? Thanks in advance.