public async Task <ActionResult <CallbackResult <string> > > SaveProduct( SaveProductRequestModel saveProductRequestModel) { try { var userId = HttpContext.User.Claims.First(t => t.Type == "UserId").Value; var sendOptions = new SendOptions(); sendOptions.SetDestination( ApplicationConfiguration.Instance.GetValue <string>("ProductService:CallbacksReceiverEndpointName")); sendOptions.RequireImmediateDispatch(); var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(TimeSpan.FromSeconds(5)); var result = await _endpointInstance.Request <CallbackResult <string> >( new SaveProductRequest(saveProductRequestModel.Name, saveProductRequestModel.Stock, saveProductRequestModel.Price, Guid.Parse(userId)), sendOptions, tokenSource.Token) .ConfigureAwait(false); return(Ok(result)); } catch (Exception e) { _logger.LogError(e, ""); return(Ok(CallbackResult <string> .ErrorResult("", "Bilinmeyen bir hata oluştu"))); } }
public async Task <IActionResult> SaveProductAsync(SaveProductRequestModel requestModel) { //var result = await _saveProductCommandHandler.SaveAsync(requestModel); var result = await _mediator.Send(requestModel); return(Ok(result)); }
public async Task <IActionResult> Index([FromBody] SaveProductRequestModel model) { var productId = await this.productsRepository.SaveAsync( await HttpContext.GetTokenAsync(ApiExtensionsConstants.TokenName), CultureInfo.CurrentUICulture.Name, model.Id, model.Name, model.Sku, model.Description, model.IsNew, model.IsPublished, model.PrimaryProductId, model.CategoryId, model.Images?.Select(x => x.Id), model.Files?.Select(x => x.Id), model.FormData); return(this.StatusCode((int)HttpStatusCode.OK, new { Id = productId, Message = this.productLocalizer.GetString("ProductSavedSuccessfully").Value })); }