blob: 86f655b9ade78c7fd65b2317188d2b19e7994a8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 });
}
}
|