public ActionResult AssignComputer() { ViewBag.Lbl_department = CommonLogic.getLabelName(2).ToString(); ViewBag.Lbl_depgroup = CommonLogic.getLabelName(3).ToString(); try{ DSRCManagementSystem.Models.AssignComputers obj = new DSRCManagementSystem.Models.AssignComputers(); DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); UserDetail(); var ComponentList = db.Assets.ToList(); var s = (from at in db.AssetTypes join ast in db.Assets on at.AssetTypeId equals ast.AssetTypeId where at.AssetName != "UPS" && ast.ISDelete == false && ast.ComputerName == 0 select new { name = ast.Name_Model_No, id = ast.AssetID //at.AssetTypeId, by Boobalan }).ToList(); var UpsList = db.Assets.ToList(); var w = (from at in db.AssetTypes join ast in db.Assets on at.AssetTypeId equals ast.AssetTypeId where at.AssetName == "UPS" && ast.ISDelete == false select new { name1 = ast.Name_Model_No, id1 = at.AssetTypeId }).ToList(); var computer = (from p in db.computermanagements.Where(x => x.ISDelete == false) select new { managementid = p.managementid, ComputerName = p.ComputerName }).ToList(); ViewBag.PenDriveAcessList = new SelectList(new[] { new { Text = "---Select---", Value = 0 }, new { Text = "No", Value = 0 }, new { Text = "Yes", Value = 1 } }, "Value", "Text", 0); var LocationList = db.locations.ToList(); var deleted = db.UserAssetMappings.Where(x => x.IsActive == false).Select(x => x.AssignId.Value).ToList(); var assign = db.ComputerAssigneds.Select(x => x.Assignid).ToList(); var LstCompAssigned = assign.Except(deleted); var Lst = db.ComputerAssigneds.Where(x => LstCompAssigned.Contains(x.Assignid)).Select(x => x.Managementid).ToList(); var ComputerNameList = db.computermanagements.Where(x => x.ISDelete == false && x.ComputerStatusNew == "Active").ToList(); //|| !Lst.Contains(x.managementid)).ToList(); //var ComputerNameList = db.computermanagements.Where(x => x.ISDelete != true).ToList(); ViewBag.ComponentIdList = new MultiSelectList(s, "id", "name"); ViewBag.UpsList = new SelectList(w, "id1", "name1"); ViewBag.LocationIDList = new SelectList(new[] { new location() { locationid = 0, LocationName = "---select---" } }.Union(LocationList), "locationid", "LocationName", 0); ViewBag.ManagementIdList = new SelectList(new[] { new computermanagement() { managementid = 0, ComputerName = "---select---" } }.Union(ComputerNameList), "managementid", "ComputerName", 0); // ViewBag.ManagementIdList = new SelectList(computer, "managementid",); } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(View()); }
public ActionResult EditCmptr(int ID) { var obj = new AssignComputers(); try { ViewBag.Lbl_department = CommonLogic.getLabelName(2).ToString(); //ViewBag.Lbl_depgroup = CommonLogic.getLabelName(3).ToString(); DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); DSRCManagementSystem.Models.AssignComputers AsgnList = new DSRCManagementSystem.Models.AssignComputers(); UserDetail(); obj = (from a in db.ComputerAssigneds where a.Assignid == ID && a.ISDelete == false join e in db.UserAssetMappings on a.Assignid equals e.AssignId // join b in db.Assets on e.AssetID equals b.AssetID join d in db.Departments on a.Departmentid equals d.DepartmentId join u in db.Users on a.Userid equals u.UserID join l in db.locations on a.Locationid equals l.locationid join c in db.computermanagements on a.Managementid equals c.managementid join b in db.Assets on e.AssetID equals b.AssetID into joinasset from jn in joinasset.DefaultIfEmpty() select new DSRCManagementSystem.Models.AssignComputers() { UserId = u.UserID, DepartmentId = d.DepartmentId, LocationId = l.locationid, Managementid = c.managementid, EmployeeName = (u.FirstName + " " + (u.LastName ?? "")).Trim(), Department = d.DepartmentName, Location = l.LocationName, ComputerName = c.ComputerName, PenDriveAcess = a.pendriveAccessnew, UPSID = a.UPSID, ComponentId = jn.Name_Model_No, Component = e.Component, CompId = e.AssetID, WorkstationNumber = a.WorkStation, ID = a.Assignid, }).FirstOrDefault(); //var z = AssetManagementController.GetUserString(db, obj.Component); if (obj.PenDriveAcess == false) { ViewBag.PenDriveAcessList = new SelectList(new[] { new { Text = "No", Value = "No" }, new { Text = "Yes", Value = "Yes" } }, "Text", "Value", "No"); } else { ViewBag.PenDriveAcessList = new SelectList(new[] { new { Text = "Yes", Value = "Yes" }, new { Text = "No", Value = "No" } }, "Text", "Value", "Yes"); } var UpsRef = db.Assets.FirstOrDefault(o => o.Name_Model_No == obj.UPSID); var s = (from at in db.AssetTypes join ast in db.Assets on at.AssetTypeId equals ast.AssetTypeId where at.AssetName != "UPS" && ast.ISDelete == false && ast.ComputerName == 0 select new { name = ast.Name_Model_No, id = ast.AssetID, }).ToList(); var w = (from at in db.AssetTypes join ast in db.Assets on at.AssetTypeId equals ast.AssetTypeId where at.AssetName == "UPS" && ast.ISDelete == false select new { Name_Model_No = ast.Name_Model_No, AssetID = ast.AssetID, }).ToList(); if (UpsRef != null) { for (int i = 0; i < w.Count; i++) { var item = w[i]; if (item.AssetID == UpsRef.AssetID) { w.Remove(item); w.Insert(0, item); } } ViewBag.abc = true; ViewBag.UpsList = new SelectList(w, "AssetID", "Name_Model_No"); } else { ViewBag.abc = false; ViewBag.UpsList = new SelectList(w, "AssetID", "Name_Model_No"); } List <int> list = new List <int>(); list.Add(Convert.ToInt32(obj.CompId)); ViewBag.ComponentIdList = new MultiSelectList(s, "id", "name", obj.Component); var LocationList = db.locations.ToList(); ViewBag.LocationIDList = new SelectList(LocationList, "locationid", "LocationName", obj.LocationId); var LstCompAssigned = db.ComputerAssigneds.Select(x => x.Managementid).ToList(); var ComputerNameList = db.computermanagements.Where(x => x.ISDelete == false).ToList(); ViewBag.ManagementIdList = new SelectList(ComputerNameList, "managementid", "ComputerName", obj.Managementid); return(View(obj)); } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(View(obj)); }
public ActionResult AssignComputers(AssignComputers model) { DSRCManagementSystem.Models.AssignComputers obj_Assign = new DSRCManagementSystem.Models.AssignComputers(); return(View(obj_Assign)); }