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