Ejemplo n.º 1
0
        public async Task <IActionResult> Conversation(int orderId)
        {
            var userId     = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var specialist = await _specialistService.FindAsync(userId);

            var dialog = await _messageService.GetDialogAsync(specialist.Id, orderId);

            if (dialog == null)
            {
                return(Content("NotFound"));
            }
            await _messageService.MarkAsRead(dialog.UserSpecialistMessage.Id, userId);

            var viewModel = new MessagesAndCurrentUser
            {
                UserId         = userId,
                Dialog         = dialog,
                AuthorImageUrl = specialist.ImageUrl
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetConversation(int id) //MessageLogId
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var dialog = await _messageService.GetDialogAsync(id);

            if (dialog.UserSpecialistMessage.Client.AppUserId != userId)
            {
                return(BadRequest());
            }
            if (dialog == null)
            {
                return(Content("NotFound"));
            }
            await _messageService.MarkAsRead(dialog.UserSpecialistMessage.Id, userId);

            var model = new MessagesAndCurrentUser(userId, dialog);

            model.IsFinished = dialog.UserSpecialistMessage.Order.State == OrderStateTypeEnum.Finished;
            model.IsHaveSelectedSpeciaslit = dialog.UserSpecialistMessage.Order.SpecialistId != null;
            model.IsSelectedSpecialist     = dialog.UserSpecialistMessage.SpecialistId == dialog.UserSpecialistMessage.Order.SpecialistId;

            return(PartialView("_ConversationPartial", model));
        }