CRUD configuration MVC with Firebase
public string TimestampUtc { get; set; }
CRUD configuration MVC with Firebase
public string TimestampUtc { get; set; }
CRUD configuration MVC with Firebase
public async Task<ActionResult> About()
{
//Simulate test user data and login timestamp
var userId = "12345";
var currentLoginTime = DateTime.UtcNow.ToString("MM/dd/yyyy HH:mm:ss");
//Save non identifying data to Firebase
var currentUserLogin = new LoginData() { TimestampUtc = currentLoginTime };
var firebaseClient = new FirebaseClient("yourFirebaseProjectUrl");
var result = await firebaseClient
.Child("Users/" + userId + "/Logins")
.PostAsync(currentUserLogin);
//Retrieve data from Firebase
var dbLogins = await firebaseClient
.Child("Users")
.Child(userId)
.Child("Logins")
.OnceAsync<LoginData>();
var timestampList = new List<DateTime>();
//Convert JSON data to original datatype
foreach (var login in dbLogins)
{
timestampList.Add(Convert.ToDateTime(login.Object.TimestampUtc).ToLocalTime());
}
//Pass data to the view
ViewBag.CurrentUser = userId;
ViewBag.Logins = timestampList.OrderByDescending(x => x);
return View();
}
CRUD configuration MVC with Firebase
@{
ViewBag.Title = "About";
}
<h2>@ViewBag.Title</h2>
<h3>Login History</h3>
<p>Current user: @ViewBag.CurrentUser</p>
<ul>
@foreach(var timestamp in ViewBag.Logins)
{
<li>Login at @timestamp</li>
}
</ul>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us