public async Task <IActionResult> Edit(Guid id, [Bind("ID,Name")] PremiumType premiumType) { if (id != premiumType.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(premiumType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PremiumTypeExists(premiumType.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(premiumType)); }
public static Plan WithPremium(this Plan plan, PremiumType premiumType = PremiumType.Individual, Frequency frequency = Frequency.Biweekly, decimal? cost = null) { plan.Premiums.Add(new Premium { Cost = cost ?? RandomData.DollarAmount, Frequency = frequency, Type = premiumType }); return plan; }
/// <summary> /// Get the <see cref="PremiumType" /> for the currently connected user. /// </summary> /// <returns></returns> /// <exception cref="ResultException"></exception> public PremiumType GetCurrentUserPremiumType() { PremiumType ret = new PremiumType(); Result res = Methods.GetCurrentUserPremiumType(methodsPtr, ref ret); if (res != Result.Ok) { throw new ResultException(res); } return(ret); }
public async Task <IActionResult> Create([Bind("ID,Name")] PremiumType premiumType) { if (ModelState.IsValid) { premiumType.ID = Guid.NewGuid(); _context.Add(premiumType); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(premiumType)); }
public decimal CalculateYearlyCost(Plan plan, decimal totalMedicalCosts, PremiumType premiumType, DeductibleType deductibleType = DeductibleType.Individual) { var premium = plan.Premium(premiumType); var premiumCost = premium.Cost * PremiumMultiplierFactory.GetMultipler(premium.Frequency); var deductibleAmount = plan.Deductible(deductibleType); var costsDuringDeductible = Math.Min(deductibleAmount, totalMedicalCosts); var outOfPocketMax = plan.OutOfPocketMax(deductibleType); var costsUnderOutOfPocketMax = Math.Min((totalMedicalCosts - costsDuringDeductible) * plan.CoinsurancePercentage, outOfPocketMax - deductibleAmount); return premiumCost + costsDuringDeductible + costsUnderOutOfPocketMax; }
/// <summary> /// Receives a PremiumType to convert to a NotificationType /// </summary> /// <param name="type"></param> /// <returns>NotificationType type, or a broken type if any isn't found</returns> public static NotificationType GetType(PremiumType type) { switch (type) { case PremiumType.Ticket: return(NotificationType.Ticket); case PremiumType.Upgrade: return(NotificationType.Upgrade); case PremiumType.Voucher: return(NotificationType.Voucher); default: return(NotificationType.Broken); } }
public Premium Premium(PremiumType premiumType) { return Premiums.SingleOrDefault(p => p.Type == premiumType); }