Example #1
0
        public TimeDTO Map(WorldTimeDTO mapEntity)
        {
            long unixTime = DateTimeUtils.GetUnixTimeFromDateTime(mapEntity.datetime);

            TimeDTO timeDTO = new TimeDTO();

            timeDTO.Time = DateTimeUtils.GetDateTimeFromUnixSeconds(unixTime);

            return(timeDTO);
        }
Example #2
0
        public async Task <TimeDTO> GetTimeFromIp(string ip)
        {
            try
            {
                string fullUrl = _worldTimeAPIUrl + ip;

                WorldTimeDTO worldTimeDTO = await this._genericRestService.Get <WorldTimeDTO>(fullUrl);

                if (!this.IsValid(worldTimeDTO))
                {
                    throw new NoTimeFoundException();
                }

                TimeDTO timeDTO = this._worldTimeMapper.Map(worldTimeDTO);

                return(timeDTO);
            }
            catch (NotFoundException)
            {
                throw new NoTimeFoundException();
            }
        }
Example #3
0
        private bool IsValid(WorldTimeDTO worldTimeDTO)
        {
            bool isValid = (worldTimeDTO != null);

            return(isValid);
        }