Permalink
Browse files

Fixed a number of issues described in VersionHistory.txt and added la…

…rge amount of new sample code and comprehensive greenfield development guide (work-in-progress)
  • Loading branch information...
1 parent 37f4de3 commit 2ccd4098c2d0d31013e98da7d5361b3d8d987059 Billy McCafferty committed Mar 9, 2012
Showing 331 changed files with 333,912 additions and 410 deletions.
View
@@ -0,0 +1,28 @@
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
View
@@ -0,0 +1,56 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.Web", "app\CaTS.Web\CaTS.Web.csproj", "{3B107D47-9BB3-4D6A-80E2-E430D6C06F45}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.Domain", "app\CaTS.Domain\CaTS.Domain.csproj", "{74801410-F690-490C-91EA-CD94E520A465}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.NHibernateProvider", "app\CaTS.NHibernateProvider\CaTS.NHibernateProvider.csproj", "{4E471CAC-A108-49AE-A4D6-155DC35712C9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.Tasks", "app\CaTS.Tasks\CaTS.Tasks.csproj", "{BE147A77-3E59-40E6-822D-5AEDFD5D383C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.Tests", "app\CaTS.Tests\CaTS.Tests.csproj", "{CEF24DDD-1D15-42BC-B035-4A33388C3F8C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaTS.Init", "app\CaTS.Init\CaTS.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
@@ -0,0 +1,12 @@
+
+ if exists (select * from dbo.sysobjects where id = object_id(N'StaffMembers') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table StaffMembers
+
+ create table StaffMembers (
+ Id INT IDENTITY NOT NULL,
+ EmployeeNumber NVARCHAR(255) null,
+ FirstName NVARCHAR(255) null,
+ LastName NVARCHAR(255) null,
+ PasswordHash NVARCHAR(255) null,
+ Roles INT null,
+ primary key (Id)
+ )
@@ -0,0 +1,30 @@
+namespace CaTS.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; }
+ }
+}
@@ -0,0 +1,66 @@
+<?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>CaTS.Domain</RootNamespace>
+ <AssemblyName>CaTS.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="Properties\AssemblyInfo.cs" />
+ <Compile Include="RoleType.cs" />
+ <Compile Include="Utilities\Hasher.cs" />
+ <Compile Include="StaffMember.cs" />
+ <Compile Include="Validators\DataAnnotationsValidator.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Queries\" />
+ </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,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CaTS.Domain")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Codai")]
+[assembly: AssemblyProduct("CaTS.Domain")]
+[assembly: AssemblyCopyright("Copyright © Codai 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("879a78ed-9b39-435b-be3b-054c0858c80b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,15 @@
+using System;
+
+namespace CaTS.Domain
+{
+ /// <remarks>
+ /// All powers of 2 so we can OR them to combine role permissions.
+ /// </remarks>
+ [Flags]
+ public enum RoleType
+ {
+ Administrator = 1,
+ Manager = 2,
+ SupportStaff = 4
+ }
+}
@@ -0,0 +1,42 @@
+using System.ComponentModel.DataAnnotations;
+using SharpLite.Domain;
+using SharpLite.Domain.Validators;
+
+namespace CaTS.Domain
+{
+ [HasUniqueDomainSignature(
+ ErrorMessage="A staff member already exists with the same employee number")]
+ public class StaffMember : Entity
+ {
+ [Required(ErrorMessage = "Employee number must be provided")]
+ [StringLength(6, MinimumLength = 6,
+ ErrorMessage = "Employee number must be 6 characters long")]
+ [Display(Name = "Employee Number")]
+ public virtual string EmployeeNumber { get; set; }
+
+ [Required(ErrorMessage = "First name must be provided")]
+ [StringLength(50, ErrorMessage = "First name must be 50 characters or fewer")]
+ [Display(Name = "First Name")]
+ public virtual string FirstName { get; set; }
+
+ [Required(ErrorMessage = "Last name must be provided")]
+ [StringLength(50, ErrorMessage = "Last name must be 50 characters or fewer")]
+ [Display(Name = "Last Name")]
+ public virtual string LastName { get; set; }
+
+ [Required(ErrorMessage = "PasswordHash must be provided")]
+ public virtual string PasswordHash { get; set; }
+
+ /// <summary>
+ /// Represents one or more roles that the staff member has been assigned.
+ /// E.g., set property to RoleType.Manager for one role and
+ /// (RoleType.Manager | RoleType.SupportStaff) for two roles.
+ /// </summary>
+ public virtual RoleType Roles { get; set; }
+
+ public virtual bool IsAuthorizedAs(RoleType requiredRoles) {
+ // Check if the roles enum has the specific role bit set
+ return (requiredRoles & Roles) == requiredRoles;
+ }
+ }
+}
@@ -0,0 +1,17 @@
+using System.Security.Cryptography;
+using System.Text;
+
+namespace CaTS.Domain.Utilities
+{
+ public class Hasher
+ {
+ public static string Hash(string value) {
+ var addSalt = string.Concat(HASH_SALT, value);
+ var sha1Hashser = new SHA1CryptoServiceProvider();
+ var hashedBytes = sha1Hashser.ComputeHash(Encoding.Unicode.GetBytes(addSalt));
+ return new UnicodeEncoding().GetString(hashedBytes);
+ }
+
+ private const string HASH_SALT = "I^>cI'}7hgIdKlCLY2%:";
+ }
+}
@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+
+namespace CaTS.Domain.Validators
+{
+ public class DataAnnotationsValidator
+ {
+ public static bool TryValidate(object @object) {
+ ICollection<ValidationResult> ignoredResults;
+ return TryValidate(@object, out ignoredResults);
+ }
+
+ public static bool TryValidate(object @object, out ICollection<ValidationResult> results) {
+ var context = new ValidationContext(@object, serviceProvider: null, items: null);
+ results = new List<ValidationResult>();
+
+ return Validator.TryValidateObject(
+ @object, context, results,
+ validateAllProperties: true
+ );
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 2ccd409

Please sign in to comment.