Beispiel #1
0
        // 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);
        }