Ejemplo n.º 1
0
 /// <summary>
 /// takes each element within a List of InvestorPcap and inserts or updates the database
 /// </summary>
 /// <param name="pcaps">List<InvestorPcap></InvestorPcap> </param>
 public static void UpdateOrInsertPcaps(List <InvestorPcap> pcaps)
 {
     if (pcaps.Count() == 0)
     {
         return;
     }
     using (HqTrustData dbContext = new HqTrustData())
     {
         foreach (InvestorPcap pcap in pcaps)
         {
             if (pcap.Id == 0)
             {
                 dbContext.InvestorPcaps.Add(pcap);
             }
             else
             {
                 InvestorPcap existingPcap = dbContext.InvestorPcaps.FirstOrDefault(p => p.Id == pcap.Id);
                 if (existingPcap == null)
                 {
                     throw new Exception($"Das PCAP mit der Id {pcap.Id} wurde nicht gefunden");
                 }
                 dbContext.Entry(existingPcap).CurrentValues.SetValues(pcap);
             }
         }
         try
         {
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception($"Fehler beim Ändern der Tabelle InvestorPcaps. {ex.InnerException.Message}");
         }
     }
 }
Ejemplo n.º 2
0
 public static void UpdateInitiator(Initiator initiator)
 {
     if (initiator.Id == 0)
     {
         // add new Iniitiator
         using (HqTrustData dbContext = new HqTrustData())
         {
             dbContext.Initiators.Add(initiator);
             try
             {
                 dbContext.SaveChanges();
                 return;
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Hinzufügen eines Initiators. {ex.InnerException.Message}");
             }
         }
     }
     else
     {
         using (HqTrustData dbContext = new HqTrustData())
         {
             Initiator oldInitiator = dbContext.Initiators.FirstOrDefault(i => i.Id == initiator.Id);
             if (oldInitiator == null)
             {
                 throw new Exception($"Fehler beim Lesen des Initiators mit der Id {initiator.Id.ToString()}");
             }
             dbContext.Entry(oldInitiator).CurrentValues.SetValues(initiator);
             try
             {
                 dbContext.SaveChanges();
                 return;
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Ändern eines Initiators. {ex.InnerException.Message}");
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void UpdateInvestorCashFlow(InvestorCashFlow cashflow)
 {
     if (cashflow.Id == 0)
     {
         using (HqTrustData dbContext = new HqTrustData())
         {
             dbContext.InvestorCashFlows.Add(cashflow);
             try
             {
                 dbContext.SaveChanges();
                 return;
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Einfügen eines CashFlows. {ex.InnerException.Message}");
             }
         }
     }
     else
     {
         using (HqTrustData dbContext = new HqTrustData())
         {
             InvestorCashFlow cf = dbContext.InvestorCashFlows.FirstOrDefault(c => c.Id == cashflow.Id);
             if (cf == null)
             {
                 throw new Exception($"Fehler beim Lesen eines CashFlows mit der Id {cashflow.Id}.");
             }
             dbContext.Entry(cf).CurrentValues.SetValues(cashflow);
             try
             {
                 dbContext.SaveChanges();
                 return;
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Ändern des CashFlows mit der Id {cashflow.Id}. {ex.InnerException.Message}");
             }
         }
     }
 }
Ejemplo n.º 4
0
 public static void UpdatePeFund(PeFund fund)
 {
     using (HqTrustData dbContext = new HqTrustData())
     {
         PeFund updatePeFund = dbContext.PeFunds.FirstOrDefault(i => i.Id == fund.Id);
         if (updatePeFund == null)
         {
             throw new Exception($"Der Fund mit der Id {fund.Id} wurde nicht in der Datenbank gefunden");
         }
         dbContext.Entry(updatePeFund).CurrentValues.SetValues(fund);
         try
         {
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception($"Fehler beim Ändern eines PeFunds: {ex.InnerException.Message}");
         }
     }
     UpdateBankAccountsForPeFund(fund);
     UpdateDocumentAndLettersForPeFund(fund);
 }
Ejemplo n.º 5
0
 public void InsertOrUpdateInvestorPcap(InvestorPcap pcap)
 {
     if (pcap.Id == 0)
     {
         // inser new record
         using (HqTrustData dbContext = new HqTrustData())
         {
             dbContext.InvestorPcaps.Add(pcap);
             try
             {
                 dbContext.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Eintragen eines PCap. {ex.InnerException.Message}");
             }
         }
     }
     else
     {
         using (HqTrustData dbContext = new HqTrustData())
         {
             InvestorPcap existingPcap = dbContext.InvestorPcaps.FirstOrDefault(p => p.Id == pcap.Id);
             if (existingPcap == null)
             {
                 throw new Exception($"Ein NAV für das Commitment {pcap.InvestorCommitmentId} mit dem Datum {pcap.AsOfDate:d} wurde nicht gefunden.");
             }
             dbContext.Entry(existingPcap).CurrentValues.SetValues(pcap);
             try
             {
                 dbContext.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw new Exception($"Fehler beim Ändern eines PCap. {ex.InnerException.Message}");
             }
         }
     }
 }
Ejemplo n.º 6
0
 public void UpdateInvestor(Investor investor)
 {
     using (HqTrustData dbContext = new HqTrustData())
     {
         Investor updateInvestor = dbContext.Investors.FirstOrDefault(i => i.Id == investor.Id);
         if (updateInvestor == null)
         {
             throw new Exception($"Der Investor mit der Id {investor.Id} wurde nicht in der Datenbank gefunden");
         }
         dbContext.Entry(updateInvestor).CurrentValues.SetValues(investor);
         try
         {
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception($"Fehler beim Ändern eines Investors: {ex.InnerException.Message}");
         }
     }
     UpdateBankAccountsForInvestor(investor);
     UpdateDocumentAndLettersForInvestor(investor);
     UpdateTaxInformationsForInvestor(investor);
     UpdateEMailAccountsForInvestor(investor);
 }