示例#1
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
            };

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

            return(RedirectToAction("Index"));
        }
示例#2
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
            };

            return(IndexHelper(_customerRepository.Search(searchDetails)));
        }