Пример #1
0
        public ActionResult SubmitConversation(PrivateConversationBetweenTwoUsers conversation)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                string userId = User.Identity.GetUserId();

                if (dogOwnerService.AddConversation(userId, conversation.NewConversation))
                {
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
        }
        public PrivateConversationBetweenTwoUsers ConversationBetweenTwoUsers(string userId, string otherId)
        {
            var conversations = privateMessageBoardRepo.GetMessagesBetweenTwoUsers(userId, otherId)
                                .Select(u => new ConversationViewModel()
            {
                OtherID       = u.SendFromID == otherId ? otherId : null,
                OtherFullName = u.SendFromID == otherId ? u.SenderOfPrivateMessage.FullName : null,
                LastMessage   = u.Message,
                DateTime      = u.CreateDate
            });
            PrivateConversationBetweenTwoUsers privateConversation = new PrivateConversationBetweenTwoUsers()
            {
                Conversations   = conversations,
                NewConversation = new ConversationViewModel()
                {
                    OtherID     = otherId,
                    LastMessage = string.Empty
                }
            };

            return(privateConversation);
        }