protected async Task AddEpisode(Chapter OneChapter) { if (OneQuiz.Id == 0) { var response = await ModalDialog.ShowMessageBoxAsync("Question", "Do you want to save this new quiz ?", MessageBoxButtons.YesNo); if (response == MessageBoxDialogResult.No) { return; } var result = await TrySavingChanges(); if (result == false) { return; } } ModalDialogParameters parameters = new ModalDialogParameters(); parameters.Add("Title", ""); parameters.Add("VideoId", ""); parameters.Add("Duration", 0); parameters.Add("Trailer", ""); var dialogResult = await ModalDialog.ShowDialogAsync <EpisodeEdit>("Add episode", new ModalDialogOptions(), parameters); if (dialogResult.Success) { var episode = new Episode { Title = dialogResult.ReturnParameters.Get <string>("Title"), VideoId = dialogResult.ReturnParameters.Get <string>("VideoId"), Duration = dialogResult.ReturnParameters.Get <int>("Duration"), Trailer = dialogResult.ReturnParameters.Get <string>("Trailer"), ChapterId = OneChapter.Id }; if (OneChapter.Episodes == null) { OneChapter.Episodes = new List <Episode>(); } OneChapter.Episodes.Add(episode); await EpisodeService.AddEpisode(episode); StateHasChanged(); } }
public async void OnClickEdit(ItemClickEventArgs e) { StateHasChanged(); var parameters = new ModalDialogParameters(); parameters.Add("Link", e.Data as UserLinkViewModel); ModalDialogResult result = await ModalDialog.ShowDialogAsync <Edit>("Edit Form", null, parameters); if (result.Success) { UserLinkVM = result.ReturnParameters.Get <UserLinkViewModel>("Link"); await OnUpdate.InvokeAsync(new ChangeEventArgs { Value = UserLinkVM }); } StateHasChanged(); }
protected async Task EditEpisode(Chapter OneChapter, Episode OneEpisode) { ModalDialogParameters parameters = new ModalDialogParameters(); parameters.Add("Title", OneEpisode.Title); parameters.Add("VideoId", OneEpisode.VideoId); parameters.Add("Duration", OneEpisode.Duration); parameters.Add("Trailer", OneEpisode.Trailer); var dialogResult = await ModalDialog.ShowDialogAsync <EpisodeEdit>("Edit episode", new ModalDialogOptions(), parameters); if (dialogResult.Success) { OneEpisode.Title = dialogResult.ReturnParameters.Get <string>("Title"); OneEpisode.VideoId = dialogResult.ReturnParameters.Get <string>("VideoId"); OneEpisode.Duration = dialogResult.ReturnParameters.Get <int>("Duration"); OneEpisode.Trailer = dialogResult.ReturnParameters.Get <string>("Trailer"); await EpisodeService.UpdateEpisode(OneEpisode); } }