예제 #1
0
 public void InsertConversationComment(ChatCommentAddRequest model, string userId)
 {
     DataProvider.ExecuteNonQuery(GetConnection, "dbo.ChatComments_Insert"
            , inputParamMapper: delegate (SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@SenderId", userId);
                paramCollection.AddWithValue("@ReceiverId", model.ReceiverHandle);
                paramCollection.AddWithValue("@Comment", model.Content);
            }
            , returnParameters: delegate (SqlParameterCollection param)
            {
            }
            );
 }
        public HttpResponseMessage GetConversation(string Handle)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();
            string receiverID = _userService.GetUserIdByHandle(Handle);

            ChatCommentAddRequest comment = new ChatCommentAddRequest();
            comment.ReceiverHandle = receiverID;

            int id = _chatService.GetConversationId(receiverID, userId);

            ItemsResponse<UserComment> response = new ItemsResponse<UserComment>();

            response.Items = _commentService.Select(id, 12);

            return Request.CreateResponse(response);
        }
        public HttpResponseMessage InsertConversationComment(ChatCommentAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();
            string receiverID = _userService.GetUserIdByHandle(model.ReceiverHandle);

            model.Id = _chatService.GetConversationId(receiverID, userId);
            CommentsAddRequest comment = CreateComment(model);

            ItemResponse<int> response = new ItemResponse<int>();

            response.Item = _commentService.Add(comment, userId);

            string user =_userService.GetByUserId(userId).Handle;

              //          _LiveChat.Reply(userId, model.ReceiverHandle);
            //            _LiveChat.Reply(receiverID, user);

            return Request.CreateResponse(response);
        }
 private static CommentsAddRequest CreateComment(ChatCommentAddRequest model)
 {
     CommentsAddRequest comment = new CommentsAddRequest();
     comment.Comment = model.Content;
     comment.OwnerId = model.Id;
     comment.OwnerType = 12;
     comment.Title = null;
     comment.ParentId = null;
     return comment;
 }