public GetCarryOutByIdResponse GetCarryOutById(GetCarryOutByIdRequest request) { var response = new GetCarryOutByIdResponse { IsSuccessful = false, }; try { var bundleId = _context.CarryOuts .FirstOrDefault(x => x.Id == request.BundleId); var carryOuts = _context.CarryOuts .Include(x => x.Food) .Include(x => x.Beverage) .Include(x => x.Customer) .Where(x => x.BundleId == request.BundleId) .Where(x => x.SubmissionTime != null) .ToList(); response.CarryOuts = carryOuts; response.IsSuccessful = true; } catch (Exception ex) { response.Message = ex.ToString(); } return(response); }
public IActionResult GetCarryOutById([FromRoute] int id) { var request = new GetCarryOutByIdRequest() { BundleId = id }; var response = _carryOutService.GetCarryOutById(request); if (response.IsSuccessful) { return(Ok(response.CarryOuts)); } else { return(BadRequest(response.Message)); } }