public async Task <int> DeleteProductOptionAsync(Guid productId, Guid id) { if (await _repository.GetByIdAsync(productId, id) == null) { throw new NotFoundException(Constants.Constants.ProductOptionNotFound, HttpStatusCode.NotFound.ToString()); } return(await _repository.DeleteAsync(productId, id)); }
public async Task <IProductOption> GetOption(Guid productId, Guid id) { var model = await productOptionRepository.GetByIdAsync(id); if (model == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(model); }
public async Task <ProductOption> GetByIdAsync(Guid id) { var productOption = await _productOptionRepository.GetByIdAsync(id); if (productOption == null) { throw new ProductOptionNotFoundException(id); } return(productOption); }
public async Task <IHttpActionResult> GetOption(Guid productId, Guid id) { var productOption = await _productOptionRepository.GetByIdAsync(productId, id); if (productOption == null) { return(NotFound()); } return(Ok(Mapper.Map <ProductOptionDto>(productOption))); }
/// <inheritdoc /> public async Task <Result <ProductOption> > GetByIdAsync(Guid productId, Guid id) { _logger.Debug("Getting product options by Id. ProductId: {productId}, ProductOptionId: {productOptionId}", productId, id); var productResult = await _productService.GetByIdAsync(productId); if (!productResult.IsSuccess()) { return(Result <ProductOption> .Failed(productResult.Error)); } var productOption = await _productOptionRepository.GetByIdAsync(id); return(productOption != null ? Result <ProductOption> .Success(productOption) : Result <ProductOption> .Failed(ErrorCode.ProductOptionNotFound, AppConstants.ResourceNotFoundErrorMessage)); }