Skip to content

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
thangchung committed May 22, 2017
1 parent 30c27e0 commit 1cf18c8
Show file tree
Hide file tree
Showing 200 changed files with 53,069 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# ShoppingCartDemo
The demo for the MSA approach using .NET stack
### Service Discovery (Windows only)

`consul.exe agent -dev`

### Migration

`dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Migrations/PersistedGrantDb`

`dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Migrations/ConfigurationDb`

`dotnet ef migrations add InitDatabase -c AppDbContext -o Migrations/SampleDb`

`dotnet run`

### Login

`[email protected]` / `root`
63 changes: 63 additions & 0 deletions ShoppingCartDemo.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26510.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NT.Infrastructure", "src\NT.Infrastructure\NT.Infrastructure.csproj", "{DABA5E01-B5C5-4325-9672-12B35E01CE24}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NT.Core", "src\NT.Core\NT.Core.csproj", "{88E28277-B9F7-4D1A-9150-8715BAA32213}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6CEABC5E-C3AD-45DE-9302-1321FCAD8033}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
ShoppingCartDemoCodeMap.dgml = ShoppingCartDemoCodeMap.dgml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Externals", "Externals", "{8D3B46E9-34E0-4C7D-8E06-7221B6492406}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NT.MigrationConsole", "src\NT.MigrationConsole\NT.MigrationConsole.csproj", "{46C34DD5-0275-47B3-9B2A-5D922CDC50FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NT.IdentityServer", "src\NT.IdentityServer\NT.IdentityServer.csproj", "{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InternalServices", "InternalServices", "{2006F265-C085-4F5D-8EFE-29B15B8C003B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NT.WebApi", "src\NT.WebApi\NT.WebApi.csproj", "{A7BBB2B3-F326-496A-98B8-A27B878361B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DABA5E01-B5C5-4325-9672-12B35E01CE24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DABA5E01-B5C5-4325-9672-12B35E01CE24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DABA5E01-B5C5-4325-9672-12B35E01CE24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DABA5E01-B5C5-4325-9672-12B35E01CE24}.Release|Any CPU.Build.0 = Release|Any CPU
{88E28277-B9F7-4D1A-9150-8715BAA32213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88E28277-B9F7-4D1A-9150-8715BAA32213}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88E28277-B9F7-4D1A-9150-8715BAA32213}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88E28277-B9F7-4D1A-9150-8715BAA32213}.Release|Any CPU.Build.0 = Release|Any CPU
{46C34DD5-0275-47B3-9B2A-5D922CDC50FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46C34DD5-0275-47B3-9B2A-5D922CDC50FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46C34DD5-0275-47B3-9B2A-5D922CDC50FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46C34DD5-0275-47B3-9B2A-5D922CDC50FF}.Release|Any CPU.Build.0 = Release|Any CPU
{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8}.Release|Any CPU.Build.0 = Release|Any CPU
{A7BBB2B3-F326-496A-98B8-A27B878361B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7BBB2B3-F326-496A-98B8-A27B878361B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7BBB2B3-F326-496A-98B8-A27B878361B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7BBB2B3-F326-496A-98B8-A27B878361B0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{46C34DD5-0275-47B3-9B2A-5D922CDC50FF} = {8D3B46E9-34E0-4C7D-8E06-7221B6492406}
{10FD5B48-FBAF-4C9F-A0FA-6D389EA909E8} = {2006F265-C085-4F5D-8EFE-29B15B8C003B}
{A7BBB2B3-F326-496A-98B8-A27B878361B0} = {2006F265-C085-4F5D-8EFE-29B15B8C003B}
EndGlobalSection
EndGlobal
2,922 changes: 2,922 additions & 0 deletions ShoppingCartDemoCodeMap.dgml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/NT.Core/CatalogContext/Product.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace NT.Core.CatalogContext
{
public class Product : EntityBase
{
public string Name { get; set; }
public int Quantity { get; set; }
public double Price { get; set; }
public string Model { get; set; }
public DateTime DateAdded { get; set; }
public Status Status { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/NT.Core/CatalogContext/Status.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NT.Core.CatalogContext
{
public enum Status
{
Review,
Published
}
}
13 changes: 13 additions & 0 deletions src/NT.Core/CatalogContext/Supplier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using NT.Core.SharedKernel;

namespace NT.Core.CatalogContext
{
public class Supplier : EntityBase
{
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
public AddressInfo AddressInfo { get; set; }
public ContactInfo ContactInfo { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/NT.Core/CustomerContext/Customer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using NT.Core.SharedKernel;

namespace NT.Core.CustomerContext
{
public class Customer : EntityBase
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string ContactTitle { get; set; }
public Guid AddressInfoId { get; set; }
public AddressInfo AddressInfo { get; set; }
public Guid ContactInfoId { get; set; }
public ContactInfo ContactInfo { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/NT.Core/CustomerContext/CustomerWithAddressInfoSpec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Linq.Expressions;

namespace NT.Core.CustomerContext
{
public class CustomerWithAddressInfoSpec : ISpecification<Customer>
{
public Expression<Func<Customer, bool>> Criteria
{
get { return e => true; }
}

public Expression<Func<Customer, object>> Include
{
get { return e => e.AddressInfo; }
}
}
}
18 changes: 18 additions & 0 deletions src/NT.Core/CustomerContext/CustomerWithContactInfoSpec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Linq.Expressions;

namespace NT.Core.CustomerContext
{
public class CustomerWithContactInfoSpec : ISpecification<Customer>
{
public Expression<Func<Customer, bool>> Criteria
{
get { return e => true; }
}

public Expression<Func<Customer, object>> Include
{
get { return e => e.ContactInfo; }
}
}
}
9 changes: 9 additions & 0 deletions src/NT.Core/EntityBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace NT.Core
{
public abstract class EntityBase
{
public Guid Id { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/NT.Core/IRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NT.Core
{
public interface IRepository<TEntity> where TEntity : EntityBase
{
Task<TEntity> GetByIdAsync(Guid id);
Task<IEnumerable<TEntity>> ListAsync();
Task<IEnumerable<TEntity>> ListAsync(ISpecification<TEntity>[] spec);
Task<TEntity> AddAsync(TEntity entity);
Task UpdateAsync(TEntity entity);
Task DeleteAsync(TEntity entity);
}
}
11 changes: 11 additions & 0 deletions src/NT.Core/ISpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Linq.Expressions;

namespace NT.Core
{
public interface ISpecification<TEntity>
{
Expression<Func<TEntity, bool>> Criteria { get; }
Expression<Func<TEntity, object>> Include { get; }
}
}
9 changes: 9 additions & 0 deletions src/NT.Core/IgnoreMemberAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace NT.Core
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class IgnoreMemberAttribute : Attribute
{
}
}
11 changes: 11 additions & 0 deletions src/NT.Core/NT.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions src/NT.Core/NotificationContext/Notification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NT.Core.NotificationContext
{
public class Notification : EntityBase
{
public NotificationInfo NotificationInfo { get; set; }
public OrderLink Order { get; set; }
}
}
21 changes: 21 additions & 0 deletions src/NT.Core/NotificationContext/NotificationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;

namespace NT.Core.NotificationContext
{
public class NotificationInfo : ValueObject
{
public NotificationInfo(Guid id, string message)
{
Id = id;
Message = message;
}

public Guid Id { get; private set; }
public string Message { get; private set; }

public override string ToString()
{
return $"Notification [id={Id}; message={Message}]";
}
}
}
6 changes: 6 additions & 0 deletions src/NT.Core/NotificationContext/OrderLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace NT.Core.NotificationContext
{
public class OrderLink : EntityBase
{
}
}
6 changes: 6 additions & 0 deletions src/NT.Core/OrderContext/CustomerLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace NT.Core.OrderContext
{
public class CustomerLink : EntityBase
{
}
}
14 changes: 14 additions & 0 deletions src/NT.Core/OrderContext/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace NT.Core.OrderContext
{
public class Order : EntityBase
{
public CustomerLink Customer { get; set; }
public Guid CustomerId { get; set; }
public UserLink Employee { get; set; }
public Guid EmployeeId { get; set; }
public DateTime OrderDate { get; set; }
public ShipInfo ShipInfo { get; set; }
}
}
13 changes: 13 additions & 0 deletions src/NT.Core/OrderContext/OrderDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace NT.Core.OrderContext
{
public class OrderDetails : EntityBase
{
public Order Order { get; set; }
public Guid OrderId { get; set; }
public ProductLink Product { get; set; }
public Guid ProductId { get; set; }
public int Quantity { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/NT.Core/OrderContext/ProductLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NT.Core.OrderContext
{
public class ProductLink : EntityBase
{
}
}
19 changes: 19 additions & 0 deletions src/NT.Core/OrderContext/ShipInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using NT.Core.SharedKernel;

namespace NT.Core.OrderContext
{
public class ShipInfo : ValueObject
{
public ShipInfo(Guid id, string name, AddressInfo addressInfo)
{
Id = id;
Name = name;
AddressInfo = addressInfo;
}

public Guid Id { get; private set; }
public string Name { get; private set; }
public AddressInfo AddressInfo { get; private set; }
}
}
10 changes: 10 additions & 0 deletions src/NT.Core/OrderContext/UserLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NT.Core.OrderContext
{
public class UserLink : EntityBase
{
}
}
15 changes: 15 additions & 0 deletions src/NT.Core/PaymentContext/CustomerPayment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace NT.Core.PaymentContext
{
public class CustomerPayment : EntityBase
{
public PaymentCustomerLink Customer { get; set; }
public Guid CustomerId { get; set; }
public PaymentMethod PaymentMethod { get; set; }
public Guid PaymentMethodId { get; set; }
public string CardNumber { get; set; }
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/NT.Core/PaymentContext/PaymentCustomerLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace NT.Core.PaymentContext
{
public class PaymentCustomerLink : EntityBase
{
}
}
Loading

0 comments on commit 1cf18c8

Please sign in to comment.