コード例 #1
0
        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
                });
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }