/
CountriesController.cs
52 lines (45 loc) · 1.38 KB
/
CountriesController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CouchbaseBeersWeb.Models;
namespace CouchbaseBeersWeb.Controllers
{
public class CountriesController : Controller
{
public BreweryRepository BreweryRepository { get; set; }
public CountriesController()
{
BreweryRepository = new BreweryRepository();
}
public ActionResult Index()
{
var grouped = BreweryRepository.GetGroupedByLocation(BreweryGroupLevels.Country);
return View(grouped);
}
public ActionResult Provinces(string country)
{
var grouped = BreweryRepository.GetGroupedByLocation(
BreweryGroupLevels.Province, new string[] { country });
return View(grouped);
}
public ActionResult Cities(string country, string province)
{
var grouped = BreweryRepository.GetGroupedByLocation(
BreweryGroupLevels.City, new string[] { country, province });
return View(grouped);
}
public ActionResult Codes(string country, string province, string city)
{
var grouped = BreweryRepository.GetGroupedByLocation(
BreweryGroupLevels.PostalCode, new string[] { country, province, city });
return View(grouped);
}
public ActionResult Details(string country, string province, string city, string code)
{
var breweries = BreweryRepository.GetByLocation(country, province, city, code);
return View(breweries);
}
}
}