예제 #1
0
        public FindCustomersResponse Find(FindCustomersRequest request)
        {
            try
            {
                _customerQuery.Init();
                _customerQuery.WithOnlyActivated(true);
                _customerQuery.WithName(request.Name);
                _customerQuery.WithLastName(request.LastName);
                _customerQuery.WithGender(request.GenderType.ConvertToEnum <EGenderType>());
                _customerQuery.WithColony(request.Colony);
                _customerQuery.WithMunicipality(request.Municipality);
                _customerQuery.WithHomePhone(request.HomePhone);
                _customerQuery.WithCellPhone(request.CellPhone);
                _customerQuery.Sort(request.Sort, request.SortBy);
                var totalRecords = _customerQuery.TotalRecords();
                _customerQuery.Paginate(request.ItemsToShow, request.Page);
                var customers = _customerQuery.Execute();

                return(new FindCustomersResponse
                {
                    Customers = TypeAdapter.Adapt <List <CustomerResponse> >(customers),
                    TotalRecords = totalRecords
                });
            }
            catch (DataAccessException)
            {
                throw new ApplicationException();
            }
        }
예제 #2
0
 /// <summary>
 /// Get customer by identifier
 /// </summary>
 /// <param name="query">Query object where logic of selection resides</param>
 /// <returns></returns>
 public Task <CustomerDto> GetCustomer(ICustomerQuery query)
 {
     return(query.Execute(UserContext));
 }