public async Task <IActionResult> Dispute([FromBody] ComplaintDisputeModel model) { if (model == null) { return(ReturnError(ErrorCodes.IncomingPayloadIsMissing, nameof(Dispute))); } try { var brokerId = User.TryGetBrokerId().Value; var apiUserId = User.UserId(); _ = await _apiOrderService.GetOrderAsync(model.OrderNumber, brokerId); var user = await _apiUserService.GetBrokerUser(model.CallingUser, brokerId); var complaint = await GetCreatedComplaint(model.OrderNumber, brokerId); _complaintService.Dispute(complaint, user?.Id ?? apiUserId, (user != null ? (int?)apiUserId : null), model.Message); await _dbContext.SaveChangesAsync(); return(Ok(new ResponseBase())); } catch (InvalidApiCallException ex) { return(ReturnError(ex.ErrorCode, nameof(Dispute))); } }
private async Task <bool> Dispute(string orderNumber, string message) { var payload = new ComplaintDisputeModel { OrderNumber = orderNumber, CallingUser = "******", Message = message }; using var content = new StringContent(JsonConvert.SerializeObject(payload, Formatting.Indented), Encoding.UTF8, "application/json"); var response = await client.PostAsync(_options.TolkApiBaseUrl.BuildUri("Complaint/Dispute"), content); if (JsonConvert.DeserializeObject <ResponseBase>(await response.Content.ReadAsStringAsync()).Success) { await _hubContext.Clients.All.SendAsync("OutgoingCall", $"[Complaint/Dispute]:: Boknings-ID: {orderNumber} Bestrider reklamation!"); } else { await _hubContext.Clients.All.SendAsync("OutgoingCall", $"[Complaint/Dispute] FAILED:: Boknings-ID: {orderNumber}Bestrider reklamation!"); } return(true); }