Exemplo n.º 1
0
        public ActionResult AdminUnits(int?id)
        {
            if (id == null)
            {
                return(new EmptyResult());
            }
            ViewBag.Regions = _adminUnitService.GetRegions();
            var type = _adminUnitService.GetAdminUnitType(id.Value);

            ViewBag.Title          = type.Name + "s";
            ViewBag.SelectedTypeId = id;
            var list = type.AdminUnits.OrderBy(a => a.Name);

            //.Select(s => new Models.AdminUnitItem()
            //{ Id = s.AdminUnitID, Name = s.Name});
            switch (id)
            {
            case 3:
                list = type.AdminUnits.OrderBy(a => a.AdminUnit2.Name).ThenBy(a => a.Name);
                break;

            case 4:
                list = type.AdminUnits.OrderBy(a => a.AdminUnit2.AdminUnit2.Name).ThenBy(a => a.AdminUnit2.Name).ThenBy(a => a.Name);
                break;
            }
            var viewName = "Lists/AdminUnits." + id + "";

            return(PartialView(viewName, list));
        }