/// <inheritdoc/> public async Task <ProductStoreItemRequest> CreateRequestAsync(UpdateRequestRequest createRequest) { var dbProduct = await _productService.GetProductAsync(createRequest.ProductId); var dbHiveSection = await _hiveSectionService.GetHiveSectionAsync(createRequest.HiveSectionId); var dbRequest = Mapper.Map <UpdateRequestRequest, DbProductStoreItemRequest>(createRequest); _context.Requests.Add(dbRequest); await _context.SaveChangesAsync(); return(Mapper.Map <ProductStoreItemRequest>(dbRequest)); }
public async Task <IHttpActionResult> GetProduct([FromUri] int id) { try { var product = await _productService.GetProductAsync(id); return(Ok(product)); } catch (RequestedResourceNotFoundException ex) { return(this.BadRequest(ex.Message)); } catch (Exception) { return(this.InternalServerError()); } }
public async Task <IHttpActionResult> GetProductAsync([FromUri] int id) { if (id < 1) { return(BadRequest($"Argument {nameof(id)} must be greater than zero.")); } try { var product = await _productService.GetProductAsync(id); return(Ok(product)); } catch (RequestedResourceNotFoundException) { return(NotFound()); } }
public async Task <IHttpActionResult> GetProduct([FromUri] int id) { var product = await _productService.GetProductAsync(id); return(Ok(product)); }