Skip to content

Commit

Permalink
Added initial S#arp Lite codebase including source, example project, …
Browse files Browse the repository at this point in the history
…and Templify template. See README.txt for setup guidance.
  • Loading branch information
Billy McCafferty committed Nov 1, 2011
0 parents commit 7f6d31f
Show file tree
Hide file tree
Showing 366 changed files with 332,253 additions and 0 deletions.
Binary file added Example/MyStore.suo
Binary file not shown.
56 changes: 56 additions & 0 deletions Example/MyStore/MyStore.sln
@@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.Web", "app\MyStore.Web\MyStore.Web.csproj", "{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.Domain", "app\MyStore.Domain\MyStore.Domain.csproj", "{74801410-F690-490C-91EA-CD94E520A465}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.NHibernateProvider", "app\MyStore.NHibernateProvider\MyStore.NHibernateProvider.csproj", "{4E471CAC-A108-49AE-A4D6-155DC35712C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.Tasks", "app\MyStore.Tasks\MyStore.Tasks.csproj", "{BE147A77-3E59-40E6-822D-5AEDFD5D383C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.Tests", "app\MyStore.Tests\MyStore.Tests.csproj", "{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStore.Init", "app\MyStore.Init\MyStore.Init.csproj", "{7112AC6B-C406-481D-99D4-56BA796B7173}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{EAA774FA-8EA7-4CE4-A406-16D7CE0BC4C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}.Release|Any CPU.Build.0 = Release|Any CPU
{74801410-F690-490C-91EA-CD94E520A465}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74801410-F690-490C-91EA-CD94E520A465}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74801410-F690-490C-91EA-CD94E520A465}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74801410-F690-490C-91EA-CD94E520A465}.Release|Any CPU.Build.0 = Release|Any CPU
{4E471CAC-A108-49AE-A4D6-155DC35712C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E471CAC-A108-49AE-A4D6-155DC35712C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E471CAC-A108-49AE-A4D6-155DC35712C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E471CAC-A108-49AE-A4D6-155DC35712C9}.Release|Any CPU.Build.0 = Release|Any CPU
{BE147A77-3E59-40E6-822D-5AEDFD5D383C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE147A77-3E59-40E6-822D-5AEDFD5D383C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE147A77-3E59-40E6-822D-5AEDFD5D383C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE147A77-3E59-40E6-822D-5AEDFD5D383C}.Release|Any CPU.Build.0 = Release|Any CPU
{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}.Release|Any CPU.Build.0 = Release|Any CPU
{7112AC6B-C406-481D-99D4-56BA796B7173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7112AC6B-C406-481D-99D4-56BA796B7173}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7112AC6B-C406-481D-99D4-56BA796B7173}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7112AC6B-C406-481D-99D4-56BA796B7173}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7112AC6B-C406-481D-99D4-56BA796B7173} = {EAA774FA-8EA7-4CE4-A406-16D7CE0BC4C1}
{4E471CAC-A108-49AE-A4D6-155DC35712C9} = {EAA774FA-8EA7-4CE4-A406-16D7CE0BC4C1}
EndGlobalSection
EndGlobal
Binary file added Example/MyStore/MyStore.suo
Binary file not shown.
111 changes: 111 additions & 0 deletions Example/MyStore/app/MyStore.DB/schema/UnitTestGeneratedSchema.sql
@@ -0,0 +1,111 @@

if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKDDD7BED2D9812CFF]') AND parent_object_id = OBJECT_ID('Products_ProductCategories'))
alter table Products_ProductCategories drop constraint FKDDD7BED2D9812CFF


if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKDDD7BED28F30214F]') AND parent_object_id = OBJECT_ID('Products_ProductCategories'))
alter table Products_ProductCategories drop constraint FKDDD7BED28F30214F


if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK570785C1427FAD8B]') AND parent_object_id = OBJECT_ID('Orders'))
alter table Orders drop constraint FK570785C1427FAD8B


if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKD1A96374B3D390D7]') AND parent_object_id = OBJECT_ID('OrderLineItems'))
alter table OrderLineItems drop constraint FKD1A96374B3D390D7


if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKD1A963748F30214F]') AND parent_object_id = OBJECT_ID('OrderLineItems'))
alter table OrderLineItems drop constraint FKD1A963748F30214F


if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FK248A035DD9812CFF]') AND parent_object_id = OBJECT_ID('ProductCategories'))
alter table ProductCategories drop constraint FK248A035DD9812CFF


if exists (select * from dbo.sysobjects where id = object_id(N'Products') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table Products

if exists (select * from dbo.sysobjects where id = object_id(N'Products_ProductCategories') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table Products_ProductCategories

if exists (select * from dbo.sysobjects where id = object_id(N'Customers') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table Customers

if exists (select * from dbo.sysobjects where id = object_id(N'Orders') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table Orders

if exists (select * from dbo.sysobjects where id = object_id(N'OrderLineItems') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table OrderLineItems

if exists (select * from dbo.sysobjects where id = object_id(N'ProductCategories') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table ProductCategories

create table Products (
Id INT IDENTITY NOT NULL,
Name NVARCHAR(255) null,
Amount DECIMAL(19,5) null,
primary key (Id)
)

create table Products_ProductCategories (
ProductFk INT not null,
ProductCategoryFk INT not null
)

create table Customers (
Id INT IDENTITY NOT NULL,
FirstName NVARCHAR(255) null,
LastName NVARCHAR(255) null,
StreetAddress NVARCHAR(255) null,
ZipCode NVARCHAR(255) null,
primary key (Id)
)

create table Orders (
Id INT IDENTITY NOT NULL,
PlacedOn DATETIME null,
OrderStatusTypeFk INT null,
CustomerFk INT null,
primary key (Id)
)

create table OrderLineItems (
Id INT IDENTITY NOT NULL,
OrderFk INT null,
Amount DECIMAL(19,5) null,
ProductFk INT null,
Quantity INT null,
primary key (Id)
)

create table ProductCategories (
Id INT IDENTITY NOT NULL,
Name NVARCHAR(255) null,
ProductCategoryFk INT null,
primary key (Id)
)

alter table Products_ProductCategories
add constraint FKDDD7BED2D9812CFF
foreign key (ProductCategoryFk)
references ProductCategories

alter table Products_ProductCategories
add constraint FKDDD7BED28F30214F
foreign key (ProductFk)
references Products

alter table Orders
add constraint FK570785C1427FAD8B
foreign key (CustomerFk)
references Customers

alter table OrderLineItems
add constraint FKD1A96374B3D390D7
foreign key (OrderFk)
references Orders

alter table OrderLineItems
add constraint FKD1A963748F30214F
foreign key (ProductFk)
references Products

alter table ProductCategories
add constraint FK248A035DD9812CFF
foreign key (ProductCategoryFk)
references ProductCategories
30 changes: 30 additions & 0 deletions Example/MyStore/app/MyStore.Domain/ActionConfirmation.cs
@@ -0,0 +1,30 @@
namespace MyStore.Domain
{
/// <summary>
/// Provides a generic typed mechanism for returning success/failure feedback along with a value
/// </summary>
public class ActionConfirmation<T>
{
private ActionConfirmation(string message) {
Message = message;
}

public static ActionConfirmation<T> CreateSuccessConfirmation(string message, T value) {
return new ActionConfirmation<T>(message) {
WasSuccessful = true,
Value = value
};
}

public static ActionConfirmation<T> CreateFailureConfirmation(string message, T value) {
return new ActionConfirmation<T>(message) {
WasSuccessful = false,
Value = value
};
}

public bool WasSuccessful { get; private set; }
public string Message { get; set; }
public T Value { get; set; }
}
}
19 changes: 19 additions & 0 deletions Example/MyStore/app/MyStore.Domain/Address.cs
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;

namespace MyStore.Domain
{
/// <summary>
/// This is a component of Customer
/// </summary>
public class Address
{
[StringLength(255, ErrorMessage = "Street address must be 255 characters or fewer")]
[Display(Name = "Street Address")]
public virtual string StreetAddress { get; set; }

[Required(ErrorMessage = "Zip code must be provided")]
[StringLength(5, ErrorMessage = "Zip code must be 5 characters or fewer")]
[Display(Name = "Zip Code")]
public virtual string ZipCode { get; set; }
}
}
38 changes: 38 additions & 0 deletions Example/MyStore/app/MyStore.Domain/Customer.cs
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using SharpLite.Domain;
using SharpLite.Domain.Validators;

namespace MyStore.Domain
{
[HasUniqueDomainSignature(ErrorMessage="A customer already exists with the same first and last name")]
public class Customer : Entity
{
public Customer() {
Orders = new List<Order>();
}

[DomainSignature]
[Required(ErrorMessage = "First name must be provided")]
[StringLength(255, ErrorMessage = "First name must be 255 characters or fewer")]
[Display(Name="First Name")]
public virtual string FirstName { get; set; }

[DomainSignature]
[Required(ErrorMessage = "Last name must be provided")]
[StringLength(255, ErrorMessage = "Last name must be 255 characters or fewer")]
[Display(Name = "Last Name")]
public virtual string LastName { get; set; }

/// <summary>
/// Address is a component, not a separate entity; i.e., the Customers table will have
/// columns for each property of Address
/// </summary>
public virtual Address Address { get; set; }

/// <summary>
/// one-to-many from Customer to Order
/// </summary>
public virtual IList<Order> Orders { get; protected set; }
}
}
19 changes: 19 additions & 0 deletions Example/MyStore/app/MyStore.Domain/Money.cs
@@ -0,0 +1,19 @@
using System;

namespace MyStore.Domain
{
public class Money
{
protected Money() { }

public Money(decimal amount) {
Amount = amount;
}

public decimal Amount { get; set; }

public override string ToString() {
return String.Format("{0:c}", Amount);
}
}
}
78 changes: 78 additions & 0 deletions Example/MyStore/app/MyStore.Domain/MyStore.Domain.csproj
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{74801410-F690-490C-91EA-CD94E520A465}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyStore.Domain</RootNamespace>
<AssemblyName>MyStore.Domain</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="SharpLite.Domain, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpLite.Domain.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActionConfirmation.cs" />
<Compile Include="Address.cs" />
<Compile Include="Customer.cs" />
<Compile Include="ProductMgmt\Queries\IQueryForProductOrderSummaries.cs" />
<Compile Include="Money.cs" />
<Compile Include="Order.cs" />
<Compile Include="OrderLineItem.cs" />
<Compile Include="OrderStatusType.cs" />
<Compile Include="ProductMgmt\Product.cs" />
<Compile Include="ProductMgmt\ProductCategory.cs" />
<Compile Include="ProductMgmt\Queries\ProductOrderSummaryDto.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Queries\CustomerOrderSummaryDto.cs" />
<Compile Include="Queries\FindActiveCustomers.cs" />
<Compile Include="Queries\QueryForCustomerOrderSummaries.cs" />
<Compile Include="Validators\DataAnnotationsValidator.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ProductMgmt\Queries\README.txt" />
<Content Include="Queries\README.txt" />
<Content Include="Validators\README.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 7f6d31f

Please sign in to comment.