Exemplo n.º 1
0
        public ActionResult New(Episode episode)
        {
            episode.DownloadSize = Util.GetFileLength(episode.DownloadLink);
            int episodeId = this._episodeService.AddEpisode(episode);

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public int AddEpisode(Episode episode)
        {
            int id = 0;

            episode.DateAdded = DateTime.UtcNow;

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                episode.UpdatedOn = episode.DateAdded;

                episode.Title = episode.Title.TrimEnd();
                episode.Title = episode.Title.Replace("–", "-");
                episode.Description = episode.Description.Replace("–", "-");
                episode.Description = episode.Description.Replace("<P>", "<p>");
                episode.Description = episode.Description.Replace("</P>", "</p>");
                episode.Description = episode.Description.Replace("<br>", "<br />");
                episode.Description = episode.Description.Replace("<p></p>", "");

                episode.Slug = GetSlug(episode.Title);

                while (GetEpisodes().Where(e => e.Slug == episode.Slug).SingleOrDefault() != null)
                {
                    episode.Slug += string.Format("-{0}", episode.DateAdded.Year.ToString());
                }

                episode.EpisodeNumber = GetEpisodes().Count() + 1;

                session.Store(episode);
                session.SaveChanges();

                id = episode.Id;
            }

            return id;
        }
Exemplo n.º 3
0
        public ActionResult Edit(int episodeId, Episode episode, bool updateDate)
        {
            episode.Id = episodeId;
            episode.DownloadSize = Util.GetFileLength(episode.DownloadLink);
            this._episodeService.EditEpisode(episode, updateDate);

            return RedirectToAction("Index");
        }
Exemplo n.º 4
0
        public void EditEpisode(Episode episode, bool? updateDate)
        {
            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                Episode editedEpisode = session.Load<Episode>
                    (string.Format("episodes/{0}", episode.Id.ToString()));

                editedEpisode.Title = episode.Title;
                editedEpisode.Description = episode.Description;
                editedEpisode.IsPublished = episode.IsPublished;
                editedEpisode.Links = episode.Links;
                editedEpisode.Guests = episode.Guests;
                editedEpisode.Summary = episode.Summary;
                editedEpisode.Duration = episode.Duration;
                if (updateDate.Value)
                    editedEpisode.DateAdded = DateTime.UtcNow;
                editedEpisode.UpdatedOn = DateTime.UtcNow;
                editedEpisode.GuestBiography = episode.GuestBiography;
                editedEpisode.DownloadLink = episode.DownloadLink;
                editedEpisode.DownloadSize = episode.DownloadSize;

                session.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public Episode GetEpisode(int id)
        {
            Episode episode = new Episode();

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                episode = session.Query<Episode>().Where(e => e.Id == id).SingleOrDefault();
            }

            return episode;
        }