コード例 #1
0
ファイル: Calendar.cshtml.cs プロジェクト: marekott/BandCams
        private Task <List <OnlineEvent> > GetEventsInMonth(DateTime date)
        {
            var fromDate = date.AddDays(-8); //ponieważ widoczna jest zmienna liczba dni z przeszłego i przyszłego miesiąca
            var toDate   = date.AddDays(45);

            return(_httpHelper.GetAsync <List <OnlineEvent> >(BandCamsEndpoints.GetOnlineEvent(fromDate, toDate)));
        }
コード例 #2
0
        public async Task OnGet()
        {
            var today = DateTime.Now;

            Streams = await _httpHelper.GetAsync <List <Stream> >(BandCamsEndpoints.GetStream(true));

            OnlineEvents = await _httpHelper.GetAsync <List <OnlineEvent> > (BandCamsEndpoints.GetOnlineEvent(today, today.AddDays(7)));
        }
コード例 #3
0
        public async Task <PartialViewResult> OnGetShowModal(int streamId)
        {
            var stream = await _httpHelper.GetAsync <Stream>(BandCamsEndpoints.GetStream(streamId));

            return(new PartialViewResult
            {
                ViewName = "_StreamVideoPartial",
                ViewData = new ViewDataDictionary <Stream>(ViewData, stream)
            });
        }
コード例 #4
0
        public void GetStreamIsActiveFalseTest()
        {
            // arrange
            const string excepted = "/api/Stream?isActive=false";

            // act
            var actual = BandCamsEndpoints.GetStream(false);

            // assert
            StringAssert.AreEqualIgnoringCase(excepted, actual);
        }
コード例 #5
0
        public void GetStreamTest()
        {
            // arrange
            var randomId = new Random().Next(1, 20);
            var expected = $"/api/Stream/{randomId}";

            // act
            var actual = BandCamsEndpoints.GetStream(randomId);

            // assert
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
コード例 #6
0
ファイル: Calendar.cshtml.cs プロジェクト: marekott/BandCams
        public async Task <PartialViewResult> OnGetShowModal(int year, int month, int day)
        {
            var passedDate = new DateTime(year, month, day);

            OnlineEvents = await _httpHelper.GetAsync <List <OnlineEvent> >(BandCamsEndpoints.GetOnlineEvent(passedDate, passedDate.AddDays(1)));

            return(new PartialViewResult
            {
                ViewName = "_OnlineEventsPartial",
                ViewData = new ViewDataDictionary <List <OnlineEvent> >(ViewData, OnlineEvents)
            });
        }
コード例 #7
0
        public void GetOnlineEventInDatesTest()
        {
            // arrange
            var now      = DateTime.Now;
            var tomorrow = now.AddDays(1);
            var expected = $"/api/OnlineEvent?fromDate={now.Year}-{now.Month}-{now.Day}&toDate={tomorrow.Year}-{tomorrow.Month}-{tomorrow.Day}";

            // act
            var actual = BandCamsEndpoints.GetOnlineEvent(now, tomorrow);

            // assert
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
コード例 #8
0
        public async Task <IActionResult> OnGet(int id)
        {
            try
            {
                OnlineEvent = await _httpHelper.GetAsync <OnlineEvent>(BandCamsEndpoints.GetOnlineEvent(id));

                return(Page());
            }
            catch (Exception)//TODO porządna obsługa - słabe rozwiązanie bo każdy wyjątek kalsyfikujemy jakby api zwróciło 404
            {
                return(NotFound());
            }
        }