public TimeDTO Map(WorldTimeDTO mapEntity) { long unixTime = DateTimeUtils.GetUnixTimeFromDateTime(mapEntity.datetime); TimeDTO timeDTO = new TimeDTO(); timeDTO.Time = DateTimeUtils.GetDateTimeFromUnixSeconds(unixTime); return(timeDTO); }
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(); } }
private bool IsValid(WorldTimeDTO worldTimeDTO) { bool isValid = (worldTimeDTO != null); return(isValid); }