summaryrefslogtreecommitdiff
path: root/src/marlin.web/Controllers/VCSController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/marlin.web/Controllers/VCSController.cs')
-rw-r--r--src/marlin.web/Controllers/VCSController.cs68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/marlin.web/Controllers/VCSController.cs b/src/marlin.web/Controllers/VCSController.cs
new file mode 100644
index 0000000..86f655b
--- /dev/null
+++ b/src/marlin.web/Controllers/VCSController.cs
@@ -0,0 +1,68 @@
+namespace marlin.web.Controllers;
+
+using core;
+using core.models;
+using Data;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+[Route("vcs")]
+public class VCSController(ApplicationDbContext dbContext) : Controller
+{
+ [HttpGet("list")]
+ public async Task<IActionResult> List(CancellationToken ct)
+ {
+ var items = await dbContext.Sources
+ .ToListAsync(ct);
+
+ return this.View(items);
+ }
+
+ [HttpGet("details/{id}")]
+ public async Task<IActionResult> Details(Guid id, CancellationToken ct)
+ {
+ var item = await dbContext.Sources
+ .FirstOrDefaultAsync(x => x.Id == id, ct);
+
+ if (item == null)
+ return this.NotFound();
+
+ return this.View(item);
+ }
+
+ [HttpPost("edit/{id}")]
+ public async Task<IActionResult> Edit(Guid id, VersionControlSource vcs, CancellationToken ct)
+ {
+ var item = await dbContext.Sources
+ .FirstOrDefaultAsync(x => x.Id == id, ct);
+
+ if (item == null)
+ return this.NotFound();
+
+ item.UpstreamUrl = vcs.UpstreamUrl;
+ item.BranchFilter = vcs.BranchFilter;
+ item.MainBranch = vcs.MainBranch;
+ item.MinPollingInterval = vcs.MinPollingInterval;
+
+ await dbContext.SaveChangesAsync(ct);
+
+ return this.RedirectToAction("List");
+ }
+
+ [HttpGet("create")]
+ public async Task<IActionResult> Create()
+ {
+ return this.View();
+ }
+
+ [HttpPost("create")]
+ public async Task<IActionResult> CreatePost(VersionControlSource vcs, CancellationToken ct)
+ {
+ vcs.Id = Guid.Empty;
+
+ await dbContext.AddAsync(vcs, ct);
+ await dbContext.SaveChangesAsync(ct);
+
+ return this.RedirectToAction("Details", new { id = vcs.Id });
+ }
+} \ No newline at end of file