// [Authorize]
        public ActionResult <List <WeatherAppUser> > Get()
        {
            // Console.WriteLine("Hi");
            // Console.WriteLine(c.Type);
            //  string userId = User.Claims.FirstOrDefault(c => c.Type == "Email").Value;
            // Console.WriteLine("hellow"+userId);

            return(_weatherService.Get());
        }
Exemple #2
0
        public MainPage()
        {
            InitializeComponent();
            WeatherService weatherService = new WeatherService();

            weatherService.Get();
        }
Exemple #3
0
        public async Task <IHttpActionResult> Get(string longitude, string latitude, string timestamp)
        {
            if (!LongitudeIsValid(longitude))
            {
                return(BadRequest("Invalid longitude"));
            }
            if (!LatitudeIsValid(latitude))
            {
                return(BadRequest("Invalid latitude"));
            }
            if (!TimestampIsValid(timestamp))
            {
                return(BadRequest("Invalid timestamp. Format is yyyy-MM-ddThh:mm:ss"));
            }

            DateTime informedDateTime;

            if (!DateTime.TryParse(timestamp, out informedDateTime))
            {
                return(BadRequest("Invalid date time values"));
            }

            var result = await _weatherService.Get(longitude, latitude, timestamp);

            return(Ok(result));
        }
        public Forecast WeatherService_Get_Returns_Null_When_City_Is_Empty(string city)
        {
            //Arrange
            var service = new WeatherService();

            //Act
            var result = service.Get(city, 1).Result;

            //Assert
            return(result);
        }
 public IActionResult Get()
 {
     try
     {
         var retorno = _apiService.Get();
         return(Ok(Utf8Json.JsonSerializer.ToJsonString(retorno)));
     }
     catch (TimeoutException e)
     {
         return(NotFound($"Não foi possível conectar ao servidor do banco de dados MongoDb, verifique se o serviço está ativo e estável no servidor. - Erro: {e.Message}"));
     }
     catch (Exception e)
     {
         return(NotFound(e));
     }
 }
        public async Task <Forecast> Get(string city, int days)
        {
            WeatherService weatherservice = new WeatherService();
            var            forecast       = await weatherservice.Get(city, days);

            if (forecast != null)
            {
                IUnitOfWork unitofwork = new UnitOfWork("WeatherContext");
                Request     request    = new Request
                {
                    RequestTown = forecast.city,
                    RequestDays = days,
                    RequestDate = forecast.GetDailyList()[0].date,
                    RequestImg  = forecast.GetDailyList()[0].icon,
                    RequestTemp = forecast.GetDailyList()[0].day
                };
                await unitofwork.Requests.CreateAsync(request);
            }
            return(forecast);
        }
Exemple #7
0
        public ActionResult <List <Weather> > GetByCountry(string country)
        {
            var weathers = _weatherService.Get();

            return(weathers.FindAll(w => string.Equals(w.Country, country, StringComparison.CurrentCultureIgnoreCase)));
        }
Exemple #8
0
 public ActionResult <List <Weather> > Get() =>
 _weatherService.Get();
Exemple #9
0
 public async Task <WeatherForecast[]> WeatherForecasts()
 {
     return(_service.Get().ToArray());
 }
        public async Task Get_Five_CallRepositoryWithCorrectQuantity()
        {
            await _service.Get(5);

            _repositoryMock.Verify(x => x.Get(5), Times.Once);
        }