Example #1
0
 public void SaveCapitalCall(CapitalCall capitalCall)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (capitalCall.CapitalCallID == 0) {
             context.CapitalCalls.AddObject(capitalCall);
         } else {
             //Update capitalCall,capitalCall account values
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key;
             object originalItem;
             foreach (var item in capitalCall.CapitalCallLineItems) {
                 key = default(EntityKey);
                 key = context.CreateEntityKey("CapitalCallLineItems", item);
                 if (context.TryGetObjectByKey(key, out originalItem)) {
                     context.ApplyCurrentValues(key.EntitySetName, item);
                 }
             }
             key = default(EntityKey);
             key = context.CreateEntityKey("CapitalCalls", capitalCall);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, capitalCall);
             }
         }
         context.SaveChanges();
     }
 }
Example #2
0
 public void SaveEntityMenu(EntityMenu entityMenu)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (entityMenu.EntityMenuID == 0) {
             if (context.EntityMenus.Count() > 0)
                 entityMenu.SortOrder = context.EntityMenus.Select(em => em.EntityMenuID).Max() + 1;
             else
                 entityMenu.SortOrder = 1;
             context.EntityMenus.AddObject(entityMenu);
         }
         else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("EntityMenus", entityMenu);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, entityMenu);
             }
         }
         context.SaveChanges();
     }
 }
Example #3
0
 public void DeleteFundRateSchedule(int id)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         FundRateSchedule rateSchedule = context.FundRateSchedulesTable
                                              .SingleOrDefault(schedule => schedule.FundRateScheduleID == id);
         context.FundRateSchedules.DeleteObject(rateSchedule);
         context.SaveChanges();
     }
 }
Example #4
0
 public void SaveModule(MODULE module)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (module.ModuleID == 0) {
             context.MODULEs.AddObject(module);
         } else {
             context.MODULEsTable.SingleOrDefault(entityType => entityType.ModuleID == module.ModuleID);
             context.MODULEs.ApplyCurrentValues(module);
         }
         context.SaveChanges();
     }
 }
Example #5
0
 public bool DeleteAccountingEntryTemplate(int id)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         AccountingEntryTemplate accountingEntryTemplate = context.AccountingEntryTemplatesTable.FirstOrDefault(virAcc => virAcc.AccountingEntryTemplateID == id);
         if (accountingEntryTemplate != null) {
             if (accountingEntryTemplate.AccountingEntries.Count() == 0) {
                 context.AccountingEntryTemplates.DeleteObject(accountingEntryTemplate);
                 context.SaveChanges();
                 return true;
             }
         }
         return false;
     }
 }
Example #6
0
 public void DeleteManagementFeeRateSchedule(int id)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         ManagementFeeRateSchedule rateSchedule = context.ManagementFeeRateSchedules
                                                 .Include("ManagementFeeRateScheduleTiers")
                                                 .EntityFilter()
                                                 .SingleOrDefault(schedule => schedule.ManagementFeeRateScheduleID == id);
         foreach (var tier in rateSchedule.ManagementFeeRateScheduleTiers) {
             context.ManagementFeeRateScheduleTiers.DeleteObject(tier);
         }
         context.ManagementFeeRateSchedules.DeleteObject(rateSchedule);
         context.SaveChanges();
     }
 }
Example #7
0
 public bool DeleteVirtualAccount(int id)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         VirtualAccount virtualAccount = context.VirtualAccountsTable.FirstOrDefault(virAcc => virAcc.VirtualAccountID == id);
         if (virtualAccount != null) {
             foreach (var virAcc in virtualAccount.VirtualAccount1) {
                 virAcc.ActualAccountID = null;
             }
             context.VirtualAccounts.DeleteObject(virtualAccount);
             context.SaveChanges();
             return true;
         }
         return false;
     }
 }
 public void SaveUnderlyingDirectDocument(UnderlyingDirectDocument underlyingDirectDocument)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (underlyingDirectDocument.UnderlyingDirectDocumentID == 0) {
             context.UnderlyingDirectDocuments.AddObject(underlyingDirectDocument);
         }
         else {
             EntityKey key;
             object originalItem;
             UnderlyingDirectDocument updateUnderlyingDirectDocument = context.UnderlyingDirectDocumentsTable.SingleOrDefault(deepblueUnderlyingDirectDocument => deepblueUnderlyingDirectDocument.UnderlyingDirectDocumentID == underlyingDirectDocument.UnderlyingDirectDocumentID);
             /* Contact & Communication */
             key = default(EntityKey);
             originalItem = null;
             key = context.CreateEntityKey("Files", underlyingDirectDocument.File);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, underlyingDirectDocument.File);
             }
             else {
                 updateUnderlyingDirectDocument.File = new Models.Entity.File {
                     CreatedBy = underlyingDirectDocument.File.CreatedBy,
                     CreatedDate = underlyingDirectDocument.File.CreatedDate,
                     EntityID = underlyingDirectDocument.File.EntityID,
                     FileID = underlyingDirectDocument.File.FileID,
                     FileName = underlyingDirectDocument.File.FileName,
                     FilePath = underlyingDirectDocument.File.FilePath,
                     FileTypeID = underlyingDirectDocument.File.FileTypeID,
                     LastUpdatedBy = underlyingDirectDocument.File.LastUpdatedBy,
                     LastUpdatedDate = underlyingDirectDocument.File.LastUpdatedDate,
                     Size = underlyingDirectDocument.File.Size
                 };
             }
             // Define an ObjectStateEntry and EntityKey for the current object.
             key = default(EntityKey);
             originalItem = null;
             key = context.CreateEntityKey("UnderlyingDirectDocuments", underlyingDirectDocument);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, underlyingDirectDocument);
             }
         }
         context.SaveChanges();
     }
 }
Example #9
0
 public void SaveVirtualAccount(VirtualAccount virtualAccount)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (virtualAccount.VirtualAccountID == 0) {
             context.VirtualAccounts.AddObject(virtualAccount);
         } else {
             EntityKey key;
             object originalItem;
             originalItem = null;
             key = default(EntityKey);
             key = context.CreateEntityKey("VirtualAccounts", virtualAccount);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, virtualAccount);
             }
         }
         context.SaveChanges();
     }
 }
Example #10
0
 public void SaveUser(USER user)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (user.UserID == 0) {
             context.USERs.AddObject(user);
         } else {
             //Update user,user account values
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key;
             object originalItem;
             key = default(EntityKey);
             key = context.CreateEntityKey("USERs", user);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, user);
             }
         }
         context.SaveChanges();
     }
 }
 public void SaveUnderlyingFundCapitalCallLineItem(UnderlyingFundCapitalCallLineItem underlyingFundCapitalCallLineItem)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (underlyingFundCapitalCallLineItem.UnderlyingFundCapitalCallLineItemID == 0) {
             context.UnderlyingFundCapitalCallLineItems.AddObject(underlyingFundCapitalCallLineItem);
         }
         else {
             //Update underlyingFundCapitalCallLineItem,underlyingFundCapitalCallLineItem account values
             //Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key;
             object originalItem;
             key = default(EntityKey);
             key = context.CreateEntityKey("UnderlyingFundCapitalCallLineItems", underlyingFundCapitalCallLineItem);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, underlyingFundCapitalCallLineItem);
             }
         }
         context.SaveChanges();
     }
 }
 public void SaveCommunicationGrouping(CommunicationGrouping communicationGrouping)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (communicationGrouping.CommunicationGroupingID == 0) {
             context.CommunicationGroupings.AddObject(communicationGrouping);
         } else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("CommunicationGroupings", communicationGrouping);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, communicationGrouping);
             }
         }
         context.SaveChanges();
     }
 }
 public void SaveManagementFeeRateSchedule(ManagementFeeRateSchedule managementFeeRateSchedule)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (managementFeeRateSchedule.ManagementFeeRateScheduleID == 0) {
             context.ManagementFeeRateSchedules.AddObject(managementFeeRateSchedule);
         }
         /*else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("ManagementFeeRateSchedules", managementFeeRateSchedule);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, managementFeeRateSchedule);
             }
         }*/
         context.SaveChanges();
     }
 }
 public void SaveUnderlyingDirectLastPrice(UnderlyingDirectLastPrice underlyingDirectLastPrice)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (underlyingDirectLastPrice.UnderlyingDirectLastPriceID == 0) {
             context.UnderlyingDirectLastPrices.AddObject(underlyingDirectLastPrice);
         }
         else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("UnderlyingDirectLastPrices", underlyingDirectLastPrice);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, underlyingDirectLastPrice);
             }
         }
         context.SaveChanges();
     }
 }
Example #15
0
 public void SaveFundActivityHistory(FundActivityHistory fundActivityHistory)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (fundActivityHistory.FundActivityHistoryID == 0) {
             context.FundActivityHistories.AddObject(fundActivityHistory);
         }
         else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("FundActivityHistories", fundActivityHistory);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, fundActivityHistory);
             }
         }
         context.SaveChanges();
     }
 }
 public void SaveDealUnderlyingFundAdjustment(DealUnderlyingFundAdjustment dealUnderlyingFund)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (dealUnderlyingFund.DealUnderlyingFundAdjustmentID == 0) {
             context.DealUnderlyingFundAdjustments.AddObject(dealUnderlyingFund);
         }
         else {
             // Define an ObjectStateEntry and EntityKey for the current object.
             EntityKey key = default(EntityKey);
             object originalItem = null;
             key = context.CreateEntityKey("DealUnderlyingFundAdjustments", dealUnderlyingFund);
             // Get the original item based on the entity key from the context
             // or from the database.
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 // Call the ApplyCurrentValues method to apply changes
                 // from the updated item to the original version.
                 context.ApplyCurrentValues(key.EntitySetName, dealUnderlyingFund);
             }
         }
         context.SaveChanges();
     }
 }
Example #17
0
        public void CreateAccountingEntry(DeepBlue.Models.Accounting.Enums.AccountingTransactionType accountingTransactionType, int fundID, int entityID, IAccountable accountableItem, decimal? amount = null, int? accountingTransactionSubTypeID = null)
        {
            DeepBlueEntities context = new DeepBlueEntities();
            decimal amt = amount.HasValue ? amount.Value : (accountableItem.Amount.HasValue ? accountableItem.Amount.Value : 0);
            var query = from aet in context.AccountingEntryTemplates
                        where aet.EntityID == entityID && aet.AccountingTransactionTypeID == (int)accountingTransactionType
                        select aet;
            // See if there are any templates specific to the Fund
            List<AccountingEntryTemplate> templates = query.Where(x => x.FundID == fundID).ToList();
            if (templates.Count <= 0) {
                // No templates found for this fund.. try to see if there is an Entity level template available
                templates = query.Where(x => x.FundID == null).ToList();
            }

            if (templates.Count > 0) {
                // Filter on the sub type
                if (accountingTransactionSubTypeID.HasValue) {
                    //var templatesWithSubType = templates.Where(x => x.AccountingTransactionSubTypeID == accountingTransactionSubTypeID.Value).ToList();
                    //if (templatesWithSubType.Count > 0) {
                    //    templates = templatesWithSubType;
                    //}
                }

                List<AccountingEntry> accountingEntries = new List<AccountingEntry>();
                foreach (AccountingEntryTemplate template in templates) {
                    // each template will result in an accounting entry
                    AccountingEntry entry = new AccountingEntry();
                    entry.AccountingEntryTemplateID = template.AccountingEntryTemplateID;
                    DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType amountType = (DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType)template.AccountingEntryAmountTypeID;
                    switch (amountType) {
                        case DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType.FixedAmount:
                            entry.Amount = Convert.ToDecimal(template.AccountingEntryAmountTypeData);
                            break;
                        case DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType.Percentage:
                            decimal percent = Convert.ToDecimal(template.AccountingEntryAmountTypeData);
                            entry.Amount = (percent * amt) / 100;
                            break;
                        case DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType.Field:
                            // Use reflection to get the amount
                            PropertyInfo property = accountableItem.GetType().GetProperties().Where(x => x.Name == template.AccountingEntryAmountTypeData).FirstOrDefault();
                            object val = property.GetValue(accountableItem, null);
                            if (val != null) {
                                entry.Amount = Convert.ToDecimal(val);
                            }
                            break;
                        case DeepBlue.Models.Accounting.Enums.AccountingEntryAmountType.Custom:
                            break;
                        default:
                            entry.Amount = amt;
                            break;
                    }

                    entry.TraceID = accountableItem.TraceID;
                    entry.AttributedTo = accountableItem.AttributedTo;
                    entry.AttributedToName = accountableItem.AttributedToName;
                    entry.AttributedToType = accountableItem.AttributedToType;
                    entry.FundID = fundID;
                    entry.EntityID = entityID;
                    context.AccountingEntries.AddObject(entry);
                    context.SaveChanges();
                }
            }
        }
Example #18
0
 public static void ConvertInvestorViaDB()
 {
     ImportErrors = new List<KeyValuePair<Models.Entity.Investor, Exception>>();
     TotalImportRecords = 0;
     RecordsImportedSuccessfully = 0;
     List<DeepBlue.Models.Entity.Investor> dbInvestors = ConvertBlueToDeepBlue();
     LogErrors(Errors);
     foreach (DeepBlue.Models.Entity.Investor investor in dbInvestors) {
         TotalImportRecords++;
         using (DeepBlueEntities context = new DeepBlueEntities()) {
             try {
                 context.Investors.AddObject(investor);
                 context.SaveChanges();
                 RecordsImportedSuccessfully++;
             }
             catch (Exception ex) {
                 ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Investor, Exception>(investor, ex));
             }
         }
     }
     LogErrors(ImportErrors);
 }
Example #19
0
        public void SaveDeal(Deal deal)
        {
            using (DeepBlueEntities context = new DeepBlueEntities()) {
                if (deal.DealID == 0) {
                    context.Deals.AddObject(deal);
                }
                else {
                    Deal updateDeal = context.DealsTable.SingleOrDefault(findDeal => findDeal.DealID == deal.DealID);
                    // Define an ObjectStateEntry and EntityKey for the current object.
                    EntityKey key;
                    object originalItem;

                    if (deal.Partner != null) {
                        // Update partner entity
                        originalItem = null;
                        key = default(EntityKey);
                        key = context.CreateEntityKey("Partners", deal.Partner);
                        if (context.TryGetObjectByKey(key, out originalItem)) {
                            context.ApplyCurrentValues(key.EntitySetName, deal.Partner);
                        }
                        else {
                            updateDeal.Partner = new Partner {
                                CreatedBy = deal.Partner.CreatedBy,
                                CreatedDate = deal.Partner.CreatedDate,
                                EntityID = deal.Partner.EntityID,
                                LastUpdatedBy = deal.Partner.LastUpdatedBy,
                                LastUpdatedDate = deal.Partner.LastUpdatedDate,
                                PartnerID = deal.Partner.PartnerID,
                                PartnerName = deal.Partner.PartnerName
                            };
                        }
                    }

                    /* if (deal.Contact != null) {
                        // Update contact entity
                        originalItem = null;
                        key = default(EntityKey);
                        key = context.CreateEntityKey("Contacts", deal.Contact);
                        if (context.TryGetObjectByKey(key, out originalItem)) {
                            context.ApplyCurrentValues(key.EntitySetName, deal.Contact);
                        }
                        else {
                            updateDeal.Contact = new Contact {
                                ContactID = deal.Contact.ContactID,
                                ContactName = deal.Contact.ContactName,
                                CreatedBy = deal.Contact.CreatedBy,
                                CreatedDate = deal.Contact.CreatedDate,
                                Designation = deal.Contact.Designation,
                                EntityID = deal.Contact.EntityID,
                                FirstName = deal.Contact.FirstName,
                                LastName = deal.Contact.LastName,
                                LastUpdatedBy = deal.Contact.LastUpdatedBy,
                                LastUpdatedDate = deal.Contact.LastUpdatedDate,
                                MiddleName = deal.Contact.MiddleName,
                                ReceivesDistributionNotices = deal.Contact.ReceivesDistributionNotices,
                                ReceivesFinancials = deal.Contact.ReceivesFinancials,
                                ReceivesInvestorLetters = deal.Contact.ReceivesInvestorLetters,
                                ReceivesK1 = deal.Contact.ReceivesK1
                            };
                        }
                        // Update contact communication
                        UpdateContactCommunication(context, deal.Contact, updateDeal.Contact);
                    }
                     * */

                    if (deal.Contact1 != null) {
                        // Update seller contact entity
                        originalItem = null;
                        key = default(EntityKey);
                        key = context.CreateEntityKey("Contacts", deal.Contact1);
                        if (context.TryGetObjectByKey(key, out originalItem)) {
                            context.ApplyCurrentValues(key.EntitySetName, deal.Contact1);
                        }
                        else {
                            updateDeal.Contact1 = new Contact {
                                ContactID = deal.Contact1.ContactID,
                                ContactName = deal.Contact1.ContactName,
                                CreatedBy = deal.Contact1.CreatedBy,
                                CreatedDate = deal.Contact1.CreatedDate,
                                Designation = deal.Contact1.Designation,
                                EntityID = deal.Contact1.EntityID,
                                FirstName = deal.Contact1.FirstName,
                                LastName = deal.Contact1.LastName,
                                LastUpdatedBy = deal.Contact1.LastUpdatedBy,
                                LastUpdatedDate = deal.Contact1.LastUpdatedDate,
                                MiddleName = deal.Contact1.MiddleName,
                                ReceivesDistributionNotices = deal.Contact1.ReceivesDistributionNotices,
                                ReceivesFinancials = deal.Contact1.ReceivesFinancials,
                                ReceivesInvestorLetters = deal.Contact1.ReceivesInvestorLetters,
                                ReceivesK1 = deal.Contact1.ReceivesK1
                            };
                        }
                        // Update seller contact communication
                        UpdateContactCommunication(context, deal.Contact1, updateDeal.Contact1);
                    }

                    key = context.CreateEntityKey("Deals", deal);
                    // Get the original item based on the entity key from the context
                    // or from the database.
                    if (context.TryGetObjectByKey(key, out originalItem)) {
                        // Call the ApplyCurrentValues method to apply changes
                        // from the updated item to the original version.
                        context.ApplyCurrentValues(key.EntitySetName, deal);
                    }
                }
                context.SaveChanges();
            }
        }
Example #20
0
 public bool Delete(int investorId)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         DeepBlue.Models.Entity.Investor deepBlueInvestor = context.InvestorsTable.SingleOrDefault(investor => investor.InvestorID == investorId);
         if (deepBlueInvestor != null) {
             if (deepBlueInvestor.CapitalCallLineItems.Count > 0 || deepBlueInvestor.CapitalDistributionLineItems.Count > 0) {
                 return false;
             }
             List<InvestorAddress> investorAddresses = deepBlueInvestor.InvestorAddresses.ToList();
             foreach (var investorAddress in investorAddresses) {
                 context.Addresses.DeleteObject(investorAddress.Address);
                 context.InvestorAddresses.DeleteObject(investorAddress);
             }
             List<InvestorAccount> investorAccounts = deepBlueInvestor.InvestorAccounts.ToList();
             foreach (var investorAccount in investorAccounts) {
                 context.InvestorAccounts.DeleteObject(investorAccount);
             }
             List<InvestorContact> investorContacts = deepBlueInvestor.InvestorContacts.ToList();
             foreach (var investorContact in investorContacts) {
                 List<ContactAddress> contactAddresses = investorContact.Contact.ContactAddresses.ToList();
                 foreach (var contactAddress in contactAddresses) {
                     context.Addresses.DeleteObject(contactAddress.Address);
                     context.ContactAddresses.DeleteObject(contactAddress);
                 }
                 List<ContactCommunication> contactCommunications = investorContact.Contact.ContactCommunications.ToList();
                 foreach (var contactCommunication in contactCommunications) {
                     context.Communications.DeleteObject(contactCommunication.Communication);
                     context.ContactCommunications.DeleteObject(contactCommunication);
                 }
                 context.Contacts.DeleteObject(investorContact.Contact);
                 context.InvestorContacts.DeleteObject(investorContact);
             }
             List<InvestorCommunication> investorCommunications = deepBlueInvestor.InvestorCommunications.ToList();
             foreach (var investorCommunication in investorCommunications) {
                 context.Communications.DeleteObject(investorCommunication.Communication);
                 context.InvestorCommunications.DeleteObject(investorCommunication);
             }
             List<InvestorFund> investorFunds = deepBlueInvestor.InvestorFunds.ToList();
             foreach (var investorFund in investorFunds) {
                 List<InvestorFundTransaction> investorFundTransactions = investorFund.InvestorFundTransactions.ToList();
                 foreach (var investorFundTransaction in investorFundTransactions) {
                     context.InvestorFundTransactions.DeleteObject(investorFundTransaction);
                 }
                 context.InvestorFunds.DeleteObject(investorFund);
             }
             List<InvestorFundDocument> investorFundDocuments = deepBlueInvestor.InvestorFundDocuments.ToList();
             foreach (var document in investorFundDocuments) {
                 context.InvestorFundDocuments.DeleteObject(document);
             }
             context.Investors.DeleteObject(deepBlueInvestor);
             context.SaveChanges();
         }
         return true;
     }
 }
Example #21
0
 public bool DeleteInvestorContact(int investorContactId)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         InvestorContact investorContact = context.InvestorContactsTable.SingleOrDefault(contact => contact.InvestorContactID == investorContactId);
         if (investorContact != null) {
             List<ContactAddress> investorContactAddresses = investorContact.Contact.ContactAddresses.ToList();
             foreach (var contactAddress in investorContactAddresses) {
                 context.Addresses.DeleteObject(contactAddress.Address);
                 context.ContactAddresses.DeleteObject(contactAddress);
             }
             List<ContactCommunication> contactCommunications = investorContact.Contact.ContactCommunications.ToList();
             foreach (var contactCommunication in contactCommunications) {
                 context.Communications.DeleteObject(contactCommunication.Communication);
                 context.ContactCommunications.DeleteObject(contactCommunication);
             }
             context.Contacts.DeleteObject(investorContact.Contact);
             context.InvestorContacts.DeleteObject(investorContact);
             context.SaveChanges();
             return true;
         }
         else {
             return false;
         }
     }
 }
Example #22
0
 public bool DeleteInvestorAccount(int investorAccountId)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         InvestorAccount investorAccount = context.InvestorAccountsTable.SingleOrDefault(account => account.InvestorAccountID == investorAccountId);
         if (investorAccount != null) {
             context.InvestorAccounts.DeleteObject(investorAccount);
             context.SaveChanges();
             return true;
         }
         else {
             return false;
         }
     }
 }