예제 #1
0
        public MyDayViewModel GetWeather()
        {
            string jsonString  = "";
            string apiEndPoint = "http://localhost:20208/api/weather?zip={0}";

            var currentUserID       = User.Claims.ToList()[0].Value; // TODO: unsure if this is right, double check!
            var locations           = _context.Location.ToList();
            var currentUserLocation = locations.SingleOrDefault(l => l.UserID == currentUserID).Zip;

            string apiString = string.Format(apiEndPoint, currentUserLocation);

            jsonString = apiCall.GetJSONStringFromAPI(apiString);

            var weather = JsonConvert.DeserializeObject <WeatherDTO>(jsonString);

            // TODO: separate the reminders part
            MyDayViewModel viewModel = new MyDayViewModel()
            {
                WeatherInfo = weather,
                Reminders   = new List <Reminder>()
            };

            return(viewModel);
        }