Пример #1
0
        public IHttpActionResult GetCustomersByName(string name)
        {
            IHttpActionResult       result;
            IList <Models.Customer> customer;

            try
            {
                customer = MapperHelper.DomainToModelMap <IList <CustomerManagementDAL.Customer>, IList <Models.Customer> >(customerRepository.GetCustomersByName(name));
            }
            catch (Exception)
            {
                return(InternalServerError(new Exception("Error in get customer by name.  Please try again.")));
            }

            if (customer == null)
            {
                result = NotFound();
            }
            else
            {
                result = Ok(customer);
            }

            return(result);
        }
Пример #2
0
        public IHttpActionResult GetCustomers(int id)
        {
            IHttpActionResult result;

            Models.Customer customer = MapperHelper.DomainToModelMap <CustomerManagementDAL.Customer, Models.Customer>(customerRepository.GetCustomerByID(id));

            if (customer == null)
            {
                result = NotFound();
            }
            else
            {
                result = Ok(customer);
            }

            return(result);
        }
Пример #3
0
        public IHttpActionResult GetCustomers()
        {
            IHttpActionResult             result = null;
            IEnumerable <Models.Customer> list;

            try
            {
                list = MapperHelper.DomainToModelMap <IEnumerable <CustomerManagementDAL.Customer>, IEnumerable <Models.Customer> >(customerRepository.GetCustomers());
            }
            catch (Exception)
            {
                return(InternalServerError(new Exception("Error in get customer list.  Please try again.")));
            }

            result = Ok(list);

            return(result);
        }