public async Task <bool> SendInterUserMessage(MessageParticipant from, MessageParticipant to, string message, int?jobId) { var interUserMessageRequest = new InterUserMessageRequest { From = from, To = to, Content = message, JobId = jobId, }; string json = JsonConvert.SerializeObject(interUserMessageRequest); StringContent data = new StringContent(json, Encoding.UTF8, "application/json"); using (HttpResponseMessage response = await Client.PostAsync("/api/InterUserMessage", data)) { string jsonResponse = await response.Content.ReadAsStringAsync(); var interUserMessageResponse = JsonConvert.DeserializeObject <ResponseWrapper <bool, CommunicationServiceErrorCode> >(jsonResponse); if (interUserMessageResponse.HasContent && interUserMessageResponse.IsSuccessful) { return(interUserMessageResponse.Content); } } return(false); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] [RequestBodyType(typeof(InterUserMessageRequest), "Inter User Message")] InterUserMessageRequest req, ILogger log) { try { var response = await _mediator.Send(req); return(new OkObjectResult(ResponseWrapper <bool, CommunicationServiceErrorCode> .CreateSuccessfulResponse(response))); } catch (Exception exc) { log.LogError("Exception occured in Inter User Message", exc); return(new ObjectResult(ResponseWrapper <bool, CommunicationServiceErrorCode> .CreateUnsuccessfulResponse(CommunicationServiceErrorCode.InternalServerError, "Internal Error")) { StatusCode = StatusCodes.Status500InternalServerError }); } }