예제 #1
0
        public async Task <IActionResult> List(string key)
        {
            try
            {
                var networks = await _networkRepository.GetAllAsync();

                var keyValue = await _keyValuesRepository.GetKeyValueAsync(key) ?? new KeyValue();

                if (keyValue.Override == null)
                {
                    keyValue.Override = Array.Empty <OverrideValue>();
                }

                var model = new OverridesModel
                {
                    KeyValue          = keyValue,
                    Networks          = networks,
                    AvailableNetworks = networks
                                        .Where(item => keyValue.Override.All(o => o.NetworkId != item.Id))
                                        .Select(n => new SelectListItem {
                        Text = n.Name, Value = n.Id
                    })
                                        .OrderBy(item => item.Text)
                                        .ToArray()
                };

                return(PartialView("List", model));
            }
            catch (Exception ex)
            {
                _log.Error(ex, context: key);
                return(PartialView("List", new OverridesModel()));
            }
        }
        public async Task <IActionResult> List()
        {
            try
            {
                var networks = await _networkRepository.GetAllAsync();

                return(PartialView("List", networks));
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(PartialView("List", new Network[] { }));
            }
        }