public async Task <IActionResult> GetCustomerOrders(Guid customerId) { var query = new GetCustomerOrdersQuery(customerId); var result = await _mediator.Send(query); return(Ok(result)); }
public async Task <IActionResult> Get([FromQuery] GetCustomerOrdersQuery query) { var result = await _mediator.Send(query); return(Ok(new HttpServiceResponseBase <OrderDto> { Data = result, Code = HttpStatusCode.OK })); }
public async Task <IActionResult> GetOrders() { FirebaseUser user = HttpContext.GetFirebaseUser(); GetCustomerOrdersQuery model = new GetCustomerOrdersQuery() { firebaseId = user.UserId }; ResultWrapper <GetCustomerOrdersOutput> result = await _mediator.Send(model); return(Ok(result)); }
public Task <ResultWrapper <GetCustomerOrdersOutput> > Handle(GetCustomerOrdersQuery request, CancellationToken cancellationToken) { ResultWrapper <GetCustomerOrdersOutput> result = new ResultWrapper <GetCustomerOrdersOutput>(); TUser tUser = _dbContext.TUser.FirstOrDefault(x => x.FireBaseId == request.firebaseId); if (tUser == null) { result.Status = false; result.Message = "cannot find customer!"; return(Task.FromResult(result)); } var list = _dbContext.TOrder .Include(x => x.TSupplier) .Where(x => x.TUserId == tUser.Id) .Where(x => x.Submited) .Select(tData => new GetCustomerOrdersOutput.OrderItem() { Id = tData.Id, Title = tData.Title, TotalPayablePrice = tData.TotalPayablePrice, Restaurant = tData.TSupplier.RestaurantName, Date = tData.Date }) .ToList(); result.Status = true; result.Result = new GetCustomerOrdersOutput() { list = list }; return(Task.FromResult(result)); }
public async Task <IList <OrderViewModel> > Handle(GetCustomerOrdersQuery request, CancellationToken cancellationToken) { var response = await _context.Orders.Where(x => x.CustomerId == request.CustomerId).ToListAsync(); return(_mapper.Map <List <OrderViewModel> >(response)); }
public async Task <IActionResult> Get([FromQuery] GetCustomerOrdersQuery query) { var response = await _mediator.Send(query); return(Result(response, HttpStatusCode.OK)); }