Exemplo n.º 1
0
 public ActionResult MitigationListAdmin(MitigationListParamViewModel vm)
 {
     UpdateListParam(vm);
     return View(vm);
 }
Exemplo n.º 2
0
        private void UpdateListParam(MitigationListParamViewModel vm)
        {
            Dictionary<int, string> posList = new Dictionary<int, string>();
            posList.Add(1, "Kantor Pusat");
            posList.Add(2, "Cabang");
            vm.PosList = new SelectList(posList, "Key", "Value", vm.PosId);

            Dictionary<int, string> branchList = new Dictionary<int, string>();
            foreach (var branch in db.Branches.OrderBy(m => m.ClassId).ThenBy(m => m.BranchName))
                branchList.Add(branch.BranchId, branch.BranchName + " (Kelas " + branch.BranchClass.ClassName + ")");
            vm.Branches = new SelectList(branchList, "Key", "Value", vm.BranchId);

            Dictionary<int, string> stateList = new Dictionary<int, string>();
            stateList.Add(1, "Belum di-approve");
            stateList.Add(2, "Dalam proses approval");
            stateList.Add(3, "Approved");
            vm.States = new SelectList(stateList, "Key", "Value", vm.StateId);

            //vm.MitigationApprovals = db.MitigationApprovals;
            vm.RiskMitigations = db.RiskMitigations;
            if (vm.PosId == 1)
                //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.RiskMitigation.Risk.DeptId != null);
                vm.RiskMitigations = db.RiskMitigations.Where(p => p.Risk.DeptId != null);
            else if (vm.PosId == 2)
            {
                //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.RiskMitigation.Risk.BranchId != null);
                vm.RiskMitigations = vm.RiskMitigations.Where(p => p.Risk.BranchId != null);
                if (vm.BranchId != null)
                    //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.RiskMitigation.Risk.BranchId == vm.BranchId);
                    vm.RiskMitigations = vm.RiskMitigations.Where(p => p.Risk.BranchId == vm.BranchId);
            }

            switch (vm.StateId)
            {
                case 1:
                    //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => !p.RiskMitigation.IsReadOnly);
                    vm.RiskMitigations = vm.RiskMitigations.Where(p => !p.IsReadOnly);
                    break;
                case 2:
                    //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.RiskMitigation.IsReadOnly && p.RiskMitigation.ApprovalDate == null);
                    vm.RiskMitigations = vm.RiskMitigations.Where(p => p.IsReadOnly && p.ApprovalDate == null);
                    break;
                case 3:
                    //vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.RiskMitigation.ApprovalDate != null);
                    vm.RiskMitigations = vm.RiskMitigations.Where(p => p.ApprovalDate != null);
                    break;
            }
            vm.RiskMitigations = vm.RiskMitigations.OrderBy(p => p.MitigationDate);
        }
Exemplo n.º 3
0
 public ActionResult MitigationListAdmin()
 {
     MitigationListParamViewModel vm = new MitigationListParamViewModel();
     vm.PosId = 1;
     vm.StateId = 1;
     UpdateListParam(vm);
     return View(vm);
 }