Пример #1
0
        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));
        }
Пример #2
0
 public ActionResult AssignComputers(AssignComputers model)
 {
     DSRCManagementSystem.Models.AssignComputers obj_Assign = new DSRCManagementSystem.Models.AssignComputers();
     return(View(obj_Assign));
 }