Skip to content
Snippets Groups Projects
Commit 40206466 authored by Daniel Lorych's avatar Daniel Lorych :cookie:
Browse files

Hardcod values to user class as proof of concept

parent 31296875
Branches
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Helios.Source;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
...@@ -10,7 +11,12 @@ namespace Helios.Controllers ...@@ -10,7 +11,12 @@ namespace Helios.Controllers
{ {
public class UserController : Controller public class UserController : Controller
{ {
private readonly UserService _userService;
public UserController(UserService service)
{
_userService = service;
}
public IActionResult Admin() public IActionResult Admin()
{ {
...@@ -19,7 +25,9 @@ namespace Helios.Controllers ...@@ -19,7 +25,9 @@ namespace Helios.Controllers
public IActionResult User() public IActionResult User()
{ {
return View(); var user = _userService.GetUser();
return View(user);
} }
} }
} }
......
...@@ -3,7 +3,10 @@ namespace Helios.Models ...@@ -3,7 +3,10 @@ namespace Helios.Models
{ {
public class User public class User
{ {
public User() { } public int SolarInput { get; set; }
public int BatteryCharge { get; set; }
public BatteryStatus BatteryStatus { get; set; }
public List<ChargeTimestamp> ChargeTimestamps { get; set; } = new List<ChargeTimestamp>();
} }
} }
using System; using System;
using Helios.Models;
using Npgsql; using Npgsql;
namespace Helios.Source namespace Helios.Source
...@@ -6,14 +7,71 @@ namespace Helios.Source ...@@ -6,14 +7,71 @@ namespace Helios.Source
public class UserService public class UserService
{ {
private readonly NpgsqlConnection _connection; private readonly NpgsqlConnection _connection;
private int userId = 7;
public UserService(string connectionString) public UserService(string connectionString)
{ {
_connection = new NpgsqlConnection(connectionString); _connection = new NpgsqlConnection(connectionString);
} }
public User GetUser()
{
User user = new User();
user.ChargeTimestamps = GetChargeTimestamps();
user.SolarInput = GetSolarInput();
user.BatteryCharge = GetBatteryCharge();
user.BatteryStatus = GetBatteryStatus();
return user;
}
private List<ChargeTimestamp> GetChargeTimestamps()
{
List<ChargeTimestamp> timestamps = new List<ChargeTimestamp>
{
new ChargeTimestamp(DateTimeOffset.Parse("01:00 AM"), 100),
new ChargeTimestamp(DateTimeOffset.Parse("02:00 AM"), 98),
new ChargeTimestamp(DateTimeOffset.Parse("03:00 AM"), 96),
new ChargeTimestamp(DateTimeOffset.Parse("04:00 AM"), 94),
new ChargeTimestamp(DateTimeOffset.Parse("05:00 AM"), 92),
new ChargeTimestamp(DateTimeOffset.Parse("06:00 AM"), 90),
new ChargeTimestamp(DateTimeOffset.Parse("07:00 AM"), 83),
new ChargeTimestamp(DateTimeOffset.Parse("08:00 AM"), 80),
new ChargeTimestamp(DateTimeOffset.Parse("09:00 AM"), 71),
new ChargeTimestamp(DateTimeOffset.Parse("10:00 AM"), 64),
new ChargeTimestamp(DateTimeOffset.Parse("11:00 AM"), 60),
new ChargeTimestamp(DateTimeOffset.Parse("12:00 PM"), 61),
new ChargeTimestamp(DateTimeOffset.Parse("13:00 PM"), 62),
new ChargeTimestamp(DateTimeOffset.Parse("14:00 PM"), 60),
new ChargeTimestamp(DateTimeOffset.Parse("15:00 PM"), 55),
new ChargeTimestamp(DateTimeOffset.Parse("16:00 PM"), 51),
new ChargeTimestamp(DateTimeOffset.Parse("17:00 PM"), 48),
new ChargeTimestamp(DateTimeOffset.Parse("18:00 PM"), 43),
new ChargeTimestamp(DateTimeOffset.Parse("19:00 PM"), 36),
new ChargeTimestamp(DateTimeOffset.Parse("20:00 PM"), 30),
new ChargeTimestamp(DateTimeOffset.Parse("21:00 PM"), 71),
new ChargeTimestamp(DateTimeOffset.Parse("22:00 PM"), 71),
new ChargeTimestamp(DateTimeOffset.Parse("23:00 PM"), 71),
};
return timestamps;
}
private int GetSolarInput()
{
return 77;
}
private int GetBatteryCharge()
{
return 45;
}
private BatteryStatus GetBatteryStatus()
{
return BatteryStatus.Charging;
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment