Exemplo n.º 1
0
        public void SaveUnderlyingFund(UnderlyingFund underlyingFund)
        {
            using (DeepBlueEntities context = new DeepBlueEntities()) {
                if (underlyingFund.UnderlyingtFundID == 0) {
                    context.UnderlyingFunds.AddObject(underlyingFund);
                }
                else {
                    UnderlyingFund updateUnderlyingFund = context.UnderlyingFundsTable.SingleOrDefault(deepblueUnderlyingFund => deepblueUnderlyingFund.UnderlyingtFundID == underlyingFund.UnderlyingtFundID);
                    //Update underlyingFund,underlyingFund account values
                    // Define an ObjectStateEntry and EntityKey for the current object.
                    EntityKey key;
                    object originalItem;

                    if (underlyingFund.Account != null) {
                        /* Account */
                        originalItem = null;
                        key = default(EntityKey);
                        key = context.CreateEntityKey("Accounts", underlyingFund.Account);
                        if (context.TryGetObjectByKey(key, out originalItem)) {
                            context.ApplyCurrentValues(key.EntitySetName, underlyingFund.Account);
                        }
                        else {
                            updateUnderlyingFund.Account = new Account {
                                Account1 = underlyingFund.Account.Account1,
                                AccountNumberCash = underlyingFund.Account.AccountNumberCash,
                                AccountOf = underlyingFund.Account.AccountOf,
                                Attention = underlyingFund.Account.Attention,
                                BankName = underlyingFund.Account.BankName,
                                CreatedBy = underlyingFund.Account.CreatedBy,
                                CreatedDate = underlyingFund.Account.CreatedDate,
                                EntityID = underlyingFund.Account.EntityID,
                                Fax = underlyingFund.Account.Fax,
                                FFCNumber = underlyingFund.Account.FFCNumber,
                                IBAN = underlyingFund.Account.IBAN,
                                IsPrimary = underlyingFund.Account.IsPrimary,
                                LastUpdatedBy = underlyingFund.Account.LastUpdatedBy,
                                LastUpdatedDate = underlyingFund.Account.LastUpdatedDate,
                                Phone = underlyingFund.Account.Phone,
                                Reference = underlyingFund.Account.Reference,
                                Routing = underlyingFund.Account.Routing,
                                SWIFT = underlyingFund.Account.SWIFT,
                                Comments = underlyingFund.Account.Comments,
                                FFC = underlyingFund.Account.FFC,
                                ByOrderOf = underlyingFund.Account.ByOrderOf
                            };
                        }
                        /* End Account */
                    }
                    originalItem = null;
                    key = default(EntityKey);
                    key = context.CreateEntityKey("UnderlyingFunds", underlyingFund);
                    if (context.TryGetObjectByKey(key, out originalItem)) {
                        context.ApplyCurrentValues(key.EntitySetName, underlyingFund);
                    }
                }
                context.SaveChanges();
            }
        }
 public void SaveInvestorCommunication(InvestorCommunication investorCommunication)
 {
     using (DeepBlueEntities context = new DeepBlueEntities()) {
         if (investorCommunication.InvestorCommunicationID == 0) {
             context.InvestorCommunications.AddObject(investorCommunication);
         }
         else {
             EntityKey key;
             object originalItem;
             key = default(EntityKey);
             originalItem = null;
             key = context.CreateEntityKey("InvestorCommunications", investorCommunication);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, investorCommunication);
             }
             key = context.CreateEntityKey("Communications", investorCommunication.Communication);
             if (context.TryGetObjectByKey(key, out originalItem)) {
                 context.ApplyCurrentValues(key.EntitySetName, investorCommunication.Communication);
             }
         }
         context.SaveChanges();
     }
 }