public InboxViewModel() { UserRequests = new ObservableCollection <RequestPresenter>(); ExecuteLoadItemsCommand(); MessagingCenter.Subscribe <RequestPresenter>(this, "RefreshInbox", (sender) => { UserRequests.Remove(sender); }); App.ComunicationService.hubConnection.On <string>("ReceiveMessage", (message) => { UserRequest deseralized = JsonConvert.DeserializeObject <UserRequest>(message); var requestPresenter = new RequestPresenter(deseralized); UserRequests.Add(requestPresenter); }); }
private void Startbutton_Click(object sender, EventArgs e) { RequestPresenter presenter = new RequestPresenter(this); if (checker.ChoosedFileIsCurrentlyExist(FileName)) { presenter.ReadMessageFromFile(FileName); presenter.GetOperationFromUI(Operation); presenter.GetMethodFromUI(Method); if (checker.IsOnlyUkrainianLetters(textBox1.Text) && radioVigenere.Checked) { KeyVigenere = textBox1.Text; presenter.GetVigenereKeyFromUI(KeyVigenere); resultForm.ResultMessage = presenter.RunCipherMachine(); } else if (checker.IsKeyCaesarValueIsValid(textBox1.Text) && radioCaesar.Checked) { KeyCaesar = Convert.ToInt32(textBox1.Text); presenter.GetCaesarKeyFromUI(KeyCaesar); resultForm.ResultMessage = presenter.RunCipherMachine(); } else if (radioAtbush.Checked) { resultForm.ResultMessage = presenter.RunCipherMachine(); } else { MessageBox.Show(checker.ErrorText(textBox1.Text)); return; } if (resultForm.IsDisposed) { resultForm = new Form2(resultForm.ResultMessage); } resultForm.Show(); return; } MessageBox.Show("Choosen file doesn`t exist"); }
public async Task ExecuteLoadItemsCommand() { TokenExpManger tokenExpManger = new TokenExpManger(App.TokenDto.Exp); if (tokenExpManger.IsExpired()) { await tokenExpManger.CloseSession(); } else { IsBusy = true; try { UserRequests.Clear(); var requestData = await requestDataStore.GetRequestOfUser(App.LogUser.UserId); foreach (var item in requestData) { if (item.RequestAnswer == Answer.None) { var presenter = new RequestPresenter(item); UserRequests.Add(presenter); } } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } } }