コード例 #1
0
        public async Task OnGetAsync()
        {
            try
            {
                Slipways = new SlipwaysModel();
                var slipways = await _dataStore.Slipways.GetValuesAsync();

                foreach (var slipway in slipways)
                {
                    slipway.Water.Longname = slipway.Water.Longname.FirstUpper();
                }
                if (slipways != null)
                {
                    Slipways.Slipways = slipways.OrderBy(_ => _.Name).ToHashSet();
                }
                else
                {
                    Slipways.Slipways = new HashSet <Slipway>();
                }
            }
            catch (Exception e)
            {
                _logger.LogError(6666, e, $"Error occurred while GET index page");
                Redirect("/Error");
            }
        }
コード例 #2
0
        public async Task <IActionResult> OnGetFilter(
            [FromQuery] string search)
        {
            try
            {
                Slipways = new SlipwaysModel();
                var slipways = await _dataStore.Slipways.GetValuesAsync();

                if (slipways == null)
                {
                    return(Page());
                }


                IEnumerable <Slipway> searchResult;
                searchResult = slipways;
                if (!string.IsNullOrWhiteSpace(search))
                {
                    search       = search.ToLower();
                    searchResult = searchResult.Where(_ => _.Name.ToLower().Contains(search) || _.City.ToLower().Contains(search) || _.Water.Longname.ToLower().Contains(search)).Distinct();
                }
                searchResult = searchResult.OrderBy(_ => _.Name);
                foreach (var slipway in searchResult)
                {
                    slipway.Water.Longname = slipway.Water.Longname.FirstUpper();
                }
                Slipways.Slipways = new HashSet <Slipway>(searchResult);
                var partial = Partial("_SlipwayTable", Slipways);
                return(partial);
            }
            catch (Exception e)
            {
                _logger.LogError(6666, e, $"Error occurred while GET filter index page");
                return(Redirect("/Error"));
            }
        }