Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CleanArchitecture
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CleanArchitecture
Commits
ac6fbd12
Commit
ac6fbd12
authored
Oct 20, 2016
by
Steve Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configured web to use inmemory
Set up basic list of items and populate method
parent
c841e0c4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
5 deletions
+75
-5
ValueObject.cs
src/CleanArchitecture.Core/SharedKernel/ValueObject.cs
+6
-0
ToDoController.cs
src/CleanArchitecture.Web/Controllers/ToDoController.cs
+23
-1
Startup.cs
src/CleanArchitecture.Web/Startup.cs
+34
-4
Index.cshtml
src/CleanArchitecture.Web/Views/ToDo/Index.cshtml
+11
-0
project.json
src/CleanArchitecture.Web/project.json
+1
-0
No files found.
src/CleanArchitecture.Core/SharedKernel/ValueObject.cs
0 → 100644
View file @
ac6fbd12
namespace
CleanArchitecture.Core.SharedKernel
{
public
abstract
class
ValueObject
{
}
}
\ No newline at end of file
src/CleanArchitecture.Web/Controllers/ToDoController.cs
View file @
ac6fbd12
...
...
@@ -19,7 +19,29 @@ namespace CleanArchitecture.Web.Controllers
public
IActionResult
Index
()
{
return
View
();
var
items
=
_todoRepository
.
List
();
return
View
(
items
);
}
public
IActionResult
Populate
()
{
if
(
_todoRepository
.
List
().
Any
())
return
Ok
(
0
);
_todoRepository
.
Add
(
new
ToDoItem
()
{
Title
=
"One"
,
Description
=
"The first item"
});
_todoRepository
.
Add
(
new
ToDoItem
()
{
Title
=
"Two"
,
Description
=
"The second item"
});
_todoRepository
.
Add
(
new
ToDoItem
()
{
Title
=
"Three"
,
Description
=
"The three item"
});
return
Ok
(
3
);
}
}
}
src/CleanArchitecture.Web/Startup.cs
View file @
ac6fbd12
using
CleanArchitecture.Core.Interfaces
;
using
System
;
using
CleanArchitecture.Core.Interfaces
;
using
CleanArchitecture.Core.Entities
;
using
CleanArchitecture.Core.SharedKernel
;
using
CleanArchitecture.Infrastructure
;
using
CleanArchitecture.Infrastructure.Data
;
using
CleanArchitecture.Infrastructure.DomainEvents
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
StructureMap
;
using
StructureMap.AutoMocking
;
namespace
CleanArchitecture.Web
{
...
...
@@ -26,17 +32,41 @@ namespace CleanArchitecture.Web
public
IConfigurationRoot
Configuration
{
get
;
}
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
public
IServiceProvider
ConfigureServices
(
IServiceCollection
services
)
{
// Add framework services.
// TODO: Add DbContext and IOC
services
.
AddDbContext
<
AppDbContext
>(
options
=>
options
.
UseSqlServer
(
Configuration
.
GetConnectionString
(
"DefaultConnection"
)));
options
.
UseInMemoryDatabase
());
//options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services
.
AddMvc
();
services
.
AddTransient
<
IDomainEventDispatcher
,
DomainEventDispatcher
>();
var
container
=
new
Container
();
container
.
Configure
(
config
=>
{
config
.
Scan
(
_
=>
{
_
.
AssemblyContainingType
(
typeof
(
Startup
));
// Web
_
.
AssemblyContainingType
(
typeof
(
BaseEntity
));
// Core
_
.
Assembly
(
"CleanArchitecture.Infrastructure"
);
// Infrastructure
_
.
WithDefaultConventions
();
_
.
ConnectImplementationsToTypesClosing
(
typeof
(
IHandle
<>));
});
// ToDo: Add Registry Classes
// TODO: Move to Infrastucture Registry
config
.
For
(
typeof
(
IRepository
<>)).
Add
(
typeof
(
EfRepository
<>));
//Populate the container using the service collection
config
.
Populate
(
services
);
});
return
container
.
GetInstance
<
IServiceProvider
>();
services
.
AddTransient
<
IRepository
<
ToDoItem
>,
EfRepository
<
ToDoItem
>>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
src/CleanArchitecture.Web/Views/ToDo/Index.cshtml
0 → 100644
View file @
ac6fbd12
@{
ViewData["Title"] = "ToDo List";
}
@model IEnumerable<CleanArchitecture.Core.Entities.ToDoItem>
<h2>To Do Items</h2>
<ul>
@foreach (var item in Model)
{
<li>@item.Title</li>
}
</ul>
src/CleanArchitecture.Web/project.json
View file @
ac6fbd12
...
...
@@ -14,6 +14,7 @@
"Microsoft.AspNetCore.Server.Kestrel"
:
"1.0.0"
,
"Microsoft.AspNetCore.StaticFiles"
:
"1.0.0"
,
"Microsoft.EntityFrameworkCore.SqlServer"
:
"1.0.0"
,
"Microsoft.EntityFrameworkCore.InMemory"
:
"1.0.0"
,
"Microsoft.Extensions.Configuration.EnvironmentVariables"
:
"1.0.0"
,
"Microsoft.Extensions.Configuration.Json"
:
"1.0.0"
,
"Microsoft.Extensions.Logging"
:
"1.0.0"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment