public ResponseModel <Models.Chat> sendMessage([FromBody] SendMessageRequestModel chat) { try { var newMessage = new Models.Chat { message = chat.message, receiverId = chat.receiverId, senderId = chat.senderId, timeSent = DateTimeOffset.Now }; dbcontext.chats.Add(newMessage); dbcontext.SaveChanges(); return(new ResponseModel <Models.Chat> { data = newMessage, message = "message sent ", status = true }); } catch (Exception ex) { return(new ResponseModel <Models.Chat> { data = null, message = "unable send " + ex.Message, status = true }); } }
public async Task <SendMessageResponseModel> SendMessageAsync(SendMessageRequestModel model) { var request = _mapper.Map <PartnersIntegration.Client.Models.MessagesPostRequestModel>(model); var result = await _partnersIntegrationClient.MessagesApi.SendMessageAsync(request); return(_mapper.Map <SendMessageResponseModel>(result)); }
public async Task <SendMessageResponseModel> SendMessageAsync([FromBody] SendMessageRequestModel model) { _log.Info("Send message started", new { model.LocationId, model.CustomerId, model.PosId, model.Subject }); var partnerId = _requestContext.UserId; model.SetPartnerId(partnerId); var result = await _messageService.SendMessageAsync(model); var logContext = new { model.LocationId, model.CustomerId, model.PosId, result.Status, PartnerMessageId = string.IsNullOrEmpty(result.PartnerMessageId) ? string.Empty : result.PartnerMessageId }; _log.Info("Send message finished", logContext); return(result); }