예제 #1
0
 public ActionResult Edit(RiskMitigationViewModel vm, int id)
 {
     if (ModelState.IsValid)
     {
         vm.RiskMitigation.RiskLevel = vm.RiskMitigation.ProbLevelId * vm.RiskMitigation.ImpactLevelId;
         db.RiskMitigations.Attach(vm.RiskMitigation);
         db.ObjectStateManager.ChangeObjectState(vm.RiskMitigation, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("MitigationList");
     }
     return View(vm);
 }
예제 #2
0
        public ActionResult Edit(int id)
        {
            RiskMitigationViewModel vm = new RiskMitigationViewModel();
            vm.RiskMitigation = db.RiskMitigations.Where(p => p.MitigationId == id).FirstOrDefault();

            vm.MitigationCats = new SelectList(db.MitigationCats, "MitigationCatId", "MitigationCatName", vm.RiskMitigation.MitigationCatId);
            vm.MitigationTypes = new SelectList(db.MitigationTypes.Where(p => p.MitigationCatId == vm.RiskMitigation.MitigationCatId), "MitigationTypeId", "MitigationTypeName", vm.RiskMitigation.MitigationTypeId);

            Dictionary<int, string> probList = new Dictionary<int, string>();
            foreach (var item in db.ProbLevels)
                probList.Add(item.ProbLevelId, item.ProbLevelId + " - " + item.ProbLevelName);
            vm.ProbLevels = new SelectList(probList, "Key", "Value", vm.RiskMitigation.ProbLevelId);

            Dictionary<int, string> impactList = new Dictionary<int, string>();
            foreach (var item in db.ImpactLevels)
                impactList.Add(item.ImpactLevelId, item.ImpactLevelId + " - " + item.ImpactLevelName);
            vm.ImpactLevels = new SelectList(impactList, "Key", "Value", vm.RiskMitigation.ImpactLevelId);

            return View(vm);
        }
예제 #3
0
        public ActionResult MitigationNew(int riskId)
        {
            RiskMitigationViewModel vm = new RiskMitigationViewModel();
            vm.Risk = db.Risks.Where(p => p.RiskId == riskId).FirstOrDefault();

            vm.MitigationCats = new SelectList(db.MitigationCats, "MitigationCatId", "MitigationCatName");
            vm.MitigationTypes = new SelectList(Enumerable.Empty<SelectListItem>(), "MitigationTypeId", "MitigationTypeName");

            Dictionary<int, string> probList = new Dictionary<int, string>();
            foreach (var item in db.ProbLevels)
                probList.Add(item.ProbLevelId, item.ProbLevelId + " - " + item.ProbLevelName);
            vm.ProbLevels = new SelectList(probList, "Key", "Value");

            Dictionary<int, string> impactList = new Dictionary<int, string>();
            foreach (var item in db.ImpactLevels)
                impactList.Add(item.ImpactLevelId, item.ImpactLevelId + " - " + item.ImpactLevelName);
            vm.ImpactLevels = new SelectList(impactList, "Key", "Value");

            vm.RiskMitigation = new RiskMitigation();
            vm.RiskMitigation.RiskId = riskId;
            vm.RiskMitigation.MitigationCode = Utils.CreateNewMiticationCode(riskId);
            vm.RiskMitigation.InputDate = DateTime.Now;
            vm.RiskMitigation.MitigationDate = DateTime.Now;
            vm.RiskMitigation.OrgPos = vm.Risk.OrgPos;

            return View(vm);
        }
예제 #4
0
        public ActionResult MitigationNew(RiskMitigationViewModel vm, int riskId)
        {
            if (ModelState.IsValid)
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    vm.Risk = db.Risks.Where(p => p.RiskId == riskId).FirstOrDefault();
                    vm.RiskMitigation.RiskLevel = vm.RiskMitigation.ProbLevelId * vm.RiskMitigation.ImpactLevelId;
                    vm.RiskMitigation.DeptId = vm.Risk.DeptId;
                    vm.RiskMitigation.SubDeptId = vm.Risk.SubDeptId;
                    vm.RiskMitigation.DivisionId = vm.Risk.DivisionId;
                    vm.RiskMitigation.SubDivId = vm.Risk.SubDivId;
                    vm.RiskMitigation.BranchId = vm.Risk.BranchId;
                    vm.RiskMitigation.SubBranchId = vm.Risk.SubBranchId;
                    vm.RiskMitigation.BizUnitId = vm.Risk.BizUnitId;
                    db.RiskMitigations.AddObject(vm.RiskMitigation);
                    db.SaveChanges();

                    Utils.CreateFirstMitigationApprovalSchedule(vm.RiskMitigation.MitigationId);
                    trans.Complete();
                }
                return RedirectToAction("MitigationEdit", new { id = vm.RiskMitigation.MitigationId, approved = false });
            }
            return View(vm);
        }
예제 #5
0
        public ActionResult MitigationListNonRO(int id, bool approved)
        {
            UserData data = Utils.LoadUserDataFromSession();

            RiskMitigationViewModel vm = new RiskMitigationViewModel();
            vm.Risk = db.Risks.Where(p => p.RiskId == id).FirstOrDefault();
            vm.MitigationApprovals = db.MitigationApprovals.Where(p => p.OrgPos == data.OrgPos && p.RiskMitigation.RiskId == id);
            if (approved)
                vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.ApprovalDate != null);
            else
                vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.ApprovalDate == null);

            switch (data.OrgPos)
            {
                case Utils.ORGPOS_DEPT:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.DeptId == data.DeptId);
                    break;
                case Utils.ORGPOS_SUBDEPT:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.SubDeptId == data.SubDeptId);
                    break;
                case Utils.ORGPOS_DIVISION:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.DivisionId == data.DivisionId);
                    break;
                case Utils.ORGPOS_SUBDIV:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.SubDivId == data.SubDivId);
                    break;
                case Utils.ORGPOS_BRANCH:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.BranchId == data.BranchId);
                    break;
                case Utils.ORGPOS_SUBBRANCH:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.SubBranchId == data.SubBranchId);
                    break;
                case Utils.ORGPOS_BIZUNIT:
                    vm.MitigationApprovals = vm.MitigationApprovals.Where(p => p.BizUnitId == data.BizUnitId);
                    break;
            }

            return View(vm);
        }
예제 #6
0
        public ActionResult MitigationListRO(int id, string status)
        {
            RiskMitigationViewModel vm = new RiskMitigationViewModel();
            vm.Risk = db.Risks.Where(p => p.RiskId == id).FirstOrDefault();
            vm.RiskMitigations = db.RiskMitigations.Where(p => p.RiskId == id);

            if (string.IsNullOrEmpty(status))
                vm.RiskMitigations = vm.RiskMitigations.Where(p => !p.IsReadOnly && p.ApprovalDate == null);
            else if (status.ToLower() == "readonly")
                vm.RiskMitigations = vm.RiskMitigations.Where(p => p.IsReadOnly && p.ApprovalDate == null);
            else if (status.ToLower() == "approved")
                vm.RiskMitigations = vm.RiskMitigations.Where(p => p.ApprovalDate != null);

            return View(vm);
        }
예제 #7
0
 public ActionResult MitigationEdit(RiskMitigationViewModel vm, int id)
 {
     if (ModelState.IsValid)
     {
         vm.RiskMitigation.RiskLevel = vm.RiskMitigation.ProbLevelId * vm.RiskMitigation.ImpactLevelId;
         vm.RiskMitigation.MitigationDate = DateTime.Now;
         db.RiskMitigations.Attach(vm.RiskMitigation);
         db.ObjectStateManager.ChangeObjectState(vm.RiskMitigation, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("MitigationList", new { id = vm.RiskMitigation.RiskId, approved = false });
     }
     return View(vm);
 }
예제 #8
0
 public ActionResult MitigationUnitInsert(RiskMitigationViewModel rm)
 {
     using (TransactionScope trans = new TransactionScope())
         {
             rm.MitigationUnits.MitigationUnitId = db.MitigationUnits.OrderByDescending(m => m.MitigationUnitId).First().MitigationUnitId + 1;
             rm.MitigationUnits.DivisionId = rm.division.DivisionId;
             db.MitigationUnits.AddObject(rm.MitigationUnits);
             db.SaveChanges();
             trans.Complete();
         }
         return RedirectToAction("MitigationUnit", new { MitigationId = rm.MitigationUnits.MitigationId, approved = false });
 }
예제 #9
0
        public ActionResult MitigationUnitInsert(int? id)
        {
            RiskMitigationViewModel rm = new RiskMitigationViewModel();
            rm.MitigationUnits = new MitigationUnit();

            Dictionary<int, string> unitList = new Dictionary<int, string>();
            foreach (var item in db.Divisions)
                unitList.Add(item.DivisionId, item.DivisionId + " - " + item.DivisionName);
            rm.divisions = new SelectList(unitList, "Key", "Value", 0);
            rm.MitigationUnits.MitigationId = (int) id;

            return View(rm);
        }
예제 #10
0
        public ActionResult MitigationUnitDelete(int? id, int? MitigationId)
        {
            RiskMitigationViewModel vm = new RiskMitigationViewModel();
            vm.MitigationUnits = db.MitigationUnits.Where(m => m.MitigationUnitId == id).First();
            db.MitigationUnits.DeleteObject(vm.MitigationUnits);
            db.SaveChanges();

            return RedirectToAction("MitigationUnit", new { MitigationId = MitigationId, approved = false });
        }
예제 #11
0
        public ActionResult MitigationUnit(int? MitigationId)
        {
            RiskMitigationViewModel vm = new RiskMitigationViewModel();

            vm.MitigationUnit = db.MitigationUnits.Where(m => m.MitigationId == MitigationId).ToList();
            vm.RiskMitigation = db.RiskMitigations.Single(m => m.MitigationId == MitigationId);

            vm.DivisionTable = from a in db.Divisions
                    join
                    b in db.MitigationUnits
                    on a.DivisionId equals b.DivisionId
                    where b.MitigationId == MitigationId
                    select new divisionTable
                    {
                        DivisionId = a.DivisionId,
                        DivisionName = a.DivisionName,
                        MitigationId = b.MitigationId,
                        MitigationUnitId = b.MitigationUnitId
                    };

            return View(vm);
        }