Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Helios
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Lorych
Helios
Commits
40206466
Commit
40206466
authored
3 years ago
by
Daniel Lorych
Browse files
Options
Downloads
Patches
Plain Diff
Hardcod values to user class as proof of concept
parent
31296875
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Helios/Controllers/UserController.cs
+9
-1
9 additions, 1 deletion
Helios/Controllers/UserController.cs
Helios/Models/User.cs
+5
-2
5 additions, 2 deletions
Helios/Models/User.cs
Helios/Source/UserService.cs
+58
-0
58 additions, 0 deletions
Helios/Source/UserService.cs
with
72 additions
and
3 deletions
Helios/Controllers/UserController.cs
+
9
−
1
View file @
40206466
...
@@ -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
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Helios/Models/User.cs
+
5
−
2
View file @
40206466
...
@@ -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
>();
}
}
}
}
This diff is collapsed.
Click to expand it.
Helios/Source/UserService.cs
+
58
−
0
View file @
40206466
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
;
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment