示例#1
0
        //Customer
        public Backend.Customer CustomerConverterToBackend(Customer dataContextCustomer)
        {
            Backend.Customer currentCustomer = new Backend.Customer();

            //Credit Card Entity
            if (dataContextCustomer.CreditCard != null)
            {
                currentCustomer.CreditCard.CreditNumber   = dataContextCustomer.CreditCard1.CreditNumber;
                currentCustomer.CreditCard.ExpirationDate = dataContextCustomer.CreditCard1.ExpirationDate;
                currentCustomer.CreditCard.FirstName      = dataContextCustomer.CreditCard1.FirstName;
                currentCustomer.CreditCard.LastName       = dataContextCustomer.CreditCard1.LastName;
            }
            else
            {
                currentCustomer.CreditCard = null;
            }

            //Customer Entity
            currentCustomer.FirstName = dataContextCustomer.FirstName;
            currentCustomer.LastName  = dataContextCustomer.LastName;
            currentCustomer.Id        = dataContextCustomer.Id;
            IQueryable transQuery = from Transaction trans in db.Transactions
                                    from TranHistoryLinkedTable linkedTrans in db.TranHistoryLinkedTables
                                    where (trans.TransactionID == linkedTrans.TransID && linkedTrans.CustomerID == currentCustomer.Id)
                                    select trans;

            foreach (Transaction trans in transQuery)
            {
                currentCustomer.TranHistory.Add(TransactionConverterToBackend(trans));
            }
            return(currentCustomer);
        }
示例#2
0
        public Customer CustomerConverterToContext(Backend.Customer currentCustomer)
        {
            CreditCard dataContextCreditCard = new CreditCard();
            Customer   dataContextCustomer   = new Customer();

            //Credit Card Entity
            if (currentCustomer.CreditCard != null)
            {
                dataContextCreditCard.CreditNumber   = currentCustomer.CreditCard.CreditNumber;
                dataContextCreditCard.ExpirationDate = currentCustomer.CreditCard.ExpirationDate;
                dataContextCreditCard.FirstName      = currentCustomer.CreditCard.FirstName;
                dataContextCreditCard.LastName       = currentCustomer.CreditCard.LastName;
                dataContextCustomer.CreditCard1      = dataContextCreditCard;
                dataContextCustomer.CreditCard       = currentCustomer.CreditCard.CreditNumber;
            }

            //Customer Entity
            dataContextCustomer.IsAClubMember = false;
            dataContextCustomer.FirstName     = currentCustomer.FirstName;
            dataContextCustomer.LastName      = currentCustomer.LastName;
            dataContextCustomer.Id            = currentCustomer.Id;
            return(dataContextCustomer);
        }