Ejemplo n.º 1
0
        /// <summary>
        /// Function to add new customer into database
        /// via the parameter: Customer object from UI
        /// </summary>
        /// <param name="customer"></param>
        public void AddCustomer(l.Customer customer)
        {
            //Add Customer Data into database

            d.Customer entity = Mapper.MapCustomer(customer);
            dbcontext.Add(entity);
            dbcontext.SaveChanges();
            logger.Info("Added customer into Customer table.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to search current customer in database
        /// then pass the result back to UI
        /// </summary>
        /// <param name="customer"></param>
        /// <returns>IEnumerable Collection of Library.Customer object</returns>
        public IEnumerable <l.Customer> SearchCustomer(l.Customer customer)
        {
            //Search Customer from database
            IQueryable <d.Customer> cusotmerFound
                = dbcontext.Customer.Where(c => c.LastName == customer.LastName &&
                                           c.FirstName == customer.FirstName);

            // IEnumerable<l.Customer> customerFound = Mapper.MapCustomer(entity);

            return(cusotmerFound.Select(Mapper.MapCustomer));
        }
Ejemplo n.º 3
0
        public void CustomerTest()
        {
            l.Customer customer = new l.Customer
            {
                CustomerId    = 1,
                FirstName     = "Sam",
                LastName      = "Lin",
                FavoriteStore = 1,
                PhoneNumber   = "1234567890"
            };

            Assert.Equal(1, customer.CustomerId);
            Assert.Equal("Sam", customer.FirstName);
            Assert.Equal("Lin", customer.LastName);
            Assert.Equal(1, customer.FavoriteStore);
            Assert.Equal("1234567890", customer.PhoneNumber);
        }