public static Navigator GetNavigator(string regionName, string areaName, string locationName, int entryId = 0)
        {
            Data.INavigationRepository repository = GetRepository();
            Models.Navigator           navigator  = new Models.Navigator();
            navigator.RegionName   = regionName;
            navigator.AreaName     = areaName;
            navigator.LocationName = locationName;
            navigator.EntryId      = entryId;
            navigator.Regions.AddRange(repository.Regions());
            navigator.RegionId = navigator.Regions.DefaultIfEmpty(new Data.Region()).First(r => r.RegionName == navigator.RegionName).RegionId;

            navigator.Areas.AddRange(repository.GetAreasByRegionId(navigator.RegionId));
            if (!String.IsNullOrEmpty(navigator.AreaName))
            {
                Area area = navigator.Areas.FirstOrDefault <Area>(a => String.Compare(a.AreaName, navigator.AreaName, true) == 0);
                navigator.AreaId = area.AreaId;
                navigator.Locations.AddRange(repository.GetLocationsByAreaId(navigator.AreaId));
            }

            //locatons
            if (!String.IsNullOrEmpty(navigator.LocationName))
            {
                navigator.LocationId = navigator.Locations.DefaultIfEmpty(new Data.Location()).First(l => l.LocationName == navigator.LocationName).LocationId;
                navigator.Entries.AddRange(repository.GetEntriesByLocationId(navigator.LocationId));
            }

            return(navigator);
        }
Ejemplo n.º 2
0
 public ActionResult Index()
 {
     return(View("Index", repository.Regions()));
 }