public async Task <IActionResult> Create(CreateProductQuery query) { var result = await mediator.Send(query); if (result.Success) { return(View(result.Content)); } TempData["ErrorMessage"] = "Something wrong happend, please try again"; return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Create([FromBody] CreateProductQuery createQuery) { var createProductParams = _mapper.Map <CreateProductParams>(createQuery); var createdProduct = await _productService.CreateProductAsync(createProductParams); if (createdProduct == null) { return(NotFound()); } var locationUri = _uriGeneratorService.GetProductUri(createdProduct.ProductId); return(Created(locationUri, new Response <ProductDto>(createdProduct))); }