public ActionResult ManageHardware() { Asset1(); ManageHardwareModel rec = new ManageHardwareModel(); rec.HardwareListCollection = (from a in db.Assets where a.InUse == true && a.ISDelete == false join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() select new HardwareList() { ID = a.AssetID, Hardware = c.AssetName, Component = a.Name_Model_No, Model = a.ModelNo, AssignedTo = a.ComputerName == 0 ? "Not Assigned" : tab1.ComputerName, Floor = a.LocationID == 0 ? "Not Allocated" : tab2.LocationName, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse }).ToList(); return(View(rec)); }
public ActionResult ManageHardware(ManageHardwareModel HW, FormCollection form) { Asset1(); bool status = form["NotInUse"].Contains("true"); int DropHardware = Convert.ToInt32(HW.ID); if (DropHardware == 0) { if (status == true) { HW.HardwareListCollection = (from a in db.Assets where a.InUse == false && a.ISDelete == false join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() select new HardwareList() { ID = a.AssetID, Hardware = c.AssetName, Component = a.Name_Model_No, Model = a.ModelNo, AssignedTo = a.ComputerName == 0 ? "Not Assigned" : tab1.ComputerName, Floor = a.LocationID == 0 ? "Not Allocated" : tab2.LocationName, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse }).ToList(); } else { HW.HardwareListCollection = (from a in db.Assets where a.InUse == true && a.ISDelete == false join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() select new HardwareList() { ID = a.AssetID, Hardware = c.AssetName, Component = a.Name_Model_No, Model = a.ModelNo, AssignedTo = a.ComputerName == 0 ? "Not Assigned" : tab1.ComputerName, Floor = a.LocationID == 0 ? "Not Allocated" : tab2.LocationName, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse }).ToList(); } } else { if (status == true) { HW.HardwareListCollection = (from a in db.Assets where a.InUse == false join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() where (a.ISDelete == false && a.AssetTypeId == DropHardware) select new HardwareList() { ID = a.AssetID, Hardware = c.AssetName, Component = a.Name_Model_No, Model = a.ModelNo, AssignedTo = a.ComputerName == 0 ? "Not Assigned" : tab1.ComputerName, Floor = a.LocationID == 0 ? "Not Allocated" : tab2.LocationName, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse }).ToList(); } else { HW.HardwareListCollection = (from a in db.Assets where a.InUse == true join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() where (a.ISDelete == false && a.AssetTypeId == DropHardware) select new HardwareList() { ID = a.AssetID, Hardware = c.AssetName, Component = a.Name_Model_No, Model = a.ModelNo, AssignedTo = a.ComputerName == 0 ? "Not Assigned" : tab1.ComputerName, Floor = a.LocationID == 0 ? "Not Allocated" : tab2.LocationName, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse }).ToList(); } } return(View(HW)); }
public ActionResult EditComponent(int ID) { location1(); ViewBag.InUse = new SelectList(new[] { new { Text = "Yes", Value = 0 }, new { Text = "No", Value = 1 } }, "Value", "Text", 0); var obj = (from a in db.Assets.Where(o => o.AssetID == ID) join b in db.locations on a.LocationID equals b.locationid into Bord1 from tab2 in Bord1.DefaultIfEmpty() join c in db.AssetTypes on a.AssetTypeId equals c.AssetTypeId join d in db.computermanagements on a.ComputerName equals d.managementid into Bord from tab1 in Bord.DefaultIfEmpty() select new HardwareList() { Hardware = c.AssetName, lid = tab2.locationid, AssignedTo = tab1.ComputerName, Floor = tab2.LocationName, Component = a.Name_Model_No, Model = a.ModelNo, mid = tab1.managementid, Quantity = a.Quantity, Ip = a.ConnectedTo, InUse = a.InUse, isdelete = true, Id = ID, AssignedToId = a.ComputerName }).FirstOrDefault(); var Deparmentgroup = (from p in db.DepartmentGroups.Where(x => x.IsActive == true) select new { GroupId = p.GroupID, GroupName = p.GroupName }).ToList(); var query = (from l in db.locations select new { locationid = l.locationid, LocationName = l.LocationName }).ToList(); ViewBag.Detail1 = new SelectList(query, "locationid", "LocationName", obj.lid); for (int i = 0; i < query.Count; i++) { var item = query[i]; if (item.locationid == obj.lid) { query.Remove(item); query.Insert(0, item); } } var ComputerNameList = (from m in db.computermanagements.Where(z => z.ISDelete == false && z.ComputerStatusNew == "Active") select new { managementid = m.managementid, ComputerName = m.Manufacturer }).ToList(); ViewBag.ManagementIdList = new SelectList(ComputerNameList, "managementid", "ComputerName", obj.AssignedToId); if (obj.InUse == true) { ViewBag.InUse = new SelectList(new[] { new { Text = "Yes", Value = "Yes" }, new { Text = "No", Value = "No" } }, "Text", "Value", "Yes"); } else { ViewBag.InUse = new SelectList(new[] { new { Text = "No", Value = "No" }, new { Text = "Yes", Value = "Yes" } }, "Text", "Value", "No"); } return(View(obj)); }