public IHttpActionResult CreateNetworkInterface(NetworkInterfaceModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var networkfordevice = new NetworkInterface();
             networkfordevice.HostName           = model.HostName;
             networkfordevice.SelectManufacturer = model.SelectManufacturer;
             networkfordevice.Model     = model.Model;
             networkfordevice.OS        = model.OS;
             networkfordevice.OSVersion = model.OSVersion;
             networkfordevice.ManufacturerPartNumber           = model.ManufacturerPartNumber;
             networkfordevice.SerialNumber                     = model.SerialNumber;
             networkfordevice.InstallDate                      = model.InstallDate;
             networkfordevice.WarrantyStarted                  = model.WarrantyStarted;
             networkfordevice.WarrantyExpires                  = model.WarrantyExpires;
             networkfordevice.UploadNetworkSwitchConfiguration = model.UploadNetworkSwitchConfiguration;
             networkfordevice.Notes     = model.Notes;
             networkfordevice.SelectTag = model.SelectTag;
             networkfordevice.CompanyId = model.CompanyId;
             db.NetworkInterfaces.Add(networkfordevice);
             db.SaveChanges();
             return(Ok(networkfordevice));
         }
         else
         {
             return(Ok("Please Enter All the mandatory Fields"));
         }
     }
     catch (Exception ex)
     {
         return(NotFound());
     }
 }
Esempio n. 2
0
 private void _RebuildInterfaceList()
 {
     foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
     {
         NetworkInterfaceModel model;
         if (!_cache.TryGetValue(networkInterface.Name, out model))
         {
             model = new NetworkInterfaceModel(networkInterface);
             _cache.Add(model.Name, model);
         }
         else
         {
             model.Reset();
             model.OperationalStatus = networkInterface.OperationalStatus;
         }
     }
     Interfaces = Array.AsReadOnly(_cache.Values.OrderBy(m => m.Name).ToArray());
 }