/// <summary> /// Action after "Update" button click /// </summary> /// <param name="viewModel">Interface options from form.</param> /// <returns>Redirect to home page</returns> public async Task <IActionResult> Edit(InterfaceViewModel viewModel) { if (viewModel.IsGVRP) { GVRPActivePortsSingleton.Instance.InterfaceStates[viewModel.Name] = InterfaceState.Listening; } else { GVRPActivePortsSingleton.Instance.InterfaceStates[viewModel.Name] = InterfaceState.Off; } switch (viewModel.Type) { case InterfaceType.Promiscuous when viewModel.VirtualLANs.Count() > 1: return(RedirectToAction("Index", new IndexViewModel { Error = "Promiscuous Interface cannot have more than 1 VLAN." })); case InterfaceType.Isolated when viewModel.VirtualLANs.Count() > 1: return(RedirectToAction("Index", new IndexViewModel { Error = "Isolated Interface cannot have more than 1 VLAN." })); } _ethernetServices.SetEthernetInterfaceState(viewModel.Name, viewModel.IsActive); _ethernetServices.ClearEthernetInterfaceVLANs(viewModel.Name); _ethernetServices.ApplyEthernetInterfaceVLANs(viewModel.Name, viewModel.Tagged, viewModel.IsGVRP, viewModel.VirtualLANs); _ethernetServices.SetEthernetInterfaceType(viewModel.Name, viewModel.Type); return(RedirectToAction("Index")); }
/// <summary> /// Action after "Update" button click /// </summary> /// <param name="viewModel">Interface options from form.</param> /// <returns>Redirect to home page</returns> public IActionResult Edit(InterfaceViewModel viewModel) { _ethernetServices.SetEthernetInterfaceState(viewModel.Name, viewModel.IsActive); _ethernetServices.ClearEthernetInterfaceVLANs(viewModel.Name); _ethernetServices.ApplyEthernetInterfaceVLANs(viewModel.Name, viewModel.Tagged, viewModel.VirtualLANs); _ethernetServices.SetEthernetInterfaceType(viewModel.Name, viewModel.Type); return(RedirectToAction("Index")); }
public async Task ShouldApplyWLANToInterface() { var vlans = new List <string> { "1" }; var ethernetInterfaceBefore = _service .GetEthernetInterfaces() .First(); _service.ClearEthernetInterfaceVLANs(ethernetInterfaceBefore.Name); _service.ApplyEthernetInterfaceVLANs(ethernetInterfaceBefore.Name, false, false, vlans); _service.SetEthernetInterfaceType(ethernetInterfaceBefore.Name, InterfaceType.Off); var ethernetInterfaceAfter = _service .GetEthernetInterfaces() .First(x => x.Name == ethernetInterfaceBefore.Name); Assert.That(ethernetInterfaceAfter.VirtualLANs, Has.Count.EqualTo(1)); Assert.That(ethernetInterfaceAfter.VirtualLANs, Has.One.EqualTo("1")); }