-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7f15540
commit 08bca2f
Showing
43 changed files
with
1,084 additions
and
49 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,9 @@ | ||
.dockerignore | ||
.env | ||
.git | ||
.gitignore | ||
.vs | ||
.vscode | ||
*/bin | ||
*/obj | ||
**/.toolstarget |
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
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
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,5 @@ | ||
* | ||
!src | ||
!*.sln | ||
**/bin | ||
**/obj |
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,28 @@ | ||
FROM microsoft/dotnet:2.1.2-aspnetcore-runtime-alpine AS base | ||
WORKDIR /app | ||
|
||
ARG service_version | ||
ENV SERVICE_VERSION ${service_version:-0.0.1} | ||
|
||
ARG api_version | ||
ENV API_VERSION ${api_version:-1.0} | ||
|
||
ENV ASPNETCORE_URLS http://+:5001 | ||
EXPOSE 5001 | ||
|
||
FROM microsoft/dotnet:2.1.302-sdk-alpine AS build | ||
WORKDIR /src | ||
COPY . . | ||
|
||
WORKDIR /src/src/samples | ||
|
||
RUN dotnet restore -nowarn:msb3202,nu1503 | ||
RUN dotnet build --no-restore -c Release -o /app | ||
|
||
FROM build AS publish | ||
RUN dotnet publish --no-restore -c Release -o /app | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app . | ||
ENTRYPOINT ["dotnet", "Company.Application.samples.dll"] |
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,55 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using NetCoreKit.Domain; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Domain | ||
{ | ||
public sealed class Todo : EntityBase | ||
{ | ||
internal Todo(string title) | ||
: this(Guid.NewGuid(), title) | ||
{ | ||
} | ||
|
||
public Todo(Guid id, string title) : base(id) | ||
{ | ||
Title = title; | ||
} | ||
|
||
public static Todo Load(string title) | ||
{ | ||
return new Todo(title); | ||
} | ||
|
||
public static Todo Load(Guid id, string title) | ||
{ | ||
return new Todo(id, title); | ||
} | ||
|
||
public int? Order { get; private set; } = 1; | ||
[Required] public string Title { get; private set; } | ||
public bool? Completed { get; private set; } = false; | ||
|
||
public Todo ChangeTitle(string title) | ||
{ | ||
if(string.IsNullOrEmpty(title)) | ||
throw new DomainException("Order is null or empty."); | ||
Title = title; | ||
return this; | ||
} | ||
|
||
public Todo ChangeOrder(int order) | ||
{ | ||
if (order <= 0) | ||
throw new DomainException("Order could be greater than zero."); | ||
Order = order; | ||
return this; | ||
} | ||
|
||
public Todo ChangeToCompleted() | ||
{ | ||
Completed = true; | ||
return this; | ||
} | ||
} | ||
} |
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 System; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Dtos | ||
{ | ||
public class TodoDto | ||
{ | ||
public Guid Id { get; set; } | ||
public string Title { get; set; } | ||
public int Order { get; set; } | ||
public bool Completed { get; set; } | ||
} | ||
} |
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,19 @@ | ||
using NetCoreKit.Samples.TodoAPI.Domain; | ||
using NetCoreKit.Samples.TodoAPI.Dtos; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Extensions | ||
{ | ||
public static class TodoExtensions | ||
{ | ||
public static TodoDto ToDto(this Todo todo) | ||
{ | ||
return new TodoDto | ||
{ | ||
Id = todo.Id, | ||
Title = todo.Title, | ||
Completed = todo.Completed ?? false, | ||
Order = todo.Order ?? 1 | ||
}; | ||
} | ||
} | ||
} |
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 Microsoft.EntityFrameworkCore; | ||
using NetCoreKit.Infrastructure.EfCore.Db; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Infrastructure.Db | ||
{ | ||
public class TodoDbContext : ApplicationDbContext | ||
{ | ||
public TodoDbContext(DbContextOptions options) : base(options) | ||
{ | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
samples/TodoApi/Migrations/20180817091043_InitTodoDb.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,33 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Migrations | ||
{ | ||
public partial class InitTodoDb : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Todos", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(nullable: false), | ||
Created = table.Column<DateTime>(nullable: false), | ||
Updated = table.Column<DateTime>(nullable: false), | ||
Order = table.Column<int>(nullable: true), | ||
Title = table.Column<string>(nullable: false), | ||
Completed = table.Column<bool>(nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Todos", x => x.Id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Todos"); | ||
} | ||
} | ||
} |
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,45 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using NetCoreKit.Samples.TodoAPI.Infrastructure.Db; | ||
|
||
namespace NetCoreKit.Samples.TodoAPI.Migrations | ||
{ | ||
[DbContext(typeof(TodoDbContext))] | ||
partial class TodoDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128) | ||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | ||
|
||
modelBuilder.Entity("NetCoreKit.Samples.TodoAPI.Domain.Todo", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd(); | ||
|
||
b.Property<bool?>("Completed"); | ||
|
||
b.Property<DateTime>("Created"); | ||
|
||
b.Property<int?>("Order"); | ||
|
||
b.Property<string>("Title") | ||
.IsRequired(); | ||
|
||
b.Property<DateTime>("Updated"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Todos"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
Oops, something went wrong.