-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel
authored and
Daniel
committed
Aug 17, 2019
1 parent
4a3c5bc
commit 89ddceb
Showing
17 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29102.190 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseAPI", "BaseAPI\BaseAPI.csproj", "{19703073-7371-4731-BA9D-412EB33D1A8D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{19703073-7371-4731-BA9D-412EB33D1A8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{19703073-7371-4731-BA9D-412EB33D1A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{19703073-7371-4731-BA9D-412EB33D1A8D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{19703073-7371-4731-BA9D-412EB33D1A8D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F841AF86-79E7-4236-8C56-DA272BF606A3} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using BaseAPI.Models; | ||
using BaseAPI.Repositories; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BaseAPI.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class NotesController : ControllerBase | ||
{ | ||
private readonly INoteRepository _noteRepository; | ||
public NotesController(INoteRepository noteRepository) | ||
{ | ||
_noteRepository = noteRepository ?? throw new ArgumentNullException(nameof(noteRepository)); | ||
} | ||
|
||
/// <summary> | ||
/// Get All Notes | ||
/// </summary> | ||
/// <returns>Notes</returns> | ||
[HttpGet] | ||
public Task<IEnumerable<Note>> GetNotes() | ||
{ | ||
return _noteRepository.GetNotesAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Add a note | ||
/// </summary> | ||
/// <param name="note">Note to be added</param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public IActionResult AddNote(Note note) | ||
{ | ||
_noteRepository.AddNoteAsync(note); | ||
return NoContent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using BaseAPI.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BaseAPI.DBContexts | ||
{ | ||
public class NoteContext : DbContext | ||
{ | ||
public NoteContext(DbContextOptions<NoteContext> options) : base(options) | ||
{ } | ||
public DbSet<Note> Notes { get; set; } | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
BaseAPI/Migrations/20190726005827_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace BaseAPI.Migrations | ||
{ | ||
public partial class InitialCreate : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Notes", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(nullable: false), | ||
Title = table.Column<string>(nullable: true), | ||
Content = table.Column<string>(nullable: true), | ||
DateCreated = table.Column<DateTime>(nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Notes", x => x.Id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Notes"); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
BaseAPI/Migrations/20190726022930_Add-DateModified.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace BaseAPI.Migrations | ||
{ | ||
public partial class AddDateModified : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<DateTime>( | ||
name: "DateModified", | ||
table: "Notes", | ||
nullable: false, | ||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropColumn( | ||
name: "DateModified", | ||
table: "Notes"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// <auto-generated /> | ||
using System; | ||
using BaseAPI.DBContexts; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace BaseAPI.Migrations | ||
{ | ||
[DbContext(typeof(NoteContext))] | ||
partial class NoteContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128) | ||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | ||
|
||
modelBuilder.Entity("BaseAPI.Models.Note", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd(); | ||
|
||
b.Property<string>("Content"); | ||
|
||
b.Property<DateTime>("DateCreated"); | ||
|
||
b.Property<DateTime>("DateModified"); | ||
|
||
b.Property<string>("Title"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Notes"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BaseAPI.Models | ||
{ | ||
public class Note | ||
{ | ||
public Guid Id { get; set; } | ||
public string Title { get; set; } | ||
public string Content { get; set; } | ||
public DateTime DateModified { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
|
||
public Note() | ||
{ | ||
Id = Guid.NewGuid(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace BaseAPI | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateWebHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:55128", | ||
"sslPort": 44343 | ||
} | ||
}, | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "api/values", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"BaseAPI": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using BaseAPI.Models; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace BaseAPI.Repositories | ||
{ | ||
public interface INoteRepository | ||
{ | ||
Task<IEnumerable<Note>> GetNotesAsync(); | ||
Task AddNoteAsync(Note note); | ||
} | ||
} |
Oops, something went wrong.