예제 #1
0
        public async Task <ActionResult <IEnumerable <CustomerDto> > > Get()
        {
            var request  = new GetAllCustomersRequest();
            var response = await _mediator.Send(request);

            return(new OkObjectResult(response));
        }
예제 #2
0
        public async Task <GetAllCustomersResponse> Get(GetAllCustomersRequest request)
        {
            var customers = await repo.GetCustomersAsync();

            var dtos     = mapper.Map <IEnumerable <CustomerDTO> >(customers);
            var response = mapper.Map <GetAllCustomersResponse>(dtos);

            response.ResponseAction = ResponseAction.Found;
            return(response);
        }
예제 #3
0
파일: Proxy.cs 프로젝트: willdarwin/tta
        /// <summary>
        /// Gets all customers.  --Robin
        /// </summary>
        /// <returns></returns>
        public List <CustomerBE> GetAllCustomers()
        {
            GetAllCustomersRequest  request  = new GetAllCustomersRequest();
            GetAllCustomersResponse response = MyChannelFactory.CreateChannel().GetAllCustomers(request);

            if (response.IsFailed)
            {
                throw new Exception("We have a error!" + response.Message);
            }
            return(response.CustomersList);
        }
예제 #4
0
        /// <summary>
        /// Gets all customers.
        /// </summary>
        /// <returns></returns>
        public GetAllCustomersResponse GetAllCustomers(GetAllCustomersRequest request)
        {
            CustomerService         service  = new CustomerService();
            GetAllCustomersResponse response = new GetAllCustomersResponse();

            try
            {
                response.CustomersList = service.GetAllCustomers();
            }
            catch (System.Exception ex)
            {
                response.Message  = ex.ToString();
                response.IsFailed = true;
            }
            return(response);
        }
예제 #5
0
        /// <summary>
        /// Gets all customers.  --Robin
        /// </summary>
        /// <returns></returns>
        public List <CustomerBE> GetAllCustomers()
        {
            GetAllCustomersRequest request = new GetAllCustomersRequest();
            ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
            GetAllCustomersResponse response = null;

            try
            {
                response = MyChannelFactory.CreateChannel().GetAllCustomers(request);
            }
            catch (System.Exception ex)
            {
                log.Error("error", ex);
                log.Fatal("fatal", ex);
                throw new Exception("We have a error! Maybe the endpoint is not correct");
            }
            if (response.IsFailed)
            {
                log.Error("error", new Exception(response.Message));
                log.Fatal("fatal", new Exception(response.Message));
                throw new Exception("We have a error!");
            }
            return(response.CustomersList);
        }
예제 #6
0
        public List <Customer> Get(GetAllCustomersRequest request)
        {
            var personCtr = new PersonCtr();

            return(personCtr.GetAllCustomers());
        }
        public Task <IEnumerable <CustomerDto> > Handle(GetAllCustomersRequest request, CancellationToken cancellationToken)
        {
            var customers = _context.Customers.Select(c => new CustomerDto(c)).AsEnumerable();

            return(Task.FromResult(customers));
        }
 public Task <IActionResult> GetAllCustomers([FromQuery] GetAllCustomersRequest request)
 {
     return(this.HandleRequest <GetAllCustomersRequest, GetAllCustomersResponse>(request));
 }