private SeInsurAccountDoc CreateAccount(String userId, Mimshak item, Mutzar product, HeshbonOPolisa policy) { SeInsurAccountDoc account; try { Double totalSchumKitzvatZikna = 0; policy.YitraLefiGilPrisha.Kupot.Kupa.ForEach(k => { totalSchumKitzvatZikna += k.SchumKitzvatZikna.GetValueOrDefault(); }); double?totalSavings = 0; double?deathInsuranceAmount = 0; policy.Kisuim.ForEach(kisui => { kisui.ZihuiKisui.ForEach(zihui => { totalSavings = zihui.SchumeiBituahYesodi?.SchumBituahLemavet.GetValueOrDefault(); deathInsuranceAmount = zihui.SchumeiBituahYesodi?.TikratGagHatamLemikreMavet.GetValueOrDefault(); }); }); var employeerId = policy.PirteiTaktziv.PirteiOved.MprMaasikBeYatzran; var employerIdentity = product.NetuneiMutzar.YeshutMaasik.Where(ym => ym.MprMaasikBeYatzran.Equals(employeerId)).FirstOrDefault(); account = new SeInsurAccountDoc { UserId = userId, ProviderName = item.YeshutYatzran?.ShemYatzran, EmployerName = employerIdentity?.ShemMaasik, PlanName = policy.ShemTohnit, PolicyId = policy.MisparPolisaOheshbon, PolicyStatus = policy.StatusPolisaOcheshbon == 1 ? PolicyStatus.Active : PolicyStatus.Inactive, TotalSavings = totalSavings, EoyBalance = policy.PirteiTaktziv.PerutYitrotLesofShanaKodemet.YitratSofShana.GetValueOrDefault(), ExpectedRetirementSavingsNoPremium = policy.YitraLefiGilPrisha.TzviratChisachonChazuyaLeloPremiyot.GetValueOrDefault(), MonthlyRetirementPensionNoPremium = policy.YitraLefiGilPrisha.Kupot.Kupa.LastOrDefault()?.SchumKitzvatZikna.GetValueOrDefault(), ExpectedRetirementSavings = policy.YitraLefiGilPrisha.TzviratChisachonChazuyaLeloPremiyot.GetValueOrDefault(), MonthlyRetirementPension = totalSchumKitzvatZikna, DepositFee = policy.PirteiTaktziv.PerutMasluleiHashkaa.FirstOrDefault()?.SheurDmeiNihulHafkada.GetValueOrDefault(), SavingFee = policy.PirteiTaktziv.PerutHotzaot.MivneDmeiNihul.PerutMivneDmeiNihul.FirstOrDefault()?.SheurDmeiNihul.GetValueOrDefault(), YearRevenue = policy.Tsua.SheurTsuaNeto.GetValueOrDefault(), DeathInsuranceMonthlyAmount = 0, DeathInsuranceAmount = deathInsuranceAmount, PolicyOpeningDate = Reader.ConvertStringToDate(policy.TaarichHitztarfutMutzar), ValidationDate = Reader.ConvertStringToDate(policy.TaarichNechonut) }; } catch (Exception e) { Console.WriteLine(e); throw; } return(account); }
public async Task AddAccount(SeInsurAccountDoc item) { try { await _context.InsurAccounts.InsertOneAsync(item); } catch (Exception ex) { // log or manage the exception throw ex; } }
public async Task <bool> UpdateAccount(Guid id, SeInsurAccountDoc account) { try { ReplaceOneResult actionResult = await _context.InsurAccounts.ReplaceOneAsync(a => a.Id.Equals(id), account, new UpdateOptions { IsUpsert = true }); return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0); } catch (Exception ex) { // log or manage the exception throw ex; }; }