Exemplo n.º 1
0
        public IHttpActionResult CreateChat([FromBody] Chat chat)
        {
            ErrorMessage errorMessage = chatBL.CreateChat(chat);

            if (errorMessage.Code == HttpStatusCode.OK)
            {
                Chat createdChat = chatBL.GetChat(chat.Id);
                return(Ok(createdChat));
            }

            return(new ResponseMessageResult(Request.CreateErrorResponse(
                                                 errorMessage.Code,
                                                 new HttpError(errorMessage.Message)
                                                 )
                                             ));
        }
Exemplo n.º 2
0
        public async Task SignIn(string currentUser, string targetUser)
        {
            var userInDB = await _userBL.GetUser(currentUser);

            if (userInDB is null || userInDB.Online is false)
            {
                return;
            }


            var chat = _chatBL.FindChat(currentUser, targetUser);

            if (chat == null)
            {
                _chatBL.CreateChat(currentUser, targetUser, Context.ConnectionId);
            }
            else
            {
                chat.IsActive         = true;
                chat.UserConnectionID = Context.ConnectionId;
                _chatBL.UpdateConnectionID(chat);
                _chatBL.UpDateChat(chat);
            }
        }