Beispiel #1
0
        public IActionResult AddEquipmentToNetwork(int networkId)
        {
            var network = _dbContext.Networks.FirstOrDefault(n => n.NetworkId == networkId);

            if (network == null)
            {
                return(NotFound());
            }

            var networkData = new NetworkData {
                Network = network
            };

            networkData.Equipments        = _dbContext.Equipments.ToList();
            networkData.NetworkEquipments = _dbContext.UserNetworkEquipments.Where(n => n.NetworkId == network.NetworkId).ToList();

            return(View(networkData));
        }
Beispiel #2
0
        public IActionResult Index()
        {
            var userId       = User.Claims.FirstOrDefault(u => u.Type == ClaimTypes.NameIdentifier).Value;
            var userNetworks = _dbContext.Networks.Where(n => n.UserId == userId).ToList();

            var networkData = new List <NetworkData>();

            foreach (var network in userNetworks)
            {
                var netData = new NetworkData();
                netData.Network    = network;
                netData.Equipments = new List <Equipment>();

                var userEquipments = _dbContext.UserNetworkEquipments.Where(u => u.NetworkId == network.NetworkId).ToList();
                foreach (var netEquipment in userEquipments)
                {
                    netData.Equipments.Add(_dbContext.Equipments.FirstOrDefault(u => u.EquipmentId == netEquipment.EquipmentId));
                }
                networkData.Add(netData);
            }
            return(View(networkData));
        }