Beispiel #1
0
        public async Task <Chat> CreateChatAsync(ChatParameters parameters)
        {
            var chatModel = await RequestClient.SendAsync <ChatModel>("/v2/chats", HttpMethod.Post, parameters)
                            .ConfigureAwait(false);

            return(new Chat(chatModel, this));
        }
        public async Task SaveChatParametersAsync(long chatId, int facultyId, int groupId, int groupTypeId)
        {
            var chatParameters = await _unitOfWork.ChatParameters.FindChatParametersAsync(chatId);

            if (chatParameters is null)
            {
                chatParameters = new ChatParameters()
                {
                    ChatId      = chatId,
                    FacultyId   = facultyId,
                    GroupId     = groupId,
                    GroupTypeId = groupTypeId
                };

                await _unitOfWork.ChatParameters.AddAsync(chatParameters);
            }
            else
            {
                chatParameters.FacultyId   = facultyId;
                chatParameters.GroupId     = groupId;
                chatParameters.GroupTypeId = groupTypeId;
            }

            await _unitOfWork.SaveChangesAsync();
        }
        public ResponseMessage GetMyMessages(ChatParameters objChatParameters)
        {
            string          reply       = string.Empty;
            ResponseMessage rM          = new ResponseMessage();
            List <ChatInfo> messageList = new List <ChatInfo>();

            try
            {
                var dt = apiRepository.GetMyMessages(objChatParameters, ref reply);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        ChatInfo message = new ChatInfo();

                        message.MessageId      = dr["MessageId"].ToString().Trim();
                        message.SenderId       = dr["SenderId"].ToString().Trim();
                        message.ReceiverId     = dr["ReceiverId"].ToString().Trim();
                        message.MessageDetails = dr["MessageDetails"].ToString().Trim();
                        message.MessageTime    = dr["MessageTime"].ToString().Trim();

                        messageList.Add(message);
                    }
                    rM.MessageCode   = "Y";
                    rM.Message       = "";
                    rM.SystemMessage = reply;
                    rM.Content       = messageList;
                }
                else
                {
                    rM.MessageCode   = "N";
                    rM.Message       = "No message found.";
                    rM.SystemMessage = reply;
                    rM.Content       = messageList;
                }
                return(rM);
            }
            catch (Exception ex)
            {
                rM.MessageCode   = "N";
                rM.Message       = "System Error";
                rM.SystemMessage = ex.Message;
                rM.Content       = messageList;
                return(rM);
            }


            return(rM);
        }
        public DataTable GetMyMessages(ChatParameters objChatParameters, ref string replay)
        {
            string    msg_code = string.Empty;
            string    msg      = string.Empty;
            DataTable dTable   = new DataTable();

            try
            {
                objSqlProcManager = new SqlProcedureManager(connectionString);
                dTable            = objSqlProcManager.ExecuteDataTable("sp_Get_My_Messages", ref replay,
                                                                       objChatParameters.SenderId,
                                                                       objChatParameters.ReceiverId

                                                                       );
            }
            catch (Exception errorException)
            {
                throw errorException;
            }
            return(dTable);
        }
Beispiel #5
0
        public ChatParameters Post([FromBody] ChatParameters chatParameters)
        {
            ConversationService conversation = new ConversationService();

            return(conversation.StartConversation(chatParameters.Text, chatParameters.Context));
        }