Esempio n. 1
0
        public async Task <IActionResult> GetDialogAsync(GetDialog _dialog)
        {
            //Находим все диалоги(только ОДИНОЧНЫЕ) в которых участвует пользователь 1 и 2. Находим общий диалог среди результатов
            var dialogsOfUser1 = await _context.Participants.Include(o => o.ChatRoom).Where(o => o.UserId == _dialog.User1 && o.ChatRoom.RoomType == Entities.Enums.RoomType.Dialog).Select(o => o.ChatRoom).ToListAsync();

            var dialogsOfUser2 = await _context.Participants.Include(o => o.ChatRoom).Where(o => o.UserId == _dialog.User2 && o.ChatRoom.RoomType == Entities.Enums.RoomType.Dialog).Select(o => o.ChatRoom).ToListAsync();

            var dialog = dialogsOfUser1.Intersect(dialogsOfUser2).First();


            return(Ok(JsonSerializer.Serialize(dialog)));
        }
        private async void ExecuteGetDialog(object o)
        {
            var dir            = Path.Combine((IsDirectorySelected ? _selectedLocalPath : null) ?? RootDirectories[0].Path);
            var selectedZkPath = IsZkPathSelected ? _selectedZkPath : null;

            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var context = new TransferDialogViewModel
            {
                LocalDirectory = Path.Combine(dir, Path.GetFileName(selectedZkPath ?? string.Empty)),
                ZkPath         = selectedZkPath,
            };
            var view = new GetDialog
            {
                DataContext = context
            };

            //show the dialog
            await DialogHost.Show(view, "RootDialog", GetClosingEventHandler);
        }