public IActionResult Index(int?year, int?month)
        {
            if (year.HasValue && (year < DateTime.MinValue.Year || year > DateTime.MaxValue.Year))
            {
                ModelState.AddModelError("All", "The requested year is invalid");
            }
            if (month.HasValue && (month < 1 || month > 12))
            {
                ModelState.AddModelError("All", "The requested month is invalid");
            }

            if (ModelState.IsValid)
            {
                var displayMonth = new DateTime(year ?? DateTime.Today.Year, month ?? DateTime.Today.Month, 1);

                var model = new CalendarViewModel()
                {
                    CurrentMonth = displayMonth
                };

                model.Appointments =
                    _mapper.Map <IEnumerable <AppointmentViewModel> >(_appointmentService.List(model.DisplayStartDate,
                                                                                               model.DisplayEndDate));
                return(View(model));
            }

            return(View());
        }
예제 #2
0
        public void GivenDateRangeWhenFilteringThenReturnsFilteredDTOs(DateTime?dateFrom, DateTime?dateTo, int expectedResult)
        {
            var count = _service.List(dateFrom, dateTo).Count();

            Assert.That(count, Is.EqualTo(expectedResult));
        }