Esempio n. 1
0
        protected string querySystems(ref systemsViewModel viewModel)
        {
            string           ret   = "";
            tblSystem        ts    = new tblSystem();
            systemsViewModel tmpVM = viewModel;
            var qry = (from a in ts.getAllDisp()
                       select a).AsQueryable();

            if (!string.IsNullOrWhiteSpace(viewModel.projectId))
            {
                qry = qry.Where(x => x.projectId == new Guid(tmpVM.projectId));
            }
            if (!string.IsNullOrWhiteSpace(viewModel.systemName))
            {
                qry = qry.Where(x => x.systemName.Contains(tmpVM.systemName));
            }
            viewModel.systemList = qry.ToList();
            return(ret);
        }
Esempio n. 2
0
        public ActionResult Systems()
        {
            systemsViewModel viewModel = new systemsViewModel();
            var projectId = Session["projectId"];

            if (projectId == null)
            {
                return(RedirectToAction("Index", "Project"));
            }
            {
                viewModel.projectId = projectId.ToString();
                ViewBag.projectName = Session["projectName"] + "";
                ViewBag.projectLock = true;
            }
            //else
            ViewBag.projectList     = PMdropdownOption.projectList();
            ViewBag.systemTypeList  = SDdropdownOptions.systemTypeList();
            ViewBag.systemGroupList = SDdropdownOptions.systemGroupList();
            return(View(viewModel));
        }
Esempio n. 3
0
        public ActionResult Systems(systemsViewModel viewModel)
        {
            ActionResult ar;
            var          multiSelect = Request.Form["multiSelect"];

            ViewBag.projectList = PMdropdownOption.projectList();
            var projectId = Session["projectId"];

            if (projectId == null)
            {
                return(RedirectToAction("Index", "Project"));
            }
            {
                viewModel.projectId = projectId.ToString();
                ViewBag.projectName = Session["projectName"] + "";
                ViewBag.projectLock = true;
            }
            //else
            viewModel.clearMsg();
            tblSystem           ts = new tblSystem();
            systemEditViewModel tmpVM;
            systems             sys;

            switch (viewModel.cmd)
            {
            case "query":
                viewModel.errorMsg = querySystems(ref viewModel);
                ar = View(viewModel);
                break;

            case "add":
                tmpVM            = new systemEditViewModel();
                tmpVM.pageStatus = (int)PAGE_STATUS.ADD;
                TempData["systemEditViewModel"] = tmpVM;
                ar = RedirectToAction("AddUpdate");
                return(ar);

            case "update":
                sys = ts.getById(viewModel.singleSelect);
                if (sys != null)
                {
                    tmpVM            = new systemEditViewModel();
                    tmpVM.editModel  = sys;
                    tmpVM.pageStatus = (int)PAGE_STATUS.EDIT;
                    TempData["systemEditViewModel"] = tmpVM;
                    ar = RedirectToAction("AddUpdate");
                    return(ar);
                }
                viewModel.errorMsg = "error reading this system";
                ar = View(viewModel);
                break;

            case "entity":
                sys = ts.getById(viewModel.singleSelect);
                if (sys != null)
                {
                    Session["systemId"]   = sys.systemId.ToString();
                    Session["systemName"] = sys.systemName + "";
                    ar = RedirectToAction("Index", "SystemEntity");
                    return(ar);
                }
                viewModel.errorMsg = "error reading this system";
                ar = View(viewModel);
                break;

            case "delete":
                //undone !!... (3) delete project delete article also
                if (string.IsNullOrWhiteSpace(multiSelect))
                {
                    viewModel.errorMsg = "please select system to delete";
                }
                else
                {
                    string[] selected = multiSelect.Split(',');
                    foreach (string systemId in selected.ToList())
                    {
                        viewModel.errorMsg += ts.Delete(systemId);
                    }
                    viewModel.errorMsg += ts.SaveChanges();
                    if (string.IsNullOrWhiteSpace(viewModel.errorMsg))
                    {
                        viewModel.successMsg = "successfully deleted";
                        viewModel.errorMsg   =
                            querySystems(ref viewModel);
                    }
                }
                //viewModel.errorMsg = querySystems(ref viewModel);
                ar = View(viewModel);
                break;

            default:
                ar = View(viewModel);
                break;
            }
            return(ar);
        }