public static ComputerInventory FromComputerName(this ComputerInventory me, string computerName) { if (computerName == string.Empty) { throw new ArgumentNullException(nameof(computerName)); } ComputerHardware lcH; ComputerSoftware lcS; ComputerProcesses lcP; switch (computerName.Trim().ToLowerInvariant()) { //ToDo: read actual inventory, currently specific for laptop case "localhost": // Get the hardware lcH = new ComputerHardware().FromComputerName(computerName); // ToDo: add "FromComputerName" extension method to ComputerSoftware and ComputerProcesses lcS = me.ComputerSoftware; lcP = me.ComputerProcesses; break; default: throw new NotImplementedException($"cannot populate ComputerInventory object from computerName = {computerName}"); } ComputerInventory lCI = new ComputerInventory() { ComputerName = computerName, ComputerHardware = lcH, ComputerSoftware = lcS, ComputerProcesses = lcP }; return(lCI); }
public ComputerInventory(ComputerHardware computerHardware, ComputerSoftware computerSoftware, ComputerProcesses computerProcesses, string computerName) { ComputerHardware = computerHardware ?? throw new ArgumentNullException(nameof(computerHardware)); ComputerSoftware = computerSoftware ?? throw new ArgumentNullException(nameof(computerSoftware)); ComputerProcesses = computerProcesses ?? throw new ArgumentNullException(nameof(computerProcesses)); ComputerName = computerName ?? throw new ArgumentNullException(nameof(computerName)); }
public ActionResult Edit([Bind(Include = "ComputerHardwareID,ComputerID,HardwareID,AmvalCode,Serial")] ComputerHardware computerHardware) { if (ModelState.IsValid) { db.Entry(computerHardware).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = computerHardware.ComputerID })); } ViewBag.ComputerID = new SelectList(db.Computer, "Computer_ID", "Computer_ID", computerHardware.ComputerID); ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", computerHardware.HardwareID); return(View(computerHardware)); }
//{ // ComputerType ct = db.ComputerType.Find(id); // var a = db.Computer.Where(c => c.TypeOfComputer == id).Select(c => c.Computer_ID).Max(); // string s = ct.SubUnitID + (ct.ID < 10 ? "0" + ct.ID.ToString() : ct.ID.ToString()) + (a == null ? "0001" : (Convert.ToInt32(a) + 1).ToString().Substring(3, 4)); // return s; //} // GET: Admin/ComputerHardwares/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComputerHardware computerHardware = db.ComputerHardware.Find(id); if (computerHardware == null) { return(HttpNotFound()); } return(View(computerHardware)); }
// GET: Admin/ComputerHardwares/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComputerHardware computerHardware = db.ComputerHardware.Find(id); if (computerHardware == null) { return(HttpNotFound()); } ViewBag.ComputerID = new SelectList(db.Computer, "Computer_ID", "Computer_ID", computerHardware.ComputerID); ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", computerHardware.HardwareID); return(View(computerHardware)); }
public ActionResult DeleteConfirmed(int id) { ComputerHardware computerHardware = db.ComputerHardware.Find(id); String comID = computerHardware.ComputerID; //db.ComputerHardware.Remove(computerHardware); //db.SaveChanges(); //return RedirectToAction("Index"); try { db.ComputerHardware.Remove(computerHardware); db.SaveChanges(); return(RedirectToAction("Index", new { id = comID })); } catch (Exception) { ViewBag.Error = true; return(View("Delete")); } }
// Extension methods to populate a ComputerHardware object public static ATAP.Utilities.ComputerInventory.ComputerHardware FromComputerName(this ATAP.Utilities.ComputerInventory.ComputerHardware me, string computerName) { ATAP.Utilities.ComputerInventory.ComputerHardware lCH; switch (computerName.Trim().ToLowerInvariant()) { //ToDo: read actual HW, currently specific for laptop case "localhost": // create the partitions COD for drive 2 //Log.Debug("in ComputerHardware.FromComputerName initializer"); var partitionInfoExs = new PartitionInfoExs(); PartitionInfoEx PIE1 = new PartitionInfoEx() { DriveLetters = new List <string>() { "E" }, Exceptions = new List <Exception>(), PartitionDbId = new Id <PartitionInfoEx>(Guid.Empty), PartitionId = new Id <PartitionInfoEx>(Guid.NewGuid()), Size = 1000000000000 }; partitionInfoExs.PartitionInfoExCOD.Add(PIE1.PartitionId, PIE1); DiskDriveInfoEx DDIE0 = new DiskDriveInfoEx() { DiskDriveId = new Id <DiskDriveInfoEx>(Guid.NewGuid()), DiskDriveDbId = new Id <DiskDriveInfoEx>(Guid.Empty), DiskDriveMaker = DiskDriveMaker.Generic, DiskDriveType = DiskDriveType.SSD, SerialNumber = "123", PartitionInfoExs = partitionInfoExs, Exceptions = new List <Exception>() }; var diskDriveInfoExs = new DiskDriveInfoExs(); diskDriveInfoExs.DiskDriveInfoExCOD.Add(DDIE0.DiskDriveId, DDIE0); lCH = new ComputerHardware(new MainBoard(MainBoardMaker.Generic, CPUSocket.Generic), new List <CPUMaker> { CPUMaker.Intel }, diskDriveInfoExs.DiskDriveInfoExCOD, new TimeBlock(DateTime.UtcNow, true)); break; default: throw new NotImplementedException($"cannot populate ComputerHardware object from computerName = {computerName}"); } return(lCH); }