2021-09-08 22:12:51 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
2021-09-08 22:33:17 +10:00
|
|
|
|
using SportsStore.Domain.Abstract;
|
2021-09-08 22:12:51 +10:00
|
|
|
|
|
|
|
|
|
namespace SportsStore.WebUI.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class NavController : Controller
|
|
|
|
|
{
|
2021-09-08 22:33:17 +10:00
|
|
|
|
private IProductRepository repository;
|
|
|
|
|
|
|
|
|
|
public NavController(IProductRepository repo)
|
2021-09-08 22:12:51 +10:00
|
|
|
|
{
|
2021-09-08 22:33:17 +10:00
|
|
|
|
repository = repo;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 23:11:00 +10:00
|
|
|
|
public PartialViewResult Menu(string category = null)
|
2021-09-08 22:33:17 +10:00
|
|
|
|
{
|
2021-09-08 23:11:00 +10:00
|
|
|
|
ViewBag.SelectedCategory = category;
|
|
|
|
|
|
2021-09-08 22:33:17 +10:00
|
|
|
|
IEnumerable<string> categories = repository.Products
|
|
|
|
|
.Select(x => x.Category)
|
|
|
|
|
.Distinct()
|
|
|
|
|
.OrderBy(x => x);
|
|
|
|
|
|
|
|
|
|
return PartialView(categories);
|
2021-09-08 22:12:51 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|