Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }