Exemplo n.º 1
0
        /// <summary>
        /// This method returns zodiac sign depending on user's birthday
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ZodiacSign GetZodiacSign(User user)
        {
            ZodiacSign result = _zodiacSignList[11]; // last one - Capricorn, so foreach can work correctly

            foreach (ZodiacSign zodiac in _zodiacSignList)
            {
                if (user.Birthday.DayOfYear >= zodiac.StartDate.DayOfYear
                    &&
                    user.Birthday.DayOfYear < zodiac.EndDate.DayOfYear)
                {
                    result = zodiac;
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// load predictions using HoroscopePersistService. This can throw IO exception
        /// </summary>
        /// <returns></returns>
        public List <ZodiacSign> LoadData()
        {
            // load data from files only if it is not in the list
            if (_zodiacSignList.Count == 0)
            {
                _hpService.LoadHoroscope();

                foreach (ZodiacSignInfo item in _hpService.GetZodiacSignInfo())
                {
                    ZodiacSign zodiac = new ZodiacSign(item.Id, item.Sign, item.ImagePath, item.StartDate, item.EndDate);
                    // copy prediction from ZodiacInfo.PredictionList to ZodiacSign.PredictionList
                    foreach (string prediction in item.PredictionList)
                    {
                        zodiac.PredictionList.AddPrediction(prediction);
                    }
                    _zodiacSignList.Add(zodiac);
                }
            }
            return(_zodiacSignList);
        }