public AnswerResponse AnswerQuestion(int questionNumber)
        {
            if (questionNumber == 1)
            {
                CountryPublicHoliday result = this.publicHolidaysOperations.GetMaxHolidaysCountry(2019);
                if (result != null)
                {
                    this.answerResponse = FormatFirstQuestionAnswerResponse(result);
                }
                else
                {
                    return(GetExceptionAnswerResponse(ExceptionMessageString));
                }
            }

            else if (questionNumber == 2)
            {
                HolidaysMonth result = this.publicHolidaysOperations.GetMaxHolidaysMonthGlobally(2019);
                if (result != null)
                {
                    this.answerResponse = FormatSecondQuestionAnswerResponse(result);
                }
                else
                {
                    return(GetExceptionAnswerResponse(ExceptionMessageString));
                }
            }

            else if (questionNumber == 3)
            {
                CountryPublicHoliday result = this.publicHolidaysOperations.GetMaxUniqueHolidaysCountry(2019);
                if (result != null)
                {
                    this.answerResponse = FormatThirdQuestionAnswerResponse(result);
                }
                else
                {
                    return(GetExceptionAnswerResponse(ExceptionMessageString));
                }
            }

            else
            {
                return(GetExceptionAnswerResponse("Question number is not provided, Please pass correct question number."));
            }

            this.answerResponse.Status = true;
            return(this.answerResponse);
        }
        private AnswerResponse FormatSecondQuestionAnswerResponse(HolidaysMonth result)
        {
            AnswerResponse formattedResponse = new AnswerResponse();

            formattedResponse.AdditionalInfo = new List <string>();
            formattedResponse.QuestionString = SecondQuestionString;
            formattedResponse.Answer         = result.MonthName;
            result.Holidays.Sort();
            foreach (var day in result.Holidays)
            {
                formattedResponse.AdditionalInfo.Add(string.Format("Day: {0} is public holiday globally", day.ToString()));
            }
            formattedResponse.Explanation = string.Format("The month contains {0} Holidays in 2019!", result.Holidays.Count);
            return(formattedResponse);
        }
        public HolidaysMonth GetMaxHolidaysMonthGlobally(int year)
        {
            var allHolidays = this._publicHolidaysService.GetPublicHolidaysByYear(year);

            if (allHolidays != null && allHolidays.Result != null && allHolidays.Result.Status == true)
            {
                HolidaysMonth        result        = new HolidaysMonth();
                int                  maxMonthCount = 0;
                List <HolidaysMonth> monthsCount   = GetMonthsCount();

                foreach (CountryPublicHoliday country in allHolidays.Result.CountryPublicHolidays)
                {
                    foreach (PublicHoliday holiday in country.PublicHolidays)
                    {
                        if (holiday.Global)
                        {
                            if (!monthsCount[holiday.Date.Month - 1].Holidays.Contains(holiday.Date.Day))
                            {
                                monthsCount[holiday.Date.Month - 1].Holidays.Add(holiday.Date.Day);
                            }
                        }
                    }
                }

                foreach (var item in monthsCount)
                {
                    if (item.Holidays.Count > maxMonthCount)
                    {
                        result.MonthName = item.MonthName;
                        result.Holidays  = item.Holidays;
                        maxMonthCount    = item.Holidays.Count;
                    }
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }