Пример #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();
     }
 }
Пример #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();
     }
 }
 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();
     }
 }
Пример #4
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();
     }
 }
Пример #5
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 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();
     }
 }
 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();
     }
 }
Пример #10
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();
     }
 }
Пример #11
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();
            }
        }
Пример #12
0
 private void UpdateContactCommunication(DeepBlueEntities context, Contact dealContact, Contact newDealContact)
 {
     EntityKey key;
     object originalItem;
     // Update contact communication
     foreach (var contactCommunication in dealContact.ContactCommunications) {
         key = default(EntityKey);
         originalItem = null;
         key = context.CreateEntityKey("ContactCommunications", contactCommunication);
         if (context.TryGetObjectByKey(key, out originalItem)) {
             context.ApplyCurrentValues(key.EntitySetName, contactCommunication);
             key = default(EntityKey);
             originalItem = null;
             key = context.CreateEntityKey("Communications", contactCommunication.Communication);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, contactCommunication.Communication);
             }
         }
         else {
             Contact contact = null;
             if (newDealContact != null) {
                 contact = newDealContact;
             }
             else {
                 contact = context.ContactsTable.SingleOrDefault(cont => cont.ContactID == contactCommunication.Contact.ContactID);
             }
             if (contact != null) {
                 contact.ContactCommunications.Add(new ContactCommunication {
                     CreatedBy = contactCommunication.CreatedBy,
                     CreatedDate = contactCommunication.CreatedDate,
                     EntityID = contactCommunication.EntityID,
                     LastUpdatedBy = contactCommunication.LastUpdatedBy,
                     LastUpdatedDate = contactCommunication.LastUpdatedDate,
                     Communication = new Communication {
                         CommunicationComment = contactCommunication.Communication.CommunicationComment,
                         CommunicationTypeID = contactCommunication.Communication.CommunicationTypeID,
                         CommunicationValue = contactCommunication.Communication.CommunicationValue,
                         CreatedBy = contactCommunication.Communication.CreatedBy,
                         CreatedDate = contactCommunication.Communication.CreatedDate,
                         EntityID = contactCommunication.Communication.EntityID,
                         IsPreferred = contactCommunication.Communication.IsPreferred,
                         LastFourPhone = contactCommunication.Communication.LastFourPhone,
                         LastUpdatedBy = contactCommunication.Communication.LastUpdatedBy,
                         LastUpdatedDate = contactCommunication.Communication.LastUpdatedDate,
                         Listed = contactCommunication.Communication.Listed
                     }
                 });
             }
         }
     }
 }