public async Task <ActionResult <IEnumerable <CustomerDto> > > Get() { var request = new GetAllCustomersRequest(); var response = await _mediator.Send(request); return(new OkObjectResult(response)); }
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); }
/// <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); }
/// <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); }
/// <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); }
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)); }