Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel authored and Daniel committed Aug 17, 2019
1 parent 4a3c5bc commit 89ddceb
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 0 deletions.
25 changes: 25 additions & 0 deletions BaseAPI.sln
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
14 changes: 14 additions & 0 deletions BaseAPI/BaseAPI.csproj
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>
44 changes: 44 additions & 0 deletions BaseAPI/Controllers/NotesController.cs
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();
}
}
}
17 changes: 17 additions & 0 deletions BaseAPI/DBContexts/NoteContext.cs
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 BaseAPI/Migrations/20190726005827_InitialCreate.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions BaseAPI/Migrations/20190726005827_InitialCreate.cs
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 BaseAPI/Migrations/20190726022930_Add-DateModified.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions BaseAPI/Migrations/20190726022930_Add-DateModified.cs
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");
}
}
}
42 changes: 42 additions & 0 deletions BaseAPI/Migrations/NoteContextModelSnapshot.cs
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
}
}
}
22 changes: 22 additions & 0 deletions BaseAPI/Models/Note.cs
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();
}
}
}
24 changes: 24 additions & 0 deletions BaseAPI/Program.cs
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>();
}
}
30 changes: 30 additions & 0 deletions BaseAPI/Properties/launchSettings.json
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"
}
}
}
12 changes: 12 additions & 0 deletions BaseAPI/Repositories/INoteRepository.cs
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);
}
}
Loading

0 comments on commit 89ddceb

Please sign in to comment.