Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored Interfaces out of the Repository class

  • Loading branch information...
commit 40051902b61f4455c1dc99433e1d6123ea116638 1 parent 068cc5d
@soitgoes authored
View
13 LoveSeat.Interfaces/IAuditableRecord.cs
@@ -0,0 +1,13 @@
+using System;
+using LoveSeat.Repository;
+
+namespace Accounting.Domain
+{
+ public interface IAuditableRecord : IBaseObject
+ {
+ DateTime CreatedAt { get; set; }
+ DateTime LastModifiedAt { get; set; }
+ string CreatedBy { get; set; }
+ string LastModifiedBy { get; set; }
+ }
+}
View
3  LoveSeat.Repository/IBaseObject.cs → LoveSeat.Interfaces/IBaseObject.cs
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
namespace LoveSeat.Repository
{
View
0  LoveSeat.Repository/IRepository.cs → LoveSeat.Interfaces/IRepository.cs
File renamed without changes
View
47 LoveSeat.Interfaces/LoveSeat.Interfaces.csproj
@@ -0,0 +1,47 @@
+<?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>{18833FC5-9145-451D-82D4-41A1886B0BE7}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>LoveSeat.Interfaces</RootNamespace>
+ <AssemblyName>LoveSeat.Interfaces</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>
+ <Compile Include="IAuditableRecord.cs" />
+ <Compile Include="IBaseObject.cs" />
+ <Compile Include="IRepository.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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>
View
36 LoveSeat.Interfaces/Properties/AssemblyInfo.cs
@@ -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("LoveSeat.Interfaces")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("LoveSeat.Interfaces")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 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("07ab2e6c-e8e5-490f-943a-3c8f568031cd")]
+
+// 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")]
View
22 LoveSeat.Repository/AuditableRepository.cs
@@ -0,0 +1,22 @@
+using System;
+using Accounting.Domain;
+using LoveSeat.Repository;
+
+namespace LoveSeat.Repositories
+{
+ public abstract class AuditableRepository<T> : CouchRepository<T> where T : IAuditableRecord
+ {
+ protected AuditableRepository(CouchDatabase db) : base(db)
+ {
+ }
+ public override void Save(T item)
+ {
+ if (item.Rev == null)
+ item.CreatedAt = DateTime.Now;
+ item.LastModifiedAt = DateTime.Now;
+ if (item.Id == Guid.Empty)
+ item.Id = Guid.NewGuid();
+ base.Save(item);
+ }
+ }
+}
View
3  LoveSeat.Repository/CouchRepository.cs
@@ -1,6 +1,7 @@
using System;
+using LoveSeat.Repository;
-namespace LoveSeat.Repository
+namespace LoveSeat.Repositories
{
public class CouchRepository<T> : IRepository<T> where T : IBaseObject
{
View
15 LoveSeat.Repository/LoveSeat.Repository.csproj → LoveSeat.Repository/LoveSeat.Repositories.csproj
@@ -8,8 +8,8 @@
<ProjectGuid>{95A18B36-B97A-4A39-8920-B245ACD12AAD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>LoveSeat.Repository</RootNamespace>
- <AssemblyName>LoveSeat.Repository</AssemblyName>
+ <RootNamespace>LoveSeat.Repositories</RootNamespace>
+ <AssemblyName>LoveSeat.Repositories</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
@@ -36,19 +36,18 @@
</Reference>
<Reference Include="System" />
<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="AuditableRepository.cs" />
<Compile Include="CouchRepository.cs" />
- <Compile Include="IBaseObject.cs" />
- <Compile Include="IRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\LoveSeat.Interfaces\LoveSeat.Interfaces.csproj">
+ <Project>{18833FC5-9145-451D-82D4-41A1886B0BE7}</Project>
+ <Name>LoveSeat.Interfaces</Name>
+ </ProjectReference>
<ProjectReference Include="..\LoveSeat\LoveSeat.csproj">
<Project>{AF987164-0100-4A90-A767-D473F882EA8B}</Project>
<Name>LoveSeat</Name>
View
8 LoveSeat.sln
@@ -5,7 +5,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoveSeat", "LoveSeat\LoveSe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoveSeat.IntegrationTest", "LoveSeat.IntegrationTest\LoveSeat.IntegrationTest.csproj", "{7496CEA9-442C-4468-8350-54F34693F64A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoveSeat.Repository", "LoveSeat.Repository\LoveSeat.Repository.csproj", "{95A18B36-B97A-4A39-8920-B245ACD12AAD}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoveSeat.Repositories", "LoveSeat.Repository\LoveSeat.Repositories.csproj", "{95A18B36-B97A-4A39-8920-B245ACD12AAD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoveSeat.Interfaces", "LoveSeat.Interfaces\LoveSeat.Interfaces.csproj", "{18833FC5-9145-451D-82D4-41A1886B0BE7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -25,6 +27,10 @@ Global
{95A18B36-B97A-4A39-8920-B245ACD12AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95A18B36-B97A-4A39-8920-B245ACD12AAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95A18B36-B97A-4A39-8920-B245ACD12AAD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {18833FC5-9145-451D-82D4-41A1886B0BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {18833FC5-9145-451D-82D4-41A1886B0BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {18833FC5-9145-451D-82D4-41A1886B0BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {18833FC5-9145-451D-82D4-41A1886B0BE7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Please sign in to comment.
Something went wrong with that request. Please try again.