Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the RiskNonMoneyImpacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRiskNonMoneyImpacts(RiskNonMoneyImpact riskNonMoneyImpact)
 {
     base.AddObject("RiskNonMoneyImpacts", riskNonMoneyImpact);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new RiskNonMoneyImpact object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="riskId">Initial value of the RiskId property.</param>
 /// <param name="impactDetailId">Initial value of the ImpactDetailId property.</param>
 /// <param name="impactTypeId">Initial value of the ImpactTypeId property.</param>
 /// <param name="impactLevelId">Initial value of the ImpactLevelId property.</param>
 public static RiskNonMoneyImpact CreateRiskNonMoneyImpact(global::System.Int32 id, global::System.Int32 riskId, global::System.Int32 impactDetailId, global::System.Int32 impactTypeId, global::System.Int32 impactLevelId)
 {
     RiskNonMoneyImpact riskNonMoneyImpact = new RiskNonMoneyImpact();
     riskNonMoneyImpact.Id = id;
     riskNonMoneyImpact.RiskId = riskId;
     riskNonMoneyImpact.ImpactDetailId = impactDetailId;
     riskNonMoneyImpact.ImpactTypeId = impactTypeId;
     riskNonMoneyImpact.ImpactLevelId = impactLevelId;
     return riskNonMoneyImpact;
 }
Exemplo n.º 3
0
        public ActionResult ImpactNonMoneySelect(ImpactSelectViewModel vm, int id)
        {
            if (vm.ImpactTypeId != 0 && vm.ImpactLeveliId != 0)
            {
                ImpactDetail detail = db.ImpactDetails.
                    Where(p => p.ImpactTypeId == vm.ImpactTypeId &&
                               p.ImpactLevelId == vm.ImpactLeveliId).FirstOrDefault();
                RiskNonMoneyImpact nmImpact = db.RiskNonMoneyImpacts.
                    Where(p => p.RiskId == id &&
                               p.ImpactTypeId == vm.ImpactTypeId).FirstOrDefault();
                if (nmImpact == null)
                {
                    nmImpact = new RiskNonMoneyImpact();
                    nmImpact.RiskId = id;
                    nmImpact.ImpactDetailId = detail.ImpactDetailId;
                    nmImpact.ImpactTypeId = vm.ImpactTypeId;
                    nmImpact.ImpactLevelId = vm.ImpactLeveliId;
                    db.RiskNonMoneyImpacts.AddObject(nmImpact);
                }
                else
                {
                    nmImpact.ImpactDetailId = detail.ImpactDetailId;
                    nmImpact.ImpactLevelId = vm.ImpactLeveliId;
                }
                db.SaveChanges();

                var maxLevelId = db.RiskNonMoneyImpacts.Where(p => p.RiskId == id).Max(p => p.ImpactLevelId);
                var risk = db.Risks.Where(p => p.RiskId == id).FirstOrDefault();
                risk.ImpactLevelId = maxLevelId;
                Utils.CalcRiskLevel(risk);
                db.SaveChanges();
                return RedirectToAction("ImpactNonMoneyList", new { id = id });
            }
            if (vm.ImpactTypeId == 0)
                ModelState.AddModelError("", "Dampak harus diisi");
            if (vm.ImpactLeveliId == 0)
                ModelState.AddModelError("", "Tingkat Dampak harus diisi");
            vm.Risk = db.Risks.Where(p => p.RiskId == id).FirstOrDefault();
            vm.ImpactCats = db.ImpactCats;
            vm.ImpactLevels = db.ImpactLevels;
            vm.ImpactDetails = db.ImpactDetails.Where(p => p.ImpactTypeId == vm.ImpactTypeId);
            return View(vm);
        }