- @Model.Current.LastUpdated @Model.Current.Temperature
+
+
@Model.Current.Temperature°F
+
@Model.Current.ConditionName
diff --git a/WeatherDashboard.Web/wwwroot/css/site.css b/WeatherDashboard.Web/wwwroot/css/site.css
index f050848..5c3f609 100644
--- a/WeatherDashboard.Web/wwwroot/css/site.css
+++ b/WeatherDashboard.Web/wwwroot/css/site.css
@@ -1,12 +1,12 @@
html {
- font-size: 14px;
+ font-size: 20px;
}
-@media (min-width: 768px) {
+/*@media (min-width: 768px) {
html {
font-size: 16px;
}
-}
+}*/
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
@@ -19,5 +19,23 @@ html {
body {
font-family: 'Montserrat', sans-serif;
- color: #777;
+ color: #444;
+ margin:40px;
+ background-color: floralwhite;
+}
+
+.location small {
+ font-size: 14px;
+}
+
+.degrees {
+ font-size: 50px;
+ position: absolute;
+ margin: 20px 0 0 10px;
+ opacity: .6;
+}
+
+.current-temperature {
+ font-size: 100px;
+ font-weight: 500;
}
\ No newline at end of file
diff --git a/WeatherDashboard/CurrentForecast.cs b/WeatherDashboard/CurrentForecast.cs
index c13cc68..616e563 100644
--- a/WeatherDashboard/CurrentForecast.cs
+++ b/WeatherDashboard/CurrentForecast.cs
@@ -2,6 +2,7 @@
namespace WeatherDashboard
{
+ [JsonConverter(typeof(JsonPathConverter))]
public class CurrentForecast
{
[JsonProperty("last_updated")]
@@ -9,5 +10,8 @@ namespace WeatherDashboard
[JsonProperty("temp_f")]
public decimal Temperature { get; set; }
+
+ [JsonProperty("condition.text")]
+ public string ConditionName { get; set; }
}
}
\ No newline at end of file
diff --git a/WeatherDashboard/JsonPathConverter.cs b/WeatherDashboard/JsonPathConverter.cs
new file mode 100644
index 0000000..2a466df
--- /dev/null
+++ b/WeatherDashboard/JsonPathConverter.cs
@@ -0,0 +1,40 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.Reflection;
+
+namespace WeatherDashboard
+{
+ public class JsonPathConverter : JsonConverter
+ {
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ var jsonObject = JObject.Load(reader);
+ var target = Activator.CreateInstance(objectType);
+
+ foreach (PropertyInfo prop in objectType.GetProperties().Where(p => p.CanRead && p.CanWrite))
+ {
+ var attribute = prop
+ .GetCustomAttributes(true)
+ .OfType
()
+ .FirstOrDefault();
+
+ var jsonPath = (attribute != null ? attribute.PropertyName : prop.Name);
+ var token = jsonObject.SelectToken(jsonPath);
+
+ if (token != null && token.Type != JTokenType.Null)
+ {
+ object value = token.ToObject(prop.PropertyType, serializer);
+ prop.SetValue(target, value, null);
+ }
+ }
+
+ return target;
+ }
+ // CanConvert is not called when [JsonConverter] attribute is used
+ public override bool CanConvert(Type objectType) => false;
+
+ public override bool CanWrite => false;
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotImplementedException();
+ }
+}