Exemplo n.º 1
0
        public ViewResult ListCustomer()
        {
            List <Models.Customer> customers = new List <Models.Customer>();

            using (var databaseContext = dbContext)
            {
                try
                {
                    var customerRepository = new Repository.CustomerRepository(databaseContext);
                    customers = customerRepository.GetAllCustomers();
                }
                ///////???????????????????????????????????????????????? empty Catch
                catch { }
                return(View(customers));
            }
        }
Exemplo n.º 2
0
        // GET: Customer
        public ActionResult Index(string searchBy, string search)
        {
            List <Models.CustomerModel> customers = customerRepository.GetAllCustomers();

            if (searchBy == "Name")
            {
                return(View(customers.Where(x => x.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || search == null).ToList()));
            }
            else if (searchBy == "EmailAddress")
            {
                return(View(customers.Where(x => x.EmailAddress.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || search == null).ToList()));
            }
            else
            {
                return(View("Index", customers));
            }
        }