public async Task <bool> Create(CustomerCCEmailHistory CustomerCCEmailHistory)
        {
            CustomerCCEmailHistoryDAO CustomerCCEmailHistoryDAO = new CustomerCCEmailHistoryDAO();

            CustomerCCEmailHistoryDAO.Id = CustomerCCEmailHistory.Id;
            CustomerCCEmailHistoryDAO.CustomerEmailHistoryId = CustomerCCEmailHistory.CustomerEmailHistoryId;
            CustomerCCEmailHistoryDAO.CCEmail = CustomerCCEmailHistory.CCEmail;
            DataContext.CustomerCCEmailHistory.Add(CustomerCCEmailHistoryDAO);
            await DataContext.SaveChangesAsync();

            CustomerCCEmailHistory.Id = CustomerCCEmailHistoryDAO.Id;
            await SaveReference(CustomerCCEmailHistory);

            return(true);
        }
        public async Task <bool> BulkMerge(List <CustomerCCEmailHistory> CustomerCCEmailHistories)
        {
            List <CustomerCCEmailHistoryDAO> CustomerCCEmailHistoryDAOs = new List <CustomerCCEmailHistoryDAO>();

            foreach (CustomerCCEmailHistory CustomerCCEmailHistory in CustomerCCEmailHistories)
            {
                CustomerCCEmailHistoryDAO CustomerCCEmailHistoryDAO = new CustomerCCEmailHistoryDAO();
                CustomerCCEmailHistoryDAO.Id = CustomerCCEmailHistory.Id;
                CustomerCCEmailHistoryDAO.CustomerEmailHistoryId = CustomerCCEmailHistory.CustomerEmailHistoryId;
                CustomerCCEmailHistoryDAO.CCEmail = CustomerCCEmailHistory.CCEmail;
                CustomerCCEmailHistoryDAOs.Add(CustomerCCEmailHistoryDAO);
            }
            await DataContext.BulkMergeAsync(CustomerCCEmailHistoryDAOs);

            return(true);
        }
        public async Task <bool> Update(CustomerCCEmailHistory CustomerCCEmailHistory)
        {
            CustomerCCEmailHistoryDAO CustomerCCEmailHistoryDAO = DataContext.CustomerCCEmailHistory.Where(x => x.Id == CustomerCCEmailHistory.Id).FirstOrDefault();

            if (CustomerCCEmailHistoryDAO == null)
            {
                return(false);
            }
            CustomerCCEmailHistoryDAO.Id = CustomerCCEmailHistory.Id;
            CustomerCCEmailHistoryDAO.CustomerEmailHistoryId = CustomerCCEmailHistory.CustomerEmailHistoryId;
            CustomerCCEmailHistoryDAO.CCEmail = CustomerCCEmailHistory.CCEmail;
            await DataContext.SaveChangesAsync();

            await SaveReference(CustomerCCEmailHistory);

            return(true);
        }
예제 #4
0
        private async Task SaveReference(CustomerEmailHistory CustomerEmailHistory)
        {
            await DataContext.CustomerCCEmailHistory.Where(x => x.CustomerEmailHistoryId == CustomerEmailHistory.Id).DeleteFromQueryAsync();

            if (CustomerEmailHistory.CustomerCCEmailHistories != null)
            {
                List <CustomerCCEmailHistoryDAO> CustomerCCEmailHistoryDAOs = new List <CustomerCCEmailHistoryDAO>();
                foreach (var CustomerCCEmailHistory in CustomerEmailHistory.CustomerCCEmailHistories)
                {
                    CustomerCCEmailHistoryDAO CustomerCCEmailHistoryDAO = new CustomerCCEmailHistoryDAO
                    {
                        Id = CustomerCCEmailHistory.Id,
                        CustomerEmailHistoryId = CustomerEmailHistory.Id,
                        CCEmail = CustomerCCEmailHistory.CCEmail
                    };
                    CustomerCCEmailHistoryDAOs.Add(CustomerCCEmailHistoryDAO);
                }
                await DataContext.BulkMergeAsync(CustomerCCEmailHistoryDAOs);
            }
        }