// TODO: rewrite this method public EditPodcastViewModel Edit(int podcastId) { var podcast = _podcastRepository.GetPodcastForEdit(podcastId); var viewModel = new EditPodcastViewModel { Id = podcast.Id, Title = podcast.Title, Description = podcast.Description, ImageUrl = podcast.ImageUrl, FeedUrl = podcast.FeedUrl, SiteUrl = podcast.SiteUrl }; var tags = _tagsRepository .GetAll() .ToList(); foreach (var tag in tags) { viewModel.Tags.Add(new CheckBoxListItem { Id = tag.TagId, Display = tag.Name }); } foreach (var tag in podcast.Tags) { var t = viewModel.Tags.Single(i => i.Id == tag.Id); t.IsChecked = true; } return(viewModel); }
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 async Task UpdatePodcast(EditPodcastViewModel model) { var selectedTags = model .Tags .Where(i => i.IsChecked) .Select(i => new TagDto { Id = i.Id, }); var dto = new PodcastDto { Id = model.Id, Title = model.Title, Description = model.Description, ImageUrl = model.ImageUrl, FeedUrl = model.FeedUrl, SiteUrl = model.SiteUrl, Tags = selectedTags }; await _podcastRepository.UpdatePodcast(dto); }
public EditPodcastWindow(PodcastViewModel podcastViewModel) { DataContext = new EditPodcastViewModel(podcastViewModel); InitializeComponent(); }
public async Task <ActionResult> Edit(EditPodcastViewModel model) { await _podcastService.UpdatePodcast(model); return(RedirectToAction("ManagePodcasts", "Admin")); }