コード例 #1
0
        public async Task <ActionResult <IEnumerable <Object> > > GetDates(string annee)
        {
            IEnumerable <Parameter> CurrentScholarYear = await _parameterRepository.GetByCodeAsync("CurrentScholarYear");

            DateTime Start;
            string   anneededebut = CurrentScholarYear.First().Value.Split('-')[0];

            if (anneededebut == annee)
            {
                IEnumerable <Parameter> datededebut = await _parameterRepository.GetByCodeAsync("ScholarYearBeginning");

                Start = DateTime.Parse(datededebut.First().Value + " " + anneededebut);
            }
            else
            {
                Start = DateTime.Parse("January 1 " + annee);
            }
            DateTime End;
            string   anneedefin = CurrentScholarYear.First().Value.Split('-')[1];

            if (anneedefin == annee)
            {
                IEnumerable <Parameter> datedefin = await _parameterRepository.GetByCodeAsync("ScholarYearEnd");

                End = DateTime.Parse(datedefin.First().Value + " " + anneedefin);
            }
            else
            {
                End = DateTime.Parse("December 31 " + annee);
            }
            IEnumerable <Object> dates = await _parameterRepository.GetDates(Start, End);

            if (dates == null)
            {
                return(NotFound());
            }

            return(Ok(dates));
        }