public void ShowModelMapsCorrectlyToDocsShow()
        {
            var showModel = new ShowModel
            {
                Title     = "The amazing .NET docs show",
                Url       = "https://www.twitch.tv/thedotnetdocs/7",
                ShowImage = "https://bitrebels.com/wp-content/uploads/2018/06/programming-languages-learn-header-image.jpg",
                VideoId   = 7,
                Tags      = new[] { "WinForms", "WPF" },
                Hosts     = new[] { new PersonModel {
                                        FirstName = "Dave", LastName = "Pine"
                                    } },
                Guests = new[] { new PersonModel {
                                     FirstName = "Chino", LastName = "Moreno"
                                 } }
            };

            DocsShow docsShow = _mapper.Map <DocsShow>(showModel);

            Assert.Equal(showModel.Id, docsShow.Id);
            Assert.Equal(showModel.Title, docsShow.Title);
            Assert.Equal(showModel.Url, docsShow.Url);
            Assert.Equal(showModel.ShowImage, docsShow.ShowImage);
            Assert.Equal(showModel.VideoId, docsShow.VideoId);
            Assert.Equal(showModel.Tags, docsShow.Tags);

            AssertPeopleAreEqual(showModel.Hosts, docsShow.Hosts);
            AssertPeopleAreEqual(showModel.Guests, docsShow.Guests);
        }
        public async ValueTask <bool> CreateShowCalendarInviteAsync(DocsShow show)
        {
            try
            {
                DateTimeOffset showTime = show.Date !.Value;
                string         bodyText =
                    $"<strong>🕚</strong> 30 mins before the show, work through the <a href='https://aka.ms/go-live-checklist'>go-live checklist</a>.<br>" +
                    $"<strong>📺</strong> <a href='{show.GuestStreamUrl}'>Join the stream</a>.<br>" +
                    $"<strong>👋</strong> <a href='https://dotnetdocs.dev/show/{show.Id}'>Share your episode to help boost viewership</a>.";

                string json = JsonConvert.SerializeObject(new
                {
                    to        = string.Join(";", show.Guests.Select(g => g.Email).Concat(new[] { "*****@*****.**" })),
                    title     = $"The .NET Docs Show: {show.Title}",
                    body      = bodyText,
                    startTime = $"{showTime:yyyy-MM-ddThh:mm:ss}",
                    endTime   = $"{showTime.AddHours(1):yyyy-MM-ddThh:mm:ss}",
                });

                using var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage?response = await _client.PostAsync(_settings.PostCalendarUrl, content);

                if (response != null)
                {
                    response.EnsureSuccessStatusCode();
                    return(true);
                }
            }
Beispiel #3
0
        public async ValueTask <DocsShow> CreateShowAsync(DocsShow show)
        {
            string?showFileName = $"{show.Id}.json";
            string?json         = JsonConvert.SerializeObject(show);

            await File.WriteAllTextAsync(showFileName, json);

            return(show);
        }
Beispiel #4
0
        public ValueTask <bool> CreateShowCalendarInviteAsync(DocsShow show)
        {
            DateTimeOffset showTime = show.Date !.Value;
            string         bodyText =
                $"<strong>🕚</strong> 30 mins before the show, work through the <a href='https://aka.ms/go-live-checklist'>go-live checklist</a>.<br>" +
                $"<strong>📺</strong> <a href='{show.GuestStreamUrl}'>Join the stream</a>.<br>" +
                $"<strong>👋</strong> <a href='https://dotnetdocs.dev/show/{show.Id}'>Share your episode to help boost viewership</a>.";

            return(PostJsonAsync(new
            {
                to = string.Join(";", show.Guests.Select(g => g.Email).Concat(new[] { "*****@*****.**" })),
                title = $"The .NET Docs Show: {show.Title}",
                body = bodyText,
                startTime = $"{showTime:yyyy-MM-ddThh:mm:ss}",
                endTime = $"{showTime.AddHours(1):yyyy-MM-ddThh:mm:ss}",
            },
        public static string ToDateString(this DocsShow show)
        {
            if (!show.IsScheduled)
            {
                return("TBD");
            }

            // TODO: fix this
            var dateTime = show.Date !.Value;
            var timeSpan = DateTimeOffset.Now.Subtract(dateTime);
            var dayDiff  = (int)timeSpan.TotalDays;
            var secDiff  = (int)timeSpan.TotalSeconds;

            if (dayDiff < 0 || dayDiff >= 31)
            {
                return($"{dateTime:MMM dd, yyyy}");
            }
Beispiel #6
0
        static void WriteShowDetails(DocsShow show)
        {
            if (show is null)
            {
                Console.WriteLine("Show is null... sadface!");
                return;
            }

            Console.WriteLine($"{show.Title} {(show.IsInFuture ? "airs" : "aired")} on {show.Date:MMM dd, yyyy}");
            foreach (Person host in show.Hosts)
            {
                WritePersonDetails(host, "Host");
            }
            foreach (Person guest in show.Guests)
            {
                WritePersonDetails(guest, "Guest");
            }
        }
        public void DocsShowMapsCorrectlyToShowModel()
        {
            var docsShow = new DocsShow
            {
                Date      = DateTimeOffset.Parse("2020-07-02T11:00:00-05:00"),
                Title     = "The amazing .NET docs show",
                Url       = "https://www.twitch.tv/thedotnetdocs",
                ShowImage = "https://bitrebels.com/wp-content/uploads/2018/06/programming-languages-learn-header-image.jpg"
            };

            ShowModel showModel = _mapper.Map <ShowModel>(docsShow);

            Assert.Equal(docsShow.Id, showModel.Id);
            Assert.Equal(docsShow.Title, showModel.Title);
            Assert.Equal(docsShow.Url, showModel.Url);
            Assert.Equal(docsShow.ShowImage, showModel.ShowImage);
            Assert.Equal(docsShow.VideoId, showModel.VideoId);
            Assert.Equal(docsShow.Tags, showModel.Tags);

            AssertPeopleAreEqual(docsShow.Hosts, showModel.Hosts);
            AssertPeopleAreEqual(docsShow.Guests, showModel.Guests);
        }
        public void GetSegmentedShowsCorrectlySegmentsWhenDaysOff()
        {
            var utcDate   = new DateTimeOffset(2020, 5, 29, 11, 0, 0, TimeSpan.FromHours(-5));
            var startDate = _systemUnderTest.ConvertFromUtc(utcDate.UtcDateTime);
            var shows     = new[]
            {
                DocsShow.CreatePlaceholder(startDate),
                DocsShow.CreatePlaceholder(startDate.AddDays(7)),
                DocsShow.CreatePlaceholder(startDate.AddDays(14)),
                DocsShow.CreatePlaceholder(startDate.AddDays(21)),
                DocsShow.CreatePlaceholder(startDate.AddDays(28))
            };

            var segmentedShows =
                _systemUnderTest.GetSegmentedShows(shows, utcDate.UtcDateTime.AddDays(15), true);

            Assert.NotNull(segmentedShows);
            Assert.NotNull(segmentedShows.PastShows);
            Assert.NotNull(segmentedShows.NextShow);
            Assert.NotNull(segmentedShows.FutureShows);

            Assert.Equal(startDate.AddDays(21), segmentedShows.NextShow.Date);
        }
Beispiel #9
0
 void OnConfirmDelete(DocsShow show)
 {
     _show      = show;
     _showModal = true;
 }
Beispiel #10
0
        internal static (bool isSuccessful, string?url, MarkupString icon) TryGetTooLongDontReadUrl(this DocsShow show)
        {
            string?tldrUrl = show?.TldrUrl;

            if (show is null || string.IsNullOrWhiteSpace(tldrUrl))
            {
                return(false, null, new MarkupString(null));
            }

            var uri = new Uri(tldrUrl);