Changing for make everything work again
This commit is contained in:
@@ -45,9 +45,11 @@ namespace IdentityDemo.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult _login(string username, string password)
|
public ActionResult _login(string username, string password)
|
||||||
{
|
{
|
||||||
JsonResponse response = new JsonResponse();
|
JsonResponse response = new JsonResponse
|
||||||
response.Success = false;
|
{
|
||||||
response.Message = "Username or password is invalid.";
|
Success = false,
|
||||||
|
Message = "Username or password is invalid."
|
||||||
|
};
|
||||||
|
|
||||||
var strunz = Db.GetTable<User>().Where(user => user.Username.Equals(username) && user.Password.Equals(password)).ToListAsync().Result;
|
var strunz = Db.GetTable<User>().Where(user => user.Username.Equals(username) && user.Password.Equals(password)).ToListAsync().Result;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ namespace SeniorAssistant.Controllers
|
|||||||
[Route("User/{User}")]
|
[Route("User/{User}")]
|
||||||
public IActionResult SingleUser(string user)
|
public IActionResult SingleUser(string user)
|
||||||
{
|
{
|
||||||
|
if(session.GetString("username") == null)
|
||||||
|
return RedirectToAction("Index");
|
||||||
return View("data", user);
|
return View("data", user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace SeniorAssistant.Models
|
|||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
[Association(ThisKey = nameof(Username), OtherKey = nameof(User.Username), CanBeNull = false)]
|
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
@@ -15,5 +14,10 @@ namespace SeniorAssistant.Models
|
|||||||
public DateTime Time { get; set; }
|
public DateTime Time { get; set; }
|
||||||
|
|
||||||
public double Value { get; set; }
|
public double Value { get; set; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
[Association(ThisKey = nameof(Username), OtherKey = nameof(User.Username), CanBeNull = false)]
|
||||||
|
public User UserObj { get; set; }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace SeniorAssistant.Models
|
|||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
[Association(ThisKey = nameof(Username), OtherKey = nameof(User.Username), CanBeNull = false)]
|
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace SeniorAssistant.Models
|
|||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
[NotNull]
|
[NotNull]
|
||||||
[Association(ThisKey = nameof(Username), OtherKey = nameof(User.Username), CanBeNull = false)]
|
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
using LinqToDB.Mapping;
|
using LinqToDB.Mapping;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SeniorAssistant.Models
|
namespace SeniorAssistant.Models
|
||||||
{
|
{
|
||||||
public class User : IHasUsername
|
public class User : IHasUsername
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[Column(IsPrimaryKey = true, CanBeNull = false)]
|
||||||
[NotNull]
|
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
|
[JsonIgnore]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace SeniorAssistant
|
|||||||
using (var db = dataContext.Create())
|
using (var db = dataContext.Create())
|
||||||
{
|
{
|
||||||
const string baseUsername = "vecchio";
|
const string baseUsername = "vecchio";
|
||||||
string[] users = { "Mario", "Giovanni", "Aldo", "Giacomo", "Marcello", "Filippo" };
|
string[] names = { "Mario", "Giovanni", "Aldo", "Giacomo", "Marcello", "Filippo" };
|
||||||
|
|
||||||
db.CreateTableIfNotExists<Heartbeat>();
|
db.CreateTableIfNotExists<Heartbeat>();
|
||||||
db.CreateTableIfNotExists<Sleep>();
|
db.CreateTableIfNotExists<Sleep>();
|
||||||
@@ -130,7 +130,7 @@ namespace SeniorAssistant
|
|||||||
{
|
{
|
||||||
db.CreateTable<User>();
|
db.CreateTable<User>();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (string user in users)
|
foreach (string user in names)
|
||||||
{
|
{
|
||||||
var username = baseUsername + count;
|
var username = baseUsername + count;
|
||||||
db.InsertOrReplace(new User { Name = user, Username = username, Password = username, Email = username + "@email.st" } );
|
db.InsertOrReplace(new User { Name = user, Username = username, Password = username, Email = username + "@email.st" } );
|
||||||
@@ -145,7 +145,7 @@ namespace SeniorAssistant
|
|||||||
now = now.AddHours(DateTime.Now.Hour).AddMinutes(30);
|
now = now.AddHours(DateTime.Now.Hour).AddMinutes(30);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double totalHours = 50;
|
double totalHours = 48;
|
||||||
try {
|
try {
|
||||||
DateTime maxTimeInDB = db.GetTable<Heartbeat>().MaxAsync(x => x.Time).Result;
|
DateTime maxTimeInDB = db.GetTable<Heartbeat>().MaxAsync(x => x.Time).Result;
|
||||||
TimeSpan span = now.Subtract(maxTimeInDB);
|
TimeSpan span = now.Subtract(maxTimeInDB);
|
||||||
@@ -155,21 +155,17 @@ namespace SeniorAssistant
|
|||||||
for (int i = 0; i<totalHours; i++)
|
for (int i = 0; i<totalHours; i++)
|
||||||
{
|
{
|
||||||
DateTime time = now.AddHours(-i);
|
DateTime time = now.AddHours(-i);
|
||||||
for (int num = 0; num < users.Length; num++)
|
for (int num = 0; num < names.Length; num++)
|
||||||
{
|
{
|
||||||
string user = baseUsername + num;
|
string user = baseUsername + num;
|
||||||
|
|
||||||
if (time.Day != now.Day)
|
if (time.Day != now.Day && time.Hour == 21)
|
||||||
{
|
{
|
||||||
db.Insert(new Sleep() { Username = user, Time = time, Value = rnd.Next(5 * 3600000, 9 * 3600000) });
|
db.Insert(new Sleep() { Username = user, Time = time, Value = rnd.Next(5 * 3600000, 9 * 3600000) });
|
||||||
}
|
}
|
||||||
db.Insert(new Heartbeat() { Username = user, Time = time, Value = rnd.Next(50, 120) });
|
db.Insert(new Heartbeat() { Username = user, Time = time, Value = rnd.Next(50, 120) });
|
||||||
db.Insert(new Step() { Username = user, Time = time, Value = rnd.Next(100, 500) });
|
db.Insert(new Step() { Username = user, Time = time, Value = rnd.Next(100, 500) });
|
||||||
}
|
}
|
||||||
if (time.Day != now.Day)
|
|
||||||
{
|
|
||||||
now = now.AddDays(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user