Skip to content

Commit 5cb7890

Browse files
author
fun-minion
committed
Initial Commit
0 parents  commit 5cb7890

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4966
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.vs/
2+
/bin/
3+
/obj/

ConduitApi.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<UserSecretsId>eec7c755-80d0-423e-a3c8-853573195ce4</UserSecretsId>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Folder Include="wwwroot\" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.AspNetCore.App" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1" />
16+
</ItemGroup>
17+
18+
</Project>

ConduitApi.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.168
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConduitApi", "ConduitApi.csproj", "{E3C37F4C-258B-4468-9E9B-AC28D63860C2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E3C37F4C-258B-4468-9E9B-AC28D63860C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E3C37F4C-258B-4468-9E9B-AC28D63860C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E3C37F4C-258B-4468-9E9B-AC28D63860C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E3C37F4C-258B-4468-9E9B-AC28D63860C2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {3303E012-4A3C-436B-B340-550DCEAD21C2}
24+
EndGlobalSection
25+
EndGlobal

Controllers/ApiController.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using ConduitApi.Infrastructure;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace ConduitApi.Controllers
9+
{
10+
[ApiController]
11+
public abstract class ApiController : Controller
12+
{
13+
public string Username => User?.Identity?.IsAuthenticated ?? false ? User.Identity.Name : null;
14+
15+
protected void EnsureModelValid()
16+
{
17+
if(!ModelState.IsValid)
18+
{
19+
throw new BadRequestException(ModelState);
20+
}
21+
}
22+
23+
protected Exception NotFoundException() => new StatusCodeException(System.Net.HttpStatusCode.NotFound);
24+
}
25+
}

0 commit comments

Comments
 (0)