public async Task <IActionResult> Update(int id) { PodcastViewModel viewModel = new PodcastViewModel(); var pod = await _context.Pods.Where(p => p.Id == id).FirstOrDefaultAsync(); if (id != pod.Id) { // ViewBag.pod = "Podcast not found!"; return(RedirectToAction(nameof(Index))); } _context.Remove(pod); await _context.SaveChangesAsync(); //viewModel.Id = pod.Id; //viewModel.Title = pod.Title; //viewModel.Author = pod.Author; //viewModel.Description = pod.Description; //viewModel.Tag = pod.Tag; return(View(viewModel)); }
// GET: Podcast/Create public ActionResult Create() { PodcastViewModel model = new PodcastViewModel(); model.viewPodcast = new Podcast(); model.hostList = db.Hosts.ToList(); return(View(model)); }
public bool ShowEditPodcastDialog(PodcastViewModel viewModel) { var editDialog = new EditPodcastWindow(viewModel) { Owner = Application.Current.MainWindow }; return(editDialog.ShowDialog().GetValueOrDefault(false)); }
public ActionResult Index() { IReadOnlyCollection <PodcastModel> podcasts = _podcastService.GetPodcasts(); var model = new PodcastViewModel { Podcasts = podcasts }; return(View(model)); }
protected override void GivenThat() { base.GivenThat(); OriginalPodcast = new PodcastViewModel(null); DialogService.Stub(s => s.ShowEditPodcastDialog(SelectedPodcast)) .WhenCalled(invocation => SelectedPodcast.Name = "New name") .Return(false); }
//// GET: Podcast/Create public ActionResult Create() { PodcastViewModel model = new PodcastViewModel() { Podcast = new Podcast(), GenreList = GetGenreList() }; return(View(model)); }
// GET: Podcast/Edit/5 public ActionResult Edit(int id) { PodcastViewModel model = new PodcastViewModel { Podcast = podcastDal.GetPodcast(id.ToString()), GenreList = GetGenreList() }; return(View(model)); }
public ICollection <Subcategory> Resolve(PodcastViewModel source, Podcast destination, ICollection <SubcategoryViewModel> sourceMember, ICollection <Subcategory> destMember, ResolutionContext context) { var results = _categoryRepository.GetAllSubcategories() .Where(r => sourceMember.Select(e => e.Id.ToString()).Contains(r.Id.ToString())) .ToList(); return(results); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); ViewModel = e.Parameter as PodcastViewModel; Debug.Assert(ViewModel != null); await ViewModel.RefreshAsync(); this.DataContext = this; }
protected override void GivenThat() { base.GivenThat(); OriginalPodcast = new PodcastViewModel(null); ViewModel.Podcasts.Add(OriginalPodcast); BrowseForFileService.Stub(s => s.BrowseForFileToOpen(null)) .IgnoreArguments() .Return(null); }
public async Task <ActionResult> Index(PodcastViewModel model) { if (!ModelState.IsValid) { // TODO: Ensure podcasts are posted instead of getting them from service. model.Podcasts = _podcastService.GetPodcasts(); return(View(model)); } await _podcastService.AddPodcast(model.FeedUrl); return(RedirectToAction("Index")); }
// GET: Podcast public ActionResult Index(string id) { PodcastViewModel podcast = this.Locator.Podcast(id); if (podcast != null && podcast.Podcast != null) { return(View(podcast)); } else { return(Redirect("/")); } }
protected override void GivenThat() { base.GivenThat(); ViewModel = new PodcastViewModel(new PodcastInfo(ControlFile) { Folder = "New Name", Feed = new FeedInfo(ControlFile) { Address = new Uri("http://www.newaddress.com/ppp.xml") } }); }
// GET: Content/Create public ActionResult Create(int type) { if (type == 1) { ViewBag.BreadCrump = "ثبت پادکست "; } ViewBag.CurrentDate = DateTime.Now.ToShortPersianDateString(); var c = new PodcastViewModel(); return(View(c)); }
public PodcastView() { BindingContext = new PodcastViewModel(); var refresh = new ToolbarItem { Command = ViewModel.LoadItemsCommand, Icon = "refresh.png", Name = "refresh", Priority = 0 }; ToolbarItems.Add (refresh); var stack = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(0, 8, 0, 8) }; var activity = new ActivityIndicator { Color = Helpers.Color.Greenish.ToFormsColor(), IsEnabled = true }; activity.SetBinding (ActivityIndicator.IsVisibleProperty, "IsBusy"); activity.SetBinding (ActivityIndicator.IsRunningProperty, "IsBusy"); stack.Children.Add (activity); var listView = new ListView(); listView.ItemsSource = ViewModel.Podcasts; var cell = new DataTemplate(typeof(ListTextCell)); cell.SetBinding (TextCell.TextProperty, "Title"); cell.SetBinding (TextCell.DetailProperty, "Details"); listView.ItemTapped += (sender, args) => { if(listView.SelectedItem == null) return; this.Navigation.PushAsync(new PodcastDetalView(listView.SelectedItem as Podcast)); listView.SelectedItem = null; }; listView.ItemTemplate = cell; stack.Children.Add (listView); Content = stack; }
public ActionResult Create(PodcastViewModel model) { if (!ModelState.IsValid) { return(View(model)); } else { model.GenreList = GetGenreList(); bool result = podcastDal.AddPodcast(model.Podcast); return(RedirectToAction("Detail", new { id = model.Podcast.PodcastID })); } }
protected override void GivenThat() { base.GivenThat(); ControlFile = GenerateMock <IReadOnlyControlFile>(); Podcast = new PodcastInfo(ControlFile) { Feed = new FeedInfo(ControlFile) }; PodcastViewModel = new PodcastViewModel(Podcast); ViewModel = new EditPodcastViewModel(PodcastViewModel); }
public void ShouldReturnValidModelState(string feedUrl, int expectedErrors) { // Given var podcastViewModel = new PodcastViewModel { FeedUrl = feedUrl }; var sut = new PodcastViewModelValidator(); // When ValidationResult validationResult = sut.Validate(podcastViewModel); // Then validationResult.IsValid.Should().BeTrue(); validationResult.Errors.Should().HaveCount(expectedErrors); }
private void InitSubstitutes() { var feedParser = Substitute.For <IFeedParser>(); ChannelStore = Substitute.For <IChannelStore>(); PlaylistStore = Substitute.For <IPlaylistStore>(); PodcastViewModel = new PodcastViewModel(Substitute.For <IScreen>(), Substitute.ForPartsOf <DummyPlayerModel>(), Substitute.For <IEventAggregator>(), Substitute.For <IDialogService>(), feedParser, ChannelStore, PlaylistStore); // resource service var resourceService = Substitute.For <IResourceService>(); Locator.CurrentMutable.RegisterConstant(resourceService, typeof(IResourceService)); }
private string UploadedFile(PodcastViewModel model) { string uniqueFileName = null; if (model.Audio != null) { string uploadsFolder = Path.Combine(_webHostEnvironment.WebRootPath, "audios"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Audio.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { model.Audio.CopyTo(fileStream); } } return(uniqueFileName); }
protected override void GivenThat() { base.GivenThat(); SelectedPodcast = GeneratePartialMock <PodcastViewModel>( new PodcastInfo(ControlFile) { Folder = "Original name", Feed = new FeedInfo(ControlFile) { Address = new Uri("http://www.blah.com/rss.xml") } }); ViewModel.SelectedPodcast = SelectedPodcast; }
public PodcastPage(MenuType item) { InitializeComponent(); BindingContext = new PodcastViewModel(item); listView.ItemTapped += (sender, args) => { if (listView.SelectedItem == null) { return; } Navigation.PushAsync(new PodcastPlaybackPage (listView.SelectedItem as FeedItem)); listView.SelectedItem = null; }; }
public async Task <IActionResult> Post([FromBody] PodcastViewModel vm) { if (!ModelState.IsValid) { return(BadRequest("Invalid podcast model")); } var item = _mapper.Map <PodcastViewModel, Podcast>(vm); var isNew = string.IsNullOrEmpty(vm.Id); item.AppUser = _applicationUser; var ret = _repository.AddOrUpdate(item); try { await _unitOfWork.CompleteAsync(); if (!isNew) { return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret))); } // TODO: Revisit this at some stage, horribly hacky & brittle // TODO: This should be moved to the background cache images job // TODO: And ultimately handled by imageresizer when they get their f*****g docs in order var rawImageFileName = vm.ImageUrl?.Replace(_storageSettings.CdnUrl, string.Empty).TrimStart('/'); if (string.IsNullOrEmpty(rawImageFileName)) { return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret))); } var parts = rawImageFileName.Split('/', 2); if (parts.Length != 2) { return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret))); } await _fileUtilities.CopyRemoteFile( parts[0], parts[1], _fileStorageSettings.ContainerName, $"podcast/{ret.Id.ToString()}.png"); return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret))); } catch (GenerateSlugFailureException) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
protected override void GivenThat() { base.GivenThat(); ControlFile = GenerateMock <IReadOnlyControlFile>(); var podcast = new PodcastInfo(ControlFile) { Folder = "Original Name", Feed = new FeedInfo(ControlFile) { Address = new Uri("http://www.originaladdress.com/ppp.xml") } }; ViewModel = new PodcastViewModel(podcast); }
public IActionResult Edit(int id, PodcastViewModel model) { if (!ModelState.IsValid) { model.GenreList = GetGenreList(); return(View(model)); } else { model.GenreList = GetGenreList(); bool result = podcastDal.UpdatePodacast(model.Podcast); LogChange(id, "EDIT"); return(RedirectToAction("Detail", new { id })); } }
public void ShouldGetIndex() { // Given var context = new Context <PodcastController>(); PodcastController sut = context.CreateSut(); // When ViewResult result = sut.Index() as ViewResult; // Then result.Should().NotBeNull(); result.Model.Should().BeOfType <PodcastViewModel>(); PodcastViewModel model = (PodcastViewModel)result.Model; model.FeedUrl.Should().BeNull(); model.Podcasts.Should().HaveCount(2); }
public IActionResult View(int episode) { PodcastViewModel model = new PodcastViewModel(); // find the podcast specified bool editor = User.IsInRole("Podcast"); var foundPodcast = _dbContext.Podcasts.Where(p => ((p.Published || editor) && p.Episode == episode)).FirstOrDefault(); if (foundPodcast != null) { model = new PodcastViewModel(foundPodcast); ViewBag.Title = model.Title + " | Teknikast"; return(View("~/Areas/Podcast/Views/Podcast/ViewPodcast.cshtml", model)); } model.Error = true; model.ErrorMessage = "No Podcasts Available"; return(View("~/Areas/Podcast/Views/Podcast/ViewPodcast.cshtml", model)); }
public async Task <IActionResult> Put([FromBody] PodcastViewModel vm) { if (!ModelState.IsValid || string.IsNullOrEmpty(vm.Id)) { return(BadRequest("Invalid request data")); } var podcast = _mapper.Map <PodcastViewModel, Podcast>(vm); if (podcast.AppUser is null) { podcast.AppUser = _applicationUser; } _repository.AddOrUpdate(podcast); await _unitOfWork.CompleteAsync(); return(Ok(_mapper.Map <Podcast, PodcastViewModel>(podcast))); }
public ActionResult Create(PodcastViewModel model) { if (!ModelState.IsValid) { model.GenreList = GetGenreList(); return(View(model)); } else { model.GenreList = GetGenreList(); podcastDal.CreatePodcast(model.Podcast); LogChange(model.Podcast.PodcastID, "CREATE"); return(RedirectToAction("Index")); } }
public async Task <IActionResult> New(PodcastViewModel model) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(model); Pod pod = new Pod { Title = model.Title, AudioFile = uniqueFileName, dateUploaded = model.dateUploaded, Description = model.Description, Tag = model.Tag }; _context.Add(pod); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public MainController(MainViewModel mainViewModel, PlaylistViewModel playlistViewModel, PodcastViewModel podcastViewModel, IWebService webService, PlayerViewModel playerViewModel, ILogService logService) { string baseAddress = string.Empty; username = Preferences.Get(nameof(LoginViewModel.Username), default(string), "login"); password = Preferences.Get(nameof(LoginViewModel.Password), default(string), "login"); this.mainViewModel = mainViewModel; this.playlistViewModel = playlistViewModel; this.podcastViewModel = podcastViewModel; this.playerViewModel = playerViewModel; this.webService = webService; this.logService = logService; this.mainViewModel.MenuItems = MainRepository.GetMenuItems(); this.mainViewModel.PropertyChanged += MainViewModel_PropertyChanged; this.playlistViewModel.PropertyChanged += PlaylistViewModel_PropertyChanged; this.podcastViewModel.PropertyChanged += PodcastViewModel_PropertyChanged; this.playerViewModel.PropertyChanged += PlayerViewModel_PropertyChanged; this.playlistViewModel.LoadPlaylistsCommand = new Command(async refresh => await LoadPlaylists(refresh)); this.podcastViewModel.LoadPodcastsCommand = new Command(async refresh => await LoadPodcasts(refresh)); this.podcastViewModel.PlayerCommand = new Command(GoToPlayer); this.playlistViewModel.LoadPlaylistCommand = new Command(async id => await LoadPlaylist(id)); this.podcastViewModel.LoadPodcastCommand = new Command(async id => await LoadPodcast(id)); this.playlistViewModel.PlayCommand = new Command(PlaylistPlay); this.playlistViewModel.PlayerCommand = new Command(GoToPlayer); this.podcastViewModel.PlayCommand = new Command(PodcastPlay); InitializeMediaPlayer(); #if DEBUG baseAddress = Preferences.Get("BASE_URI_DEBUG", default(string)); #else baseAddress = Preferences.Get("BASE_URI", default(string)); #endif baseUri = new Uri(baseAddress); pages = new Dictionary <Pages, NavigationPage>() { { Pages.Playlist, new NavigationPage(playlistViewModel.View) }, { Pages.Podcast, new NavigationPage(podcastViewModel.View) } }; this.mainViewModel.SelectedMenuItem = this.mainViewModel.MenuItems.FirstOrDefault(); }
public ActionResult Edit(int type, int id, int tagId, int pageNumber) { var c = _podcastService.FindByIdAsync(id).Result; if (c.TypeId == 1) { ViewBag.BreadCrump = "ویرایش آلبوم"; } var m = new PodcastViewModel { Title = c.Title, TypeId = c.TypeId, Thumbnail = c.Thumbnail, Pic = c.Pic, Id = c.Id, IsPublic = c.IsPublish, Description = c.Description, Tags = string.Join(",", c.PodcastTags.Where(d => d.Type == "tag").Select(d => d.TagId)), Category = string.Join(",", c.PodcastTags.Where(d => d.Type == "podcastcat").Select(d => d.TagId)), Auther = string.Join(",", c.PodcastTags.Where(d => d.Type == "auther").Select(d => d.TagId)), Editor = string.Join(",", c.PodcastTags.Where(d => d.Type == "editor").Select(d => d.TagId)), Speaker = string.Join(",", c.PodcastTags.Where(d => d.Type == "speaker").Select(d => d.TagId)), RegisterDate = c.PublishDateTime.ToShortPersianDateString(), PodcastTags = c.PodcastTags, RegisterTime = c.PublishDateTime != null?c.PublishDateTime.Value.ToString("h:mm:tt") : "", ContentText = c.ContentText != null?c.ContentText.Replace("../../content/files/editor/", "/content/files/editor/") .Replace("../content/files/editor/", "/content/files/editor/") .Replace("..//content/files/editor/", "/content/files/editor/") : "" }; return(View(m)); }
public async void AddPodcastAsync() { try { var corePodcast = await podcastService.GetPodcastAsync(feedUrl); var podcastModel = new PodcastViewModel(corePodcast); if (!podcasts.Contains(podcastModel)) { podcasts.Add(podcastModel); await podcastService.SavePodcastAsync(corePodcast); } else { } FeedUrl = string.Empty; } catch (GetPodcastException ex) { var result = await dialogService.ShowDialogAsync(ex.Message, "Error!", new[] { new UICommand("Retry") { Id = 0 }, new UICommand("Cancel") { Id = 1 }, new UICommand("test") {Id =2 } }, 0); if ((int)result.Id == 0) { AddPodcastAsync(); } else { } } }
public DeletePodcastMessage(PodcastViewModel podcast) { this.PodcastViewModel = podcast; }