Code cleanup, 2022 edition
This commit is contained in:
parent
db4a42171d
commit
1d9712294f
|
@ -1,10 +1,10 @@
|
||||||
using LinqToDB.Mapping;
|
using LinqToDB.Mapping;
|
||||||
|
|
||||||
namespace c3stream.DataModels.Tables {
|
namespace c3stream.DataModels.Tables;
|
||||||
[Table(Name = "States")]
|
|
||||||
public class States {
|
[Table(Name = "States")]
|
||||||
|
public class States {
|
||||||
[Column(Name = "TalkId"), PrimaryKey, NotNull] public string TalkId { get; set; }
|
[Column(Name = "TalkId"), PrimaryKey, NotNull] public string TalkId { get; set; }
|
||||||
[Column(Name = "UserId"), PrimaryKey, NotNull] public string UserId { get; set; }
|
[Column(Name = "UserId"), PrimaryKey, NotNull] public string UserId { get; set; }
|
||||||
[Column(Name = "State"), NotNull] public string State { get; set; }
|
[Column(Name = "State"), NotNull] public string State { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ namespace c3stream;
|
||||||
public static class Migrations {
|
public static class Migrations {
|
||||||
private const int DbVer = 0;
|
private const int DbVer = 0;
|
||||||
|
|
||||||
private static readonly List<Migration> _migrations = new() { };
|
private static readonly List<Migration> _migrations = new();
|
||||||
|
|
||||||
public static void RunMigrations() {
|
public static void RunMigrations() {
|
||||||
using var db = new Database.DbConn();
|
using var db = new Database.DbConn();
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
@page
|
@page
|
||||||
@model ConferenceModel
|
|
||||||
@using System.Net
|
|
||||||
@using global::c3stream.DataModels
|
@using global::c3stream.DataModels
|
||||||
@using static ConferenceModel
|
@model ConferenceModel
|
||||||
@{
|
@{
|
||||||
if (c3stream.Conferences.All(c => c.Acronym != Request.Query["c"])) {
|
if (c3stream.Conferences.All(c => c.Acronym != Request.Query["c"])) {
|
||||||
Response.Redirect("/");
|
Response.Redirect("/");
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using c3stream.DataModels;
|
using c3stream.DataModels;
|
||||||
using c3stream.DataModels.Tables;
|
using c3stream.DataModels.Tables;
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
public class ConferenceModel : PageModel {
|
|
||||||
|
public class ConferenceModel : PageModel {
|
||||||
private readonly ILogger<ConferenceModel> _logger;
|
private readonly ILogger<ConferenceModel> _logger;
|
||||||
|
|
||||||
public ConferenceModel(ILogger<ConferenceModel> logger) => _logger = logger;
|
public ConferenceModel(ILogger<ConferenceModel> logger) => _logger = logger;
|
||||||
|
@ -23,17 +22,16 @@ namespace c3stream.Pages {
|
||||||
using var db = new Database.DbConn();
|
using var db = new Database.DbConn();
|
||||||
var existing = db.States.FirstOrDefault(p => p.TalkId == guid && p.UserId == userid);
|
var existing = db.States.FirstOrDefault(p => p.TalkId == guid && p.UserId == userid);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
if (state == "unwatched")
|
if (state == "unwatched") {
|
||||||
db.States.Delete(p => p == existing);
|
db.States.Delete(p => p == existing);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
existing.State = state;
|
existing.State = state;
|
||||||
db.Update(existing);
|
db.Update(existing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
db.Insert(new States {
|
db.Insert(new States { State = state, TalkId = guid, UserId = userid });
|
||||||
State = state, TalkId = guid, UserId = userid
|
|
||||||
});
|
|
||||||
Response.Redirect("/");
|
Response.Redirect("/");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,9 +3,10 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
||||||
public class ErrorModel : PageModel {
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public class ErrorModel : PageModel {
|
||||||
private readonly ILogger<ErrorModel> _logger;
|
private readonly ILogger<ErrorModel> _logger;
|
||||||
|
|
||||||
public ErrorModel(ILogger<ErrorModel> logger) => _logger = logger;
|
public ErrorModel(ILogger<ErrorModel> logger) => _logger = logger;
|
||||||
|
@ -17,5 +18,4 @@ namespace c3stream.Pages {
|
||||||
public void OnGet() {
|
public void OnGet() {
|
||||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
public class IndexModel : PageModel {
|
|
||||||
|
public class IndexModel : PageModel {
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ILogger<IndexModel> _logger;
|
||||||
|
|
||||||
public IndexModel(ILogger<IndexModel> logger) => _logger = logger;
|
public IndexModel(ILogger<IndexModel> logger) => _logger = logger;
|
||||||
|
|
||||||
public void OnGet() { }
|
public void OnGet() { }
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
public class InfoModel : PageModel {
|
|
||||||
|
public class InfoModel : PageModel {
|
||||||
private readonly ILogger<InfoModel> _logger;
|
private readonly ILogger<InfoModel> _logger;
|
||||||
|
|
||||||
public InfoModel(ILogger<InfoModel> logger) => _logger = logger;
|
public InfoModel(ILogger<InfoModel> logger) => _logger = logger;
|
||||||
|
|
||||||
public void OnGet() { }
|
public void OnGet() { }
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
public class PrivacyModel : PageModel {
|
|
||||||
|
public class PrivacyModel : PageModel {
|
||||||
private readonly ILogger<PrivacyModel> _logger;
|
private readonly ILogger<PrivacyModel> _logger;
|
||||||
|
|
||||||
public PrivacyModel(ILogger<PrivacyModel> logger) => _logger = logger;
|
public PrivacyModel(ILogger<PrivacyModel> logger) => _logger = logger;
|
||||||
|
|
||||||
public void OnGet() { }
|
public void OnGet() { }
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,10 +1,8 @@
|
||||||
@page
|
@page
|
||||||
@model WatchlistModel
|
|
||||||
@using System.Net
|
|
||||||
@using global::c3stream.DataModels
|
@using global::c3stream.DataModels
|
||||||
@using static WatchlistModel
|
@model WatchlistModel
|
||||||
@{
|
@{
|
||||||
var cookie = c3stream.UpdateCookie(Request, Response, $"/Watchlist");
|
var cookie = c3stream.UpdateCookie(Request, Response, "/Watchlist");
|
||||||
ViewData["Title"] = "Watchlist";
|
ViewData["Title"] = "Watchlist";
|
||||||
await using var db = new Database.DbConn();
|
await using var db = new Database.DbConn();
|
||||||
var states = db.States.ToList();
|
var states = db.States.ToList();
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using c3stream.DataModels;
|
using c3stream.DataModels;
|
||||||
using c3stream.DataModels.Tables;
|
using c3stream.DataModels.Tables;
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace c3stream.Pages {
|
namespace c3stream.Pages;
|
||||||
public class WatchlistModel : PageModel {
|
|
||||||
|
public class WatchlistModel : PageModel {
|
||||||
private readonly ILogger<ConferenceModel> _logger;
|
private readonly ILogger<ConferenceModel> _logger;
|
||||||
|
|
||||||
public WatchlistModel(ILogger<ConferenceModel> logger) => _logger = logger;
|
public WatchlistModel(ILogger<ConferenceModel> logger) => _logger = logger;
|
||||||
|
@ -23,17 +22,16 @@ namespace c3stream.Pages {
|
||||||
using var db = new Database.DbConn();
|
using var db = new Database.DbConn();
|
||||||
var existing = db.States.FirstOrDefault(p => p.TalkId == guid && p.UserId == userid);
|
var existing = db.States.FirstOrDefault(p => p.TalkId == guid && p.UserId == userid);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
if (state == "unwatched")
|
if (state == "unwatched") {
|
||||||
db.States.Delete(p => p == existing);
|
db.States.Delete(p => p == existing);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
existing.State = state;
|
existing.State = state;
|
||||||
db.Update(existing);
|
db.Update(existing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
db.Insert(new States {
|
db.Insert(new States { State = state, TalkId = guid, UserId = userid });
|
||||||
State = state, TalkId = guid, UserId = userid
|
|
||||||
});
|
|
||||||
Response.Redirect("/");
|
Response.Redirect("/");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1 +1,2 @@
|
||||||
c3stream is a small proxy site meant for saving watched status & watch-later-lists for media.ccc.de talks. Test in production at https://c3stream.de
|
c3stream is a small proxy site meant for saving watched status & watch-later-lists for media.ccc.de talks. Test in
|
||||||
|
production at https://c3stream.de
|
|
@ -4,8 +4,9 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace c3stream {
|
namespace c3stream;
|
||||||
public class Startup {
|
|
||||||
|
public class Startup {
|
||||||
public Startup(IConfiguration configuration) => Configuration = configuration;
|
public Startup(IConfiguration configuration) => Configuration = configuration;
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
@ -31,5 +32,4 @@ namespace c3stream {
|
||||||
|
|
||||||
app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); });
|
app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue