public GetByIdProductQueryResponse GetByIdProduct(GetByIdProductQueryRequest getByIdProductQueryRequest) { var product = ApplicationDbContext.ProductList.FirstOrDefault(p => p.Id == getByIdProductQueryRequest.Id); return(new GetByIdProductQueryResponse { Id = product.Id, Name = product.Name, Price = product.Price, Quantity = product.Quantity, CreateTime = product.CreateTime }); }
public GetByIdProductQueryResponse GetByIdProduct(GetByIdProductQueryRequest getByIdProductQueryRequest) { var product = ApplicationDbContext.ProductList.FirstOrDefault(s => s.Id == getByIdProductQueryRequest.Id); if (product == null) { throw new ArgumentNullException("Product Not Found"); } return(new GetByIdProductQueryResponse { Id = product.Id, Name = product.Name, Price = product.Price, Quantity = product.Quantity, CreateTime = product.CreateTime }); }
public IActionResult Get([FromQuery] GetByIdProductQueryRequest requestModel) { GetByIdProductQueryResponse product = _getByIdProductQueryHandler.GetByIdProduct(requestModel); return(Ok(product)); }
public async Task <IActionResult> Get([FromQuery] GetByIdProductQueryRequest requestModel) { var product = await _mediator.Send(requestModel); return(Ok(product)); }