예제 #1
0
        public IActionResult DeleteCustomer(int customerId)
        {
            datalayer.interfaces.ICustomerRepository customersRepository = new datalayer.repositories.CustomerRepository();
            customersRepository.Delete(customerId);

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public IActionResult Index()
        {
            datalayer.interfaces.ICustomerRepository customersRepository = new datalayer.repositories.CustomerRepository();
            var customers = customersRepository.GetAll();

            return(IndexHelper(customers));
        }
예제 #3
0
        public IActionResult SaveCustomer(CustomerViewModel a)
        {
            var customer = new datalayer.models.Customer
            {
                Id    = a.Customer.Id,
                Title = new datalayer.models.Title {
                    Id = System.Convert.ToInt32(a.CustomerTitleId)
                },
                FirstName       = a.Customer.FirstName,
                LastName        = a.Customer.LastName,
                AddressLine1    = a.Customer.AddressLine1,
                AddressPostcode = a.Customer.AddressPostcode
            };

            datalayer.interfaces.ICustomerRepository customersRepository = new datalayer.repositories.CustomerRepository();

            if (customer.Id == 0)
            {
                customersRepository.Add(customer);
            }
            else
            {
                customersRepository.Update(customer);
            }

            return(RedirectToAction("Index"));
        }
예제 #4
0
        public IActionResult SearchCustomers(IndexViewModel a)
        {
            var searchDetails = new datalayer.models.Customer
            {
                Title = new datalayer.models.Title {
                    Id = System.Convert.ToInt32(a.SearchDetails.CustomerTitleId)
                },
                FirstName       = a.SearchDetails.Customer.FirstName,
                LastName        = a.SearchDetails.Customer.LastName,
                AddressLine1    = a.SearchDetails.Customer.AddressLine1,
                AddressPostcode = a.SearchDetails.Customer.AddressPostcode
            };

            datalayer.interfaces.ICustomerRepository customersRepository = new datalayer.repositories.CustomerRepository();
            var customers = customersRepository.Search(searchDetails);

            return(IndexHelper(customers));
        }
예제 #5
0
        public IActionResult EditCustomer(int customerId)
        {
            datalayer.interfaces.ICustomerRepository customersRepository = new datalayer.repositories.CustomerRepository();
            var customer = customersRepository.Get(customerId);

            return(View(new CustomerViewModel {
                Customer = new Customer {
                    Id = customer.Id,
                    Title = customer.Title.Name,
                    FirstName = customer.FirstName,
                    LastName = customer.LastName,
                    AddressLine1 = customer.AddressLine1,
                    AddressPostcode = customer.AddressPostcode
                },
                CustomerTitleId = customer.Title.Id,
                Titles = BuildTitleList()
            }));
        }