summaryrefslogtreecommitdiff
path: root/slips/src/app/Marina
diff options
context:
space:
mode:
Diffstat (limited to 'slips/src/app/Marina')
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/DatabaseDelete.cs31
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/DatabaseInsert.cs50
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/DatabaseSelect.cs101
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/DatabaseUpdate.cs52
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IDeleteQueryBuilder.cs3
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IInsertQueryBuilder.cs5
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IJoin.cs6
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IQuery.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IQueryBuilder.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/ISelectQueryBuilder.cs11
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/IUpdateQueryBuilder.cs5
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/Query.cs22
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/SqlQuery.cs18
-rw-r--r--slips/src/app/Marina/DataAccess/Builders/WhereClause.cs27
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/BoatDataMapper.cs74
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/CustomerDataMapper.cs82
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/DockDataMapper.cs54
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/IBoatDataMapper.cs12
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/ICustomerDataMapper.cs11
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/IDataMapper.cs5
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/IDockDataMapper.cs6
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/ILeaseDataMapper.cs14
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/IRegistrationDataMapper.cs11
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/ISlipDataMapper.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/LeaseDataMapper.cs87
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/RegistrationDataMapper.cs88
-rw-r--r--slips/src/app/Marina/DataAccess/DataMappers/SlipDataMapper.cs97
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseColumn.cs23
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseCommand.cs23
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseCommandParameter.cs19
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseConfiguration.cs22
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseConnection.cs38
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseConnectionFactory.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseGateway.cs60
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseProviderFactory.cs10
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseRow.cs24
-rw-r--r--slips/src/app/Marina/DataAccess/DatabaseTransaction.cs19
-rw-r--r--slips/src/app/Marina/DataAccess/Exceptions/ObjectAlreadyAddedToIdentityMapException.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseCommand.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseConfiguration.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseConnection.cs10
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseConnectionFactory.cs5
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseGateway.cs19
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseProviderFactory.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseRow.cs5
-rw-r--r--slips/src/app/Marina/DataAccess/IDatabaseTransaction.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/IIdentityMap.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/IdentityMap.cs42
-rw-r--r--slips/src/app/Marina/DataAccess/Repositories/CustomerRepository.cs51
-rw-r--r--slips/src/app/Marina/DataAccess/Repositories/DockRepository.cs20
-rw-r--r--slips/src/app/Marina/DataAccess/Repositories/SlipsRepository.cs58
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/AuthorizationTable.cs9
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/BoatTable.cs11
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/CustomerTable.cs10
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/DockTable.cs10
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/LeaseTable.cs11
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/LeaseType.cs8
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/LocationTable.cs7
-rw-r--r--slips/src/app/Marina/DataAccess/Schemas/SlipTable.cs9
-rw-r--r--slips/src/app/Marina/Domain/Boat.cs72
-rw-r--r--slips/src/app/Marina/Domain/BrokenRule.cs15
-rw-r--r--slips/src/app/Marina/Domain/Customer.cs76
-rw-r--r--slips/src/app/Marina/Domain/CustomerRegistration.cs151
-rw-r--r--slips/src/app/Marina/Domain/DateRange.cs22
-rw-r--r--slips/src/app/Marina/Domain/Dock.cs33
-rw-r--r--slips/src/app/Marina/Domain/DomainObject.cs19
-rw-r--r--slips/src/app/Marina/Domain/Exceptions/SlipIsAlreadyLeasedException.cs5
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IBoat.cs13
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IBrokenRule.cs5
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IBusinessRule.cs9
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ICustomer.cs27
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IDateRange.cs9
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IDock.cs11
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IDomainObject.cs7
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ILeaseDuration.cs10
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ILeaseType.cs7
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ILocation.cs5
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IRange.cs11
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IRegistration.cs22
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ISlip.cs15
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/ISlipLease.cs13
-rw-r--r--slips/src/app/Marina/Domain/Interfaces/IUtility.cs5
-rw-r--r--slips/src/app/Marina/Domain/LeaseDurations.cs62
-rw-r--r--slips/src/app/Marina/Domain/Location.cs15
-rw-r--r--slips/src/app/Marina/Domain/Range.cs32
-rw-r--r--slips/src/app/Marina/Domain/Repositories/ICustomerRepository.cs13
-rw-r--r--slips/src/app/Marina/Domain/Repositories/IDockRepository.cs7
-rw-r--r--slips/src/app/Marina/Domain/Repositories/ISlipsRepository.cs12
-rw-r--r--slips/src/app/Marina/Domain/Slip.cs46
-rw-r--r--slips/src/app/Marina/Domain/SlipLease.cs37
-rw-r--r--slips/src/app/Marina/Domain/UnknownCustomer.cs39
-rw-r--r--slips/src/app/Marina/Domain/Utilities.cs91
-rw-r--r--slips/src/app/Marina/Infrastructure/BlankCommand.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItem.cs13
-rw-r--r--slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItems.cs15
-rw-r--r--slips/src/app/Marina/Infrastructure/Container/Custom/CustomDependencyContainer.cs21
-rw-r--r--slips/src/app/Marina/Infrastructure/Container/IDependencyContainer.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/Container/InterfaceResolutionException.cs11
-rw-r--r--slips/src/app/Marina/Infrastructure/Container/Resolve.cs21
-rw-r--r--slips/src/app/Marina/Infrastructure/Container/Windsor/WindsorDependencyContainer.cs16
-rw-r--r--slips/src/app/Marina/Infrastructure/EnumerableMapper.cs17
-rw-r--r--slips/src/app/Marina/Infrastructure/ICommand.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/IFactory.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/IMapper.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/IRichEnumerable.cs7
-rw-r--r--slips/src/app/Marina/Infrastructure/IRichList.cs91
-rw-r--r--slips/src/app/Marina/Infrastructure/ISpecification.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/ISpecificationBuilder.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/ITransformer.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/IValueReturningVisitor.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/IVisitor.cs5
-rw-r--r--slips/src/app/Marina/Infrastructure/ListFactory.cs20
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs7
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs7
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs14
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs8
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs19
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs23
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs30
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs24
-rw-r--r--slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs10
-rw-r--r--slips/src/app/Marina/Infrastructure/RichEnumerable.cs28
-rw-r--r--slips/src/app/Marina/Infrastructure/RichList.cs45
-rw-r--r--slips/src/app/Marina/Infrastructure/SpecificationBuilder.cs44
-rw-r--r--slips/src/app/Marina/Infrastructure/Transform.cs7
-rw-r--r--slips/src/app/Marina/Infrastructure/Transformer.cs22
-rw-r--r--slips/src/app/Marina/Marina.csproj322
-rw-r--r--slips/src/app/Marina/Presentation/DTO/BoatRegistrationDTO.cs41
-rw-r--r--slips/src/app/Marina/Presentation/DTO/CustomerRegistrationDisplayDTO.cs91
-rw-r--r--slips/src/app/Marina/Presentation/DTO/DisplayLeaseDTO.cs28
-rw-r--r--slips/src/app/Marina/Presentation/DTO/DisplayResponseLineDTO.cs36
-rw-r--r--slips/src/app/Marina/Presentation/DTO/DisplayResponseLines.cs24
-rw-r--r--slips/src/app/Marina/Presentation/DTO/DockDisplayDTO.cs36
-rw-r--r--slips/src/app/Marina/Presentation/DTO/LoginCredentialsDTO.cs24
-rw-r--r--slips/src/app/Marina/Presentation/DTO/RegisterCustomerDTO.cs47
-rw-r--r--slips/src/app/Marina/Presentation/DTO/SlipDisplayDTO.cs48
-rw-r--r--slips/src/app/Marina/Presentation/DTO/SubmitLeaseRequestDTO.cs60
-rw-r--r--slips/src/app/Marina/Presentation/DTO/UpdateCustomerRegistrationDTO.cs53
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/CustomerRegistrationPresentationMapper.cs17
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/ICustomerRegistrationPresentationMapper.cs8
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/ILeaseRequestDtoFromHttpRequestMapper.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/ILoginCredentialsMapper.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/INewBoatRegistrationMapper.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/IUpdateRegistrationPresentationMapper.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/LeaseRequestDtoFromHttpRequestMapper.cs14
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/LoginCredentialsMapper.cs13
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/NewBoatRegistrationMapper.cs16
-rw-r--r--slips/src/app/Marina/Presentation/Mappers/UpdateRegistrationPresentationMapper.cs18
-rw-r--r--slips/src/app/Marina/Presentation/PayLoadKeys.cs12
-rw-r--r--slips/src/app/Marina/Presentation/PayloadKey.cs48
-rw-r--r--slips/src/app/Marina/Presentation/PayloadKeyNotFoundException.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/AvailableSlipsPresenter.cs25
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/CurrentLeasesPresenter.cs25
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/CustomerRegistrationPresenter.cs30
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/DockPresenter.cs31
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/IAvailableSlipsPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/ICurrentLeasesPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/ICustomerRegistrationPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/IDockPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/ILeaseSlipPresenter.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/ILoginPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/IRegisterBoatPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/IUpdateCustomerRegistrationPresenter.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/IViewRegisteredBoatsPresenter.cs5
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/LeaseSlipPresenter.cs41
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/LoginPresenter.cs34
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/RegisterBoatPresenter.cs33
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/UpdateCustomerRegistrationPresenter.cs44
-rw-r--r--slips/src/app/Marina/Presentation/Presenters/ViewRegisteredBoatsPresenter.cs25
-rw-r--r--slips/src/app/Marina/Presentation/Views/IAvailableSlipsView.cs8
-rw-r--r--slips/src/app/Marina/Presentation/Views/ICurrentLeasesView.cs8
-rw-r--r--slips/src/app/Marina/Presentation/Views/ICustomerRegistrationView.cs20
-rw-r--r--slips/src/app/Marina/Presentation/Views/IDockView.cs9
-rw-r--r--slips/src/app/Marina/Presentation/Views/ILeaseSlipView.cs9
-rw-r--r--slips/src/app/Marina/Presentation/Views/ILoginView.cs7
-rw-r--r--slips/src/app/Marina/Presentation/Views/IRegisterBoatView.cs8
-rw-r--r--slips/src/app/Marina/Presentation/Views/IRegisteredBoatsView.cs8
-rw-r--r--slips/src/app/Marina/Presentation/Views/IUpdateRegistrationView.cs9
-rw-r--r--slips/src/app/Marina/Properties/AssemblyInfo.cs36
-rw-r--r--slips/src/app/Marina/Task/ApplicationStartupTask.cs14
-rw-r--r--slips/src/app/Marina/Task/AuthenticationTask.cs41
-rw-r--r--slips/src/app/Marina/Task/CatalogTasks.cs52
-rw-r--r--slips/src/app/Marina/Task/IApplicationStartupTask.cs5
-rw-r--r--slips/src/app/Marina/Task/IAuthenticationTask.cs7
-rw-r--r--slips/src/app/Marina/Task/ICatalogTasks.cs14
-rw-r--r--slips/src/app/Marina/Task/ILeaseTasks.cs10
-rw-r--r--slips/src/app/Marina/Task/IRegistrationTasks.cs16
-rw-r--r--slips/src/app/Marina/Task/LeaseTasks.cs39
-rw-r--r--slips/src/app/Marina/Task/Mappers/BrokenRulesToDisplayItemMapper.cs13
-rw-r--r--slips/src/app/Marina/Task/Mappers/DockToDisplayDTOMapper.cs16
-rw-r--r--slips/src/app/Marina/Task/Mappers/IBrokenRulesToDisplayItemMapper.cs9
-rw-r--r--slips/src/app/Marina/Task/Mappers/IDockToDisplayDTOMapper.cs7
-rw-r--r--slips/src/app/Marina/Task/Mappers/ILeaseToDtoMapper.cs7
-rw-r--r--slips/src/app/Marina/Task/Mappers/ISlipsToDisplayDTOMapper.cs7
-rw-r--r--slips/src/app/Marina/Task/Mappers/LeaseToDtoMapper.cs12
-rw-r--r--slips/src/app/Marina/Task/Mappers/SlipsToDisplayDTOMapper.cs16
-rw-r--r--slips/src/app/Marina/Task/RegistrationTasks.cs92
-rw-r--r--slips/src/app/Marina/Web/AuthenticationHttpModule.cs28
-rw-r--r--slips/src/app/Marina/Web/Commands/AvailableSlipsCommand.cs23
-rw-r--r--slips/src/app/Marina/Web/Commands/CommandNames.cs5
-rw-r--r--slips/src/app/Marina/Web/Commands/RedirectCommand.cs11
-rw-r--r--slips/src/app/Marina/Web/CurrentHttpContext.cs135
-rw-r--r--slips/src/app/Marina/Web/CurrentHttpRequest.cs20
-rw-r--r--slips/src/app/Marina/Web/FrontController.cs21
-rw-r--r--slips/src/app/Marina/Web/GlobalApplication.cs17
-rw-r--r--slips/src/app/Marina/Web/Handlers/AvailableSlipsHandler.cs7
-rw-r--r--slips/src/app/Marina/Web/Handlers/Dispatcher.cs24
-rw-r--r--slips/src/app/Marina/Web/Handlers/IRegisteredHandlers.cs8
-rw-r--r--slips/src/app/Marina/Web/Handlers/IRequestHandler.cs6
-rw-r--r--slips/src/app/Marina/Web/Handlers/RegisteredHandlers.cs9
-rw-r--r--slips/src/app/Marina/Web/Handlers/RequestHandler.cs26
-rw-r--r--slips/src/app/Marina/Web/Handlers/RequestHandlerSpecification.cs16
-rw-r--r--slips/src/app/Marina/Web/Http/HttpGateway.cs71
-rw-r--r--slips/src/app/Marina/Web/Http/IHttpGateway.cs16
-rw-r--r--slips/src/app/Marina/Web/IHttpContext.cs69
-rw-r--r--slips/src/app/Marina/Web/IHttpRequest.cs7
-rw-r--r--slips/src/app/Marina/Web/Redirect.cs10
-rw-r--r--slips/src/app/Marina/Web/Services/AuthenticationServices.asmx1
-rw-r--r--slips/src/app/Marina/Web/Services/AuthenticationWebServices.cs21
-rw-r--r--slips/src/app/Marina/Web/Services/CatalogServices.asmx1
-rw-r--r--slips/src/app/Marina/Web/Services/CatalogWebServices.cs35
-rw-r--r--slips/src/app/Marina/Web/Services/LeaseServices.asmx1
-rw-r--r--slips/src/app/Marina/Web/Services/LeaseWebServices.cs26
-rw-r--r--slips/src/app/Marina/Web/Services/RegistrationServices.asmx1
-rw-r--r--slips/src/app/Marina/Web/Services/RegistrationWebServices.cs38
-rw-r--r--slips/src/app/Marina/Web/UnhandledExceptionsHttpModule.cs19
-rw-r--r--slips/src/app/Marina/Web/Views/IView.cs7
-rw-r--r--slips/src/app/Marina/Web/Views/IViewLuggageTicket.cs3
-rw-r--r--slips/src/app/Marina/Web/Views/IViewLuggageTransporter.cs7
-rw-r--r--slips/src/app/Marina/Web/Views/IWebView.cs5
-rw-r--r--slips/src/app/Marina/Web/Views/Pages/AvailableSlipsWebView.cs16
-rw-r--r--slips/src/app/Marina/Web/Views/Pages/IAvailableSlipsWebView.cs6
-rw-r--r--slips/src/app/Marina/Web/Views/View.cs28
-rw-r--r--slips/src/app/Marina/Web/Views/ViewLuggage.cs11
-rw-r--r--slips/src/app/Marina/Web/Views/ViewLuggageTickets.cs14
-rw-r--r--slips/src/app/Marina/Web/Views/ViewLuggageTransporter.cs32
-rw-r--r--slips/src/app/Marina/Web/Views/WebView.cs27
-rw-r--r--slips/src/app/Marina/Web/Views/WebViews.cs18
238 files changed, 5634 insertions, 0 deletions
diff --git a/slips/src/app/Marina/DataAccess/Builders/DatabaseDelete.cs b/slips/src/app/Marina/DataAccess/Builders/DatabaseDelete.cs
new file mode 100644
index 0000000..801aba0
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/DatabaseDelete.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace Marina.DataAccess.Builders {
+ public static class DatabaseDelete {
+ public static IQuery Where< T >( DatabaseColumn column, T equalsValue ) {
+ return new DeleteQueryBuilder< T >( column, equalsValue ).Build( );
+ }
+
+ private class DeleteQueryBuilder< T > : IDeleteQueryBuilder {
+ public DeleteQueryBuilder( DatabaseColumn column, T value ) {
+ _column = column;
+ _value = value;
+ }
+
+ public override string ToString() {
+ return string.Format( "DELETE FROM [{0}] WHERE [{0}].[{1}] = @{1};", _column.TableName, _column.ColumnName );
+ }
+
+ public IEnumerable< DatabaseCommandParameter > Parameters() {
+ yield return new DatabaseCommandParameter( _column.ColumnName, _value );
+ }
+
+ public IQuery Build() {
+ return new Query( this );
+ }
+
+ private readonly DatabaseColumn _column;
+ private readonly T _value;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/DatabaseInsert.cs b/slips/src/app/Marina/DataAccess/Builders/DatabaseInsert.cs
new file mode 100644
index 0000000..57c0c1d
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/DatabaseInsert.cs
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace Marina.DataAccess.Builders {
+ public static class DatabaseInsert {
+ public static IInsertQueryBuilder Into( string tableName ) {
+ return new InsertQueryBuilder( tableName );
+ }
+
+ private class InsertQueryBuilder : IInsertQueryBuilder {
+ public InsertQueryBuilder( string tableName ) {
+ _tableName = tableName;
+ _parameters = new List< DatabaseCommandParameter >( );
+ }
+
+ public IEnumerable< DatabaseCommandParameter > Parameters() {
+ return _parameters;
+ }
+
+ public IQuery Build() {
+ return new Query( this );
+ }
+
+ public IInsertQueryBuilder AddValue< T >( DatabaseColumn column, T value ) {
+ _parameters.Add( new DatabaseCommandParameter( column.ColumnName, value ) );
+ return this;
+ }
+
+ public override string ToString() {
+ StringBuilder builder = new StringBuilder( );
+ builder.AppendFormat( "INSERT INTO {0} ({1}) VALUES ({2});SELECT @@IDENTITY;", _tableName,
+ GetParameterNames( string.Empty ),
+ GetParameterNames( "@" ) );
+ return builder.ToString( );
+ }
+
+ private string GetParameterNames( string prefix ) {
+ StringBuilder builder = new StringBuilder( );
+ foreach ( DatabaseCommandParameter parameter in _parameters ) {
+ builder.AppendFormat( "{0}{1},", prefix, parameter.ColumnName );
+ }
+ builder.Remove( builder.Length - 1, 1 );
+ return builder.ToString( );
+ }
+
+ private readonly string _tableName;
+ private readonly IList< DatabaseCommandParameter > _parameters;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/DatabaseSelect.cs b/slips/src/app/Marina/DataAccess/Builders/DatabaseSelect.cs
new file mode 100644
index 0000000..6e61fff
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/DatabaseSelect.cs
@@ -0,0 +1,101 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace Marina.DataAccess.Builders {
+ public static class DatabaseSelect {
+ public static ISelectQueryBuilder From( string tableName ) {
+ return new SelectQueryBuilder( tableName );
+ }
+
+ private class SelectQueryBuilder : ISelectQueryBuilder {
+ public SelectQueryBuilder( string tableName ) {
+ _tableName = string.Format( "[{0}]", tableName );
+ _innerJoins = new List< InnerJoin >( );
+ _selectColumns = new List< DatabaseColumn >( );
+ }
+
+ public ISelectQueryBuilder AddColumn( DatabaseColumn column ) {
+ _selectColumns.Add( column );
+ return this;
+ }
+
+ public ISelectQueryBuilder InnerJoinOn( DatabaseColumn leftColumn, DatabaseColumn rightColumn ) {
+ _innerJoins.Add( new InnerJoin( leftColumn, rightColumn ) );
+ return this;
+ }
+
+ public ISelectQueryBuilder Where( DatabaseColumn column, string value ) {
+ _whereClause = new WhereClause( column, value );
+ return this;
+ }
+
+ public ISelectQueryBuilder Where< T >( DatabaseColumn column, T value ) {
+ return Where( column, value.ToString( ) );
+ }
+
+ public override string ToString() {
+ return
+ string.Format( "SELECT {0} FROM {1} {2} {3};", GetColumnNames( ), _tableName, GetInnerJoins( ), _whereClause );
+ }
+
+ public IEnumerable< DatabaseCommandParameter > Parameters() {
+ foreach ( DatabaseColumn databaseColumn in _selectColumns ) {
+ yield return new DatabaseCommandParameter( databaseColumn.ColumnName, string.Empty );
+ }
+ }
+
+ public IQuery Build() {
+ return new Query( this );
+ }
+
+ private string GetInnerJoins() {
+ StringBuilder builder = new StringBuilder( );
+ foreach ( InnerJoin innerJoin in _innerJoins ) {
+ builder.Append( innerJoin.ToString( ) );
+ }
+ return builder.ToString( );
+ }
+
+ private string GetColumnNames() {
+ StringBuilder builder = new StringBuilder( );
+ foreach ( DatabaseColumn selectColumn in _selectColumns ) {
+ builder.AppendFormat( "{0},", selectColumn );
+ }
+ builder.Remove( builder.Length - 1, 1 );
+ return builder.ToString( );
+ }
+
+ private readonly string _tableName;
+ private readonly IList< DatabaseColumn > _selectColumns;
+ private readonly IList< InnerJoin > _innerJoins;
+ private WhereClause _whereClause;
+
+ private class InnerJoin : IJoin {
+ public InnerJoin( DatabaseColumn leftColumn, DatabaseColumn rightColumn ) {
+ _leftColumn = leftColumn;
+ _rightColumn = rightColumn;
+ }
+
+ public DatabaseColumn Left() {
+ return _leftColumn;
+ }
+
+ public DatabaseColumn Right() {
+ return _rightColumn;
+ }
+
+ public override string ToString() {
+ return
+ string.Format( "INNER JOIN [{0}] ON [{0}].[{1}] = [{2}].[{3}]",
+ _leftColumn.TableName,
+ _leftColumn.ColumnName,
+ _rightColumn.TableName,
+ _rightColumn.ColumnName );
+ }
+
+ private readonly DatabaseColumn _leftColumn;
+ private readonly DatabaseColumn _rightColumn;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/DatabaseUpdate.cs b/slips/src/app/Marina/DataAccess/Builders/DatabaseUpdate.cs
new file mode 100644
index 0000000..8b90edc
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/DatabaseUpdate.cs
@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace Marina.DataAccess.Builders {
+ public static class DatabaseUpdate {
+ public static IUpdateQueryBuilder Where< T >( DatabaseColumn whereColumn, T whereValue ) {
+ return new UpdateQueryBuilder( whereColumn, whereValue.ToString( ) );
+ }
+
+ private class UpdateQueryBuilder : IUpdateQueryBuilder {
+ public UpdateQueryBuilder( DatabaseColumn whereColumn, string whereValue )
+ : this( new List< DatabaseCommandParameter >( ), new WhereClause( whereColumn, whereValue ) ) {}
+
+ public UpdateQueryBuilder( IList< DatabaseCommandParameter > parameters, WhereClause where ) {
+ _parameters = parameters;
+ _where = where;
+ }
+
+ public IEnumerable< DatabaseCommandParameter > Parameters() {
+ return _parameters;
+ }
+
+ public IQuery Build() {
+ return new Query( this );
+ }
+
+ public IUpdateQueryBuilder Add( DatabaseColumn column, string value ) {
+ _parameters.Add( new DatabaseCommandParameter( column.ColumnName, value ) );
+ return this;
+ }
+
+ public override string ToString() {
+ StringBuilder builder = new StringBuilder( );
+ builder.AppendFormat( "UPDATE [{0}] SET {1};", _where.Column( ).TableName, GetParameterNames( ) );
+ return builder.ToString( );
+ }
+
+ private string GetParameterNames() {
+ StringBuilder builder = new StringBuilder( );
+ foreach ( DatabaseCommandParameter parameter in _parameters ) {
+ builder.AppendFormat( "[{0}].[{1}] = @{1},", _where.Column( ).TableName, parameter.ColumnName );
+ }
+ builder.Remove( builder.Length - 1, 1 );
+ builder.Append( _where );
+ return builder.ToString( );
+ }
+
+ private readonly IList< DatabaseCommandParameter > _parameters;
+ private readonly WhereClause _where;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IDeleteQueryBuilder.cs b/slips/src/app/Marina/DataAccess/Builders/IDeleteQueryBuilder.cs
new file mode 100644
index 0000000..2b7290a
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IDeleteQueryBuilder.cs
@@ -0,0 +1,3 @@
+namespace Marina.DataAccess.Builders {
+ public interface IDeleteQueryBuilder : IQueryBuilder {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IInsertQueryBuilder.cs b/slips/src/app/Marina/DataAccess/Builders/IInsertQueryBuilder.cs
new file mode 100644
index 0000000..946c914
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IInsertQueryBuilder.cs
@@ -0,0 +1,5 @@
+namespace Marina.DataAccess.Builders {
+ public interface IInsertQueryBuilder : IQueryBuilder {
+ IInsertQueryBuilder AddValue< T >( DatabaseColumn column, T value );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IJoin.cs b/slips/src/app/Marina/DataAccess/Builders/IJoin.cs
new file mode 100644
index 0000000..c4ae46f
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IJoin.cs
@@ -0,0 +1,6 @@
+namespace Marina.DataAccess.Builders {
+ internal interface IJoin {
+ DatabaseColumn Left();
+ DatabaseColumn Right();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IQuery.cs b/slips/src/app/Marina/DataAccess/Builders/IQuery.cs
new file mode 100644
index 0000000..a45527f
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IQuery.cs
@@ -0,0 +1,7 @@
+using System.Data;
+
+namespace Marina.DataAccess.Builders {
+ public interface IQuery {
+ void Prepare( IDbCommand command );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IQueryBuilder.cs b/slips/src/app/Marina/DataAccess/Builders/IQueryBuilder.cs
new file mode 100644
index 0000000..175c2d5
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IQueryBuilder.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Marina.DataAccess.Builders {
+ public interface IQueryBuilder {
+ IEnumerable< DatabaseCommandParameter > Parameters();
+
+ IQuery Build();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/ISelectQueryBuilder.cs b/slips/src/app/Marina/DataAccess/Builders/ISelectQueryBuilder.cs
new file mode 100644
index 0000000..058a7a1
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/ISelectQueryBuilder.cs
@@ -0,0 +1,11 @@
+namespace Marina.DataAccess.Builders {
+ public interface ISelectQueryBuilder : IQueryBuilder {
+ ISelectQueryBuilder AddColumn( DatabaseColumn column );
+
+ ISelectQueryBuilder InnerJoinOn( DatabaseColumn leftColumn, DatabaseColumn rightColumn );
+
+ ISelectQueryBuilder Where( DatabaseColumn column, string value );
+
+ ISelectQueryBuilder Where< T >( DatabaseColumn column, T value );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/IUpdateQueryBuilder.cs b/slips/src/app/Marina/DataAccess/Builders/IUpdateQueryBuilder.cs
new file mode 100644
index 0000000..c599243
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/IUpdateQueryBuilder.cs
@@ -0,0 +1,5 @@
+namespace Marina.DataAccess.Builders {
+ public interface IUpdateQueryBuilder : IQueryBuilder {
+ IUpdateQueryBuilder Add( DatabaseColumn column, string value );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/Query.cs b/slips/src/app/Marina/DataAccess/Builders/Query.cs
new file mode 100644
index 0000000..0b95bf1
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/Query.cs
@@ -0,0 +1,22 @@
+using System.Data;
+
+namespace Marina.DataAccess.Builders {
+ public class Query : IQuery {
+ public Query( IQueryBuilder builder ) {
+ _builder = builder;
+ }
+
+ public void Prepare( IDbCommand command ) {
+ command.CommandText = _builder.ToString( );
+ command.CommandType = CommandType.Text;
+ foreach ( DatabaseCommandParameter parameter in _builder.Parameters( ) ) {
+ IDataParameter commandParameter = command.CreateParameter( );
+ commandParameter.ParameterName = "@" + parameter.ColumnName;
+ commandParameter.Value = parameter.Value;
+ command.Parameters.Add( commandParameter );
+ }
+ }
+
+ private readonly IQueryBuilder _builder;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/SqlQuery.cs b/slips/src/app/Marina/DataAccess/Builders/SqlQuery.cs
new file mode 100644
index 0000000..c6b2b47
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/SqlQuery.cs
@@ -0,0 +1,18 @@
+using System.Data;
+
+namespace Marina.DataAccess.Builders {
+ public class SqlQuery : IQuery {
+ public SqlQuery( string sqlQuery ) {
+ _sqlQuery = sqlQuery;
+ }
+
+ public void Prepare( IDbCommand command ) {
+ if ( command != null ) {
+ command.CommandText = _sqlQuery;
+ command.CommandType = CommandType.Text;
+ }
+ }
+
+ private readonly string _sqlQuery;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Builders/WhereClause.cs b/slips/src/app/Marina/DataAccess/Builders/WhereClause.cs
new file mode 100644
index 0000000..5768fde
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Builders/WhereClause.cs
@@ -0,0 +1,27 @@
+namespace Marina.DataAccess.Builders {
+ public class WhereClause {
+ public WhereClause( DatabaseColumn column, string value ) {
+ _column = column;
+ _value = value;
+ }
+
+ public DatabaseColumn Column() {
+ return _column;
+ }
+
+ public string Value() {
+ return _value;
+ }
+
+ public string ToSql() {
+ return ToString( );
+ }
+
+ public override string ToString() {
+ return string.Format( " WHERE [{0}].[{1}] = {2};", _column.TableName, _column.ColumnName, _value );
+ }
+
+ private readonly DatabaseColumn _column;
+ private readonly string _value;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/BoatDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/BoatDataMapper.cs
new file mode 100644
index 0000000..fbd33cd
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/BoatDataMapper.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class BoatDataMapper : IBoatDataMapper {
+ public BoatDataMapper() : this( Resolve.DependencyFor< IDatabaseGateway >( ) ) {}
+
+ public BoatDataMapper( IDatabaseGateway gateway ) {
+ _gateway = gateway;
+ }
+
+ public IEnumerable< IBoat > AllBoatsFor( long customerId ) {
+ return Map.From( _gateway.FindAllRowsMatching( Queries.SelectBoatsFor( customerId ) ) );
+ }
+
+ public void Insert( IEnumerable< IBoat > boats, long forCustomerId ) {
+ _gateway.Execute( Queries.InsertQueriesFor( boats, forCustomerId ) );
+ }
+
+ public void Update( IEnumerable< IBoat > boats, long forCustomerId ) {
+ using ( IDatabaseTransaction transaction = new DatabaseTransaction( ) ) {
+ _gateway.Execute( DatabaseDelete.Where( BoatTable.CustomerID, forCustomerId ) );
+ Insert( boats, forCustomerId );
+ transaction.Commit( );
+ }
+ }
+
+ private readonly IDatabaseGateway _gateway;
+
+ private class Queries {
+ public static IQuery SelectBoatsFor( long customerId ) {
+ return DatabaseSelect.From( BoatTable.TableName )
+ .AddColumn( BoatTable.Length )
+ .AddColumn( BoatTable.Manufacturer )
+ .AddColumn( BoatTable.ModelYear )
+ .AddColumn( BoatTable.RegistrationNumber )
+ .AddColumn( BoatTable.BoatID )
+ .Where( BoatTable.CustomerID, customerId.ToString( ) ).Build( );
+ }
+
+ public static IEnumerable< IQuery > InsertQueriesFor( IEnumerable< IBoat > boats, long customerId ) {
+ foreach ( IBoat boat in boats ) {
+ yield return DatabaseInsert.Into( BoatTable.TableName )
+ .AddValue( BoatTable.CustomerID, customerId )
+ .AddValue( BoatTable.Length, boat.LengthInFeet( ) )
+ .AddValue( BoatTable.Manufacturer, boat.Manufacturer( ) )
+ .AddValue( BoatTable.ModelYear, boat.YearOfModel( ).Year )
+ .AddValue( BoatTable.RegistrationNumber, boat.RegistrationNumber( ) ).Build( );
+ }
+ }
+ }
+
+ private class Map {
+ public static IEnumerable< IBoat > From( IEnumerable< IDatabaseRow > rows ) {
+ foreach ( IDatabaseRow dataRow in rows ) {
+ yield return new Boat(
+ dataRow.From< long >( BoatTable.BoatID ),
+ dataRow.From< string >( BoatTable.RegistrationNumber ),
+ dataRow.From< string >( BoatTable.Manufacturer ),
+ dataRow.From< int >( BoatTable.ModelYear ) != 0
+ ? new DateTime( dataRow.From< int >( BoatTable.ModelYear ), 1, 01 )
+ : DateTime.MinValue,
+ dataRow.From< long >( BoatTable.Length )
+ );
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/CustomerDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/CustomerDataMapper.cs
new file mode 100644
index 0000000..cdc56be
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/CustomerDataMapper.cs
@@ -0,0 +1,82 @@
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class CustomerDataMapper : ICustomerDataMapper {
+ public CustomerDataMapper() : this
+ (
+ Resolve.DependencyFor< IDatabaseGateway >( ),
+ Resolve.DependencyFor< IBoatDataMapper >( ),
+ Resolve.DependencyFor< ILeaseDataMapper >( ),
+ Resolve.DependencyFor< IRegistrationDataMapper >( )
+ ) {}
+
+ public CustomerDataMapper( IDatabaseGateway gateway, IBoatDataMapper boatMapper, ILeaseDataMapper leaseMapper,
+ IRegistrationDataMapper registrationMapper ) {
+ _gateway = gateway;
+ _boatMapper = boatMapper;
+ _leaseMapper = leaseMapper;
+ _registrationMapper = registrationMapper;
+ }
+
+ public ICustomer FindBy( long customerId ) {
+ if ( customerId > 0 ) {
+ return new Customer( customerId,
+ _boatMapper.AllBoatsFor( customerId ),
+ _leaseMapper.AllLeasesFor( customerId ),
+ _registrationMapper.For( customerId ) );
+ }
+ return null;
+ }
+
+ public ICustomer FindBy( string username ) {
+ IDatabaseRow row = _gateway.LoadRowUsing( Queries.SelectCustomerBy( username ) );
+ return FindBy( row.From< long >( AuthorizationTable.CustomerID ) );
+ }
+
+ public void Insert( ICustomer customer ) {
+ using ( IDatabaseTransaction workUnit = new DatabaseTransaction( ) ) {
+ customer.ChangeIdTo( _gateway.ExecuteScalar( Queries.Insert( ) ) );
+ _registrationMapper.Insert( customer.Registration( ), customer.ID( ) );
+ _boatMapper.Insert( customer.RegisteredBoats( ), customer.ID( ) );
+ _leaseMapper.Insert( customer.Leases( ), customer.ID( ) );
+ workUnit.Commit( );
+ }
+ }
+
+ public void Update( ICustomer customer ) {
+ using ( IDatabaseTransaction workUnit = new DatabaseTransaction( ) ) {
+ _registrationMapper.Update( customer.Registration( ), customer.ID( ) );
+ _boatMapper.Update( customer.RegisteredBoats( ), customer.ID( ) );
+ _leaseMapper.Update( customer.Leases( ), customer.ID( ) );
+ workUnit.Commit( );
+ }
+ }
+
+ private readonly IDatabaseGateway _gateway;
+ private readonly IBoatDataMapper _boatMapper;
+ private readonly ILeaseDataMapper _leaseMapper;
+ private readonly IRegistrationDataMapper _registrationMapper;
+
+ private static class Queries {
+ public static IQuery Insert() {
+ return DatabaseInsert.Into( CustomerTable.TableName )
+ .AddValue( CustomerTable.FirstName, string.Empty )
+ .AddValue( CustomerTable.LastName, string.Empty )
+ .AddValue( CustomerTable.Phone, string.Empty )
+ .AddValue( CustomerTable.City, string.Empty ).Build( );
+ }
+
+ public static IQuery SelectCustomerBy( string username ) {
+ return DatabaseSelect.From( AuthorizationTable.TableName )
+ .AddColumn( AuthorizationTable.CustomerID )
+ .AddColumn( AuthorizationTable.UserName )
+ .Where( AuthorizationTable.UserName, "'" + username + "'" )
+ .Build( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/DockDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/DockDataMapper.cs
new file mode 100644
index 0000000..bf2ae13
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/DockDataMapper.cs
@@ -0,0 +1,54 @@
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class DockDataMapper : IDockDataMapper {
+ public DockDataMapper() : this( Resolve.DependencyFor< IDatabaseGateway >( ) ) {}
+
+ public DockDataMapper( IDatabaseGateway gateway ) {
+ _gateway = gateway;
+ }
+
+ public IDock FindBy( long dockId ) {
+ return Map.From( _gateway.LoadRowUsing( Queries.SelectDockBy( dockId ) ) );
+ }
+
+ private readonly IDatabaseGateway _gateway;
+
+ private static class Queries {
+ public static IQuery SelectDockBy( long dockId ) {
+ return DatabaseSelect
+ .From( DockTable.TableName )
+ .AddColumn( DockTable.DockID )
+ .AddColumn( DockTable.DockName )
+ .AddColumn( DockTable.LocationId )
+ .AddColumn( DockTable.WaterService )
+ .AddColumn( DockTable.ElectricalService )
+ .AddColumn( LocationTable.Name )
+ .InnerJoinOn( LocationTable.ID, DockTable.LocationId )
+ .Where( DockTable.DockID, dockId ).Build( );
+ }
+ }
+
+ private class Map {
+ public static IDock From( IDatabaseRow row ) {
+ return new Dock(
+ row.From< long >( DockTable.DockID ),
+ row.From< string >( DockTable.DockName ),
+ new Location( row.From< string >( LocationTable.Name ) ),
+ GetEnabledUtilities( row )
+ );
+ }
+
+ private static IUtility GetEnabledUtilities( IDatabaseRow row ) {
+ return Utilities.For(
+ row.From< bool >( DockTable.WaterService ) ? Utilities.Water : null,
+ row.From< bool >( DockTable.ElectricalService ) ? Utilities.Electrical : null
+ );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/IBoatDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/IBoatDataMapper.cs
new file mode 100644
index 0000000..bcdb7d1
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/IBoatDataMapper.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface IBoatDataMapper {
+ IEnumerable< IBoat > AllBoatsFor( long customerId );
+
+ void Insert( IEnumerable< IBoat > boats, long forCustomerId );
+
+ void Update( IEnumerable< IBoat > boats, long forCustomerId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/ICustomerDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/ICustomerDataMapper.cs
new file mode 100644
index 0000000..fc757e7
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/ICustomerDataMapper.cs
@@ -0,0 +1,11 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface ICustomerDataMapper : IDataMapper< ICustomer > {
+ void Insert( ICustomer customer );
+
+ void Update( ICustomer customer );
+
+ ICustomer FindBy( string username );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/IDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/IDataMapper.cs
new file mode 100644
index 0000000..249eeb7
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/IDataMapper.cs
@@ -0,0 +1,5 @@
+namespace Marina.DataAccess.DataMappers {
+ public interface IDataMapper< T > {
+ T FindBy( long id );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/IDockDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/IDockDataMapper.cs
new file mode 100644
index 0000000..5140eb1
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/IDockDataMapper.cs
@@ -0,0 +1,6 @@
+using Marina.DataAccess.DataMappers;
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface IDockDataMapper : IDataMapper< IDock > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/ILeaseDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/ILeaseDataMapper.cs
new file mode 100644
index 0000000..c7134d7
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/ILeaseDataMapper.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface ILeaseDataMapper {
+ IEnumerable< ISlipLease > AllLeasesFor( long customerId );
+
+ void Insert( IEnumerable< ISlipLease > leases, long forCustomerId );
+
+ void Update( IEnumerable< ISlipLease > leases, long forCustomerId );
+
+ bool IsLeased( long slipId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/IRegistrationDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/IRegistrationDataMapper.cs
new file mode 100644
index 0000000..a9f01dc
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/IRegistrationDataMapper.cs
@@ -0,0 +1,11 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface IRegistrationDataMapper {
+ IRegistration For( long customerId );
+
+ void Insert( IRegistration registration, long forCustomerId );
+
+ void Update( IRegistration registration, long forCustomerId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/ISlipDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/ISlipDataMapper.cs
new file mode 100644
index 0000000..99ff069
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/ISlipDataMapper.cs
@@ -0,0 +1,9 @@
+using Marina.DataAccess.DataMappers;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+
+namespace Marina.DataAccess.DataMappers {
+ public interface ISlipDataMapper : IDataMapper< ISlip > {
+ IRichEnumerable< ISlip > AllSlips();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/LeaseDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/LeaseDataMapper.cs
new file mode 100644
index 0000000..8214b05
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/LeaseDataMapper.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class LeaseDataMapper : ILeaseDataMapper {
+ public LeaseDataMapper()
+ : this( Resolve.DependencyFor< IDatabaseGateway >( ), Resolve.DependencyFor< ISlipDataMapper >( ) ) {}
+
+ public LeaseDataMapper( IDatabaseGateway gateway, ISlipDataMapper slipMapper ) {
+ _gateway = gateway;
+ _slipMapper = slipMapper;
+ }
+
+ public IEnumerable< ISlipLease > AllLeasesFor( long customerId ) {
+ foreach ( IDatabaseRow row in _gateway.FindAllRowsMatching( Queries.SelectLeasesFor( customerId ) ) ) {
+ yield return
+ new SlipLease(
+ _slipMapper.FindBy( row.From< long >( LeaseTable.SlipID ) ),
+ LeaseDurations.FindFor( row.From< DateTime >( LeaseTable.StartDate ), row.From< DateTime >( LeaseTable.EndDate ) ),
+ row.From< DateTime >( LeaseTable.StartDate ),
+ row.From< DateTime >( LeaseTable.EndDate )
+ );
+ }
+ }
+
+ public void Insert( IEnumerable< ISlipLease > leases, long forCustomerId ) {
+ using ( IDatabaseTransaction transaction = new DatabaseTransaction( ) ) {
+ IList< IQuery > queries = new List< IQuery >( );
+ foreach ( ISlipLease lease in leases ) {
+ queries.Add(
+ DatabaseInsert.Into( LeaseTable.TableName )
+ .AddValue( LeaseTable.StartDate, lease.StartDate( ) )
+ .AddValue( LeaseTable.EndDate, lease.ExpiryDate( ) )
+ .AddValue( LeaseTable.SlipID, lease.Slip( ).ID( ) )
+ .AddValue( LeaseTable.CustomerID, forCustomerId )
+ .AddValue( LeaseTable.LeaseTypeID, lease.Duration( ).ID( ) ).Build( )
+ );
+ }
+ _gateway.Execute( queries );
+ transaction.Commit( );
+ }
+ }
+
+ public void Update( IEnumerable< ISlipLease > leases, long forCustomerId ) {
+ using ( IDatabaseTransaction transaction = new DatabaseTransaction( ) ) {
+ _gateway.Execute( DatabaseDelete.Where( LeaseTable.CustomerID, forCustomerId ) );
+ Insert( leases, forCustomerId );
+ transaction.Commit( );
+ }
+ }
+
+ public bool IsLeased( long slipId ) {
+ IQuery query =
+ DatabaseSelect.From( LeaseTable.TableName ).AddColumn( LeaseTable.SlipID ).Where( LeaseTable.SlipID, slipId ).Build( );
+
+ return !_gateway.LoadRowUsing( query ).Equals( DatabaseRow.Blank );
+ }
+
+ private readonly IDatabaseGateway _gateway;
+ private readonly ISlipDataMapper _slipMapper;
+
+ private static class Queries {
+ public static IQuery SelectLeasesFor( long customerId ) {
+ return DatabaseSelect
+ .From( LeaseTable.TableName )
+ .AddColumn( LeaseTable.EndDate )
+ .AddColumn( LeaseTable.ID )
+ .AddColumn( LeaseTable.LeaseTypeID )
+ .AddColumn( LeaseTable.SlipID )
+ .AddColumn( LeaseTable.StartDate )
+ .Where( LeaseTable.CustomerID, customerId ).Build( );
+ }
+
+ public static IQuery SelectLeaseFor( long slipId ) {
+ return DatabaseSelect.From( LeaseTable.TableName )
+ .AddColumn( LeaseTable.StartDate )
+ .AddColumn( LeaseTable.EndDate )
+ .Where( LeaseTable.SlipID, slipId ).Build( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/RegistrationDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/RegistrationDataMapper.cs
new file mode 100644
index 0000000..5c2cd41
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/RegistrationDataMapper.cs
@@ -0,0 +1,88 @@
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class RegistrationDataMapper : IRegistrationDataMapper {
+ public RegistrationDataMapper() : this( Resolve.DependencyFor< IDatabaseGateway >( ) ) {}
+
+ public RegistrationDataMapper( IDatabaseGateway gateway ) {
+ _gateway = gateway;
+ }
+
+ public IRegistration For( long customerId ) {
+ return Mappers.From( _gateway.LoadRowUsing( Queries.SelectRegistrationFor( customerId ) ) );
+ }
+
+ public void Insert( IRegistration registration, long forCustomerId ) {
+ using ( IDatabaseTransaction unitOfWork = new DatabaseTransaction( ) ) {
+ _gateway.Execute( Queries.Insert( registration, forCustomerId ),
+ Queries.UpdateCustomer( registration, forCustomerId ) );
+ unitOfWork.Commit( );
+ }
+ }
+
+ public void Update( IRegistration registration, long forCustomerId ) {
+ using ( IDatabaseTransaction unitOfWork = new DatabaseTransaction( ) ) {
+ _gateway.Execute( Queries.UpdateCustomer( registration, forCustomerId ),
+ Queries.UpdateAuthorization( registration, forCustomerId ) );
+ unitOfWork.Commit( );
+ }
+ }
+
+ private readonly IDatabaseGateway _gateway;
+
+ private class Queries {
+ public static IQuery SelectRegistrationFor( long customerId ) {
+ return DatabaseSelect.From( CustomerTable.TableName )
+ .AddColumn( CustomerTable.FirstName )
+ .AddColumn( CustomerTable.LastName )
+ .AddColumn( CustomerTable.Phone )
+ .AddColumn( CustomerTable.City )
+ .AddColumn( AuthorizationTable.UserName )
+ .AddColumn( AuthorizationTable.Password )
+ .InnerJoinOn( AuthorizationTable.CustomerID, CustomerTable.CustomerID )
+ .Where( CustomerTable.CustomerID, customerId.ToString( ) ).Build( );
+ }
+
+ public static IQuery Insert( IRegistration registration, long forCustomerId ) {
+ return DatabaseInsert.Into( AuthorizationTable.TableName )
+ .AddValue( AuthorizationTable.CustomerID, forCustomerId.ToString( ) )
+ .AddValue( AuthorizationTable.UserName, registration.Username( ) )
+ .AddValue( AuthorizationTable.Password, registration.Password( ) )
+ .Build( );
+ }
+
+ public static IQuery UpdateCustomer( IRegistration registration, long forCustomerId ) {
+ return DatabaseUpdate.Where( CustomerTable.CustomerID, forCustomerId )
+ .Add( CustomerTable.FirstName, registration.FirstName( ) )
+ .Add( CustomerTable.LastName, registration.LastName( ) )
+ .Add( CustomerTable.Phone, registration.PhoneNumber( ) )
+ .Add( CustomerTable.City, registration.City( ) )
+ .Build( );
+ }
+
+ public static IQuery UpdateAuthorization( IRegistration registration, long forCustomerId ) {
+ return DatabaseUpdate.Where( AuthorizationTable.CustomerID, forCustomerId )
+ .Add( AuthorizationTable.UserName, registration.Username( ) )
+ .Add( AuthorizationTable.Password, registration.Password( ) )
+ .Build( );
+ }
+ }
+
+ private class Mappers {
+ public static IRegistration From( IDatabaseRow row ) {
+ return new CustomerRegistration(
+ row.From< string >( AuthorizationTable.UserName ),
+ row.From< string >( AuthorizationTable.Password ),
+ row.From< string >( CustomerTable.FirstName ),
+ row.From< string >( CustomerTable.LastName ),
+ row.From< string >( CustomerTable.Phone ),
+ row.From< string >( CustomerTable.City )
+ );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DataMappers/SlipDataMapper.cs b/slips/src/app/Marina/DataAccess/DataMappers/SlipDataMapper.cs
new file mode 100644
index 0000000..67f7d69
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DataMappers/SlipDataMapper.cs
@@ -0,0 +1,97 @@
+using System.Collections.Generic;
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.DataMappers {
+ public class SlipDataMapper : ISlipDataMapper {
+ public SlipDataMapper( IDatabaseGateway gateway ) {
+ _gateway = gateway;
+ }
+
+ public ISlip FindBy( long slipId ) {
+ return Map.From( _gateway.LoadRowUsing( Queries.SelectSlipBy( slipId ) ) );
+ }
+
+ public IRichEnumerable< ISlip > AllSlips() {
+ return new RichEnumerable< ISlip >( FetchAllSlips( ) );
+ }
+
+ private IEnumerable< ISlip > FetchAllSlips() {
+ return Map.From( _gateway.FindAllRowsMatching( Queries.SelectAllSlips( ) ) );
+ }
+
+ private readonly IDatabaseGateway _gateway;
+
+ private static class Queries {
+ public static IQuery SelectAllSlips() {
+ return SelectAllColumns( ).Build( );
+ }
+
+ public static IQuery SelectSlipBy( long slipId ) {
+ return SelectAllColumns( ).Where( SlipTable.ID, slipId ).Build( );
+ }
+
+ private static ISelectQueryBuilder SelectAllColumns() {
+ return DatabaseSelect
+ .From( SlipTable.TableName )
+ .AddColumn( SlipTable.ID )
+ .AddColumn( SlipTable.Width )
+ .AddColumn( SlipTable.Length )
+ .AddColumn( SlipTable.DockID )
+ .AddColumn( DockTable.DockName )
+ .AddColumn( DockTable.WaterService )
+ .AddColumn( DockTable.ElectricalService )
+ .AddColumn( LocationTable.Name )
+ .InnerJoinOn( DockTable.DockID, SlipTable.DockID )
+ .InnerJoinOn( LocationTable.ID, DockTable.LocationId );
+ }
+ }
+
+ private static class Map {
+ public static IEnumerable< ISlip > From( IEnumerable< IDatabaseRow > rows ) {
+ return new EnumerableMapper< IDatabaseRow, ISlip >( new DatabaseRowToSlipMapper( ) ).MapFrom( rows );
+ }
+
+ public static ISlip From( IDatabaseRow row ) {
+ return new DatabaseRowToSlipMapper( ).MapFrom( row );
+ }
+
+ private class DatabaseRowToSlipMapper : IMapper< IDatabaseRow, ISlip > {
+ public DatabaseRowToSlipMapper()
+ : this( Resolve.DependencyFor< ILeaseDataMapper >( ) ) {}
+
+ public DatabaseRowToSlipMapper( ILeaseDataMapper leaseDataMapper ) {
+ this.leaseDataMapper = leaseDataMapper;
+ }
+
+ public ISlip MapFrom( IDatabaseRow row ) {
+ return new Slip(
+ row.From< long >( SlipTable.ID ),
+ CreateDockFrom( row ),
+ row.From< int >( SlipTable.Width ),
+ row.From< int >( SlipTable.Length ),
+ leaseDataMapper.IsLeased( row.From< long >( SlipTable.ID ) )
+ );
+ }
+
+ private static Dock CreateDockFrom( IDatabaseRow row ) {
+ return new Dock(
+ row.From< long >( DockTable.DockID ),
+ row.From< string >( DockTable.DockName ),
+ new Location( row.From< string >( LocationTable.Name ) ),
+ Utilities.For(
+ row.From< bool >( DockTable.WaterService ) ? Utilities.Water : null,
+ row.From< bool >( DockTable.ElectricalService ) ? Utilities.Electrical : null
+ )
+ );
+ }
+
+ private readonly ILeaseDataMapper leaseDataMapper;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseColumn.cs b/slips/src/app/Marina/DataAccess/DatabaseColumn.cs
new file mode 100644
index 0000000..cc79200
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseColumn.cs
@@ -0,0 +1,23 @@
+namespace Marina.DataAccess {
+ public class DatabaseColumn {
+ internal DatabaseColumn( string tableName, string columnName ) {
+ _tableName = tableName;
+ _columnName = columnName;
+ }
+
+ public string TableName {
+ get { return _tableName; }
+ }
+
+ public string ColumnName {
+ get { return _columnName; }
+ }
+
+ public override string ToString() {
+ return string.Format( "[{0}].[{1}]", _tableName, _columnName );
+ }
+
+ private readonly string _tableName;
+ private readonly string _columnName;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseCommand.cs b/slips/src/app/Marina/DataAccess/DatabaseCommand.cs
new file mode 100644
index 0000000..f394ec0
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseCommand.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Data;
+
+namespace Marina.DataAccess {
+ public class DatabaseCommand : IDatabaseCommand {
+ public DatabaseCommand( IDbCommand command ) {
+ _command = command;
+ }
+
+ public DataTable ExecuteQuery() {
+ DataTable table = new DataTable( );
+ table.Load( _command.ExecuteReader( ) );
+ return table;
+ }
+
+ public long ExecuteScalarQuery() {
+ object scalar = _command.ExecuteScalar( );
+ return DBNull.Value != scalar ? Convert.ToInt32( scalar ) : -1;
+ }
+
+ private readonly IDbCommand _command;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseCommandParameter.cs b/slips/src/app/Marina/DataAccess/DatabaseCommandParameter.cs
new file mode 100644
index 0000000..84a0675
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseCommandParameter.cs
@@ -0,0 +1,19 @@
+namespace Marina.DataAccess {
+ public class DatabaseCommandParameter {
+ public DatabaseCommandParameter( string columnName, object value ) {
+ _columnName = columnName;
+ _value = value;
+ }
+
+ public string ColumnName {
+ get { return _columnName; }
+ }
+
+ public object Value {
+ get { return _value; }
+ }
+
+ private readonly string _columnName;
+ private readonly object _value;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseConfiguration.cs b/slips/src/app/Marina/DataAccess/DatabaseConfiguration.cs
new file mode 100644
index 0000000..f70a437
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseConfiguration.cs
@@ -0,0 +1,22 @@
+using System.Configuration;
+
+namespace Marina.DataAccess {
+ public class DatabaseConfiguration : IDatabaseConfiguration {
+ private readonly ConnectionStringSettings _connectionSettings;
+
+ public DatabaseConfiguration()
+ : this( ConfigurationManager.ConnectionStrings[ ConfigurationManager.AppSettings[ "ActiveConnection" ] ] ) {}
+
+ public DatabaseConfiguration( ConnectionStringSettings connectionSettings ) {
+ _connectionSettings = connectionSettings;
+ }
+
+ public string ConnectionString() {
+ return _connectionSettings.ConnectionString;
+ }
+
+ public string ProviderName() {
+ return _connectionSettings.ProviderName;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseConnection.cs b/slips/src/app/Marina/DataAccess/DatabaseConnection.cs
new file mode 100644
index 0000000..b08399f
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseConnection.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Data;
+using Marina.DataAccess.Builders;
+
+namespace Marina.DataAccess {
+ public class DatabaseConnection : IDatabaseConnection {
+ private readonly IDbConnection _connection;
+
+ public DatabaseConnection() : this( new DatabaseConfiguration( ), new DatabaseProviderFactory( ) ) {}
+
+ public DatabaseConnection( IDatabaseConfiguration configuration, IDatabaseProviderFactory providerFactory ) {
+ _connection = providerFactory.CreateConnectionFor( configuration.ProviderName( ) );
+ _connection.ConnectionString = configuration.ConnectionString( );
+ _connection.Open( );
+ }
+
+ public IDatabaseCommand CreateCommandFor( string sqlQuery ) {
+ return CreateCommandFor( new SqlQuery( sqlQuery ) );
+ }
+
+ public IDatabaseCommand CreateCommandFor( IQuery query ) {
+ IDbCommand command = _connection.CreateCommand( );
+ query.Prepare( command );
+ return new DatabaseCommand( command );
+ }
+
+ public void Dispose() {
+ Dispose( true );
+ GC.SuppressFinalize( this );
+ }
+
+ protected virtual void Dispose( bool disposing ) {
+ if ( disposing ) {
+ _connection.Close( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseConnectionFactory.cs b/slips/src/app/Marina/DataAccess/DatabaseConnectionFactory.cs
new file mode 100644
index 0000000..2747148
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseConnectionFactory.cs
@@ -0,0 +1,7 @@
+namespace Marina.DataAccess {
+ public class DatabaseConnectionFactory : IDatabaseConnectionFactory {
+ public IDatabaseConnection Create() {
+ return new DatabaseConnection( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseGateway.cs b/slips/src/app/Marina/DataAccess/DatabaseGateway.cs
new file mode 100644
index 0000000..92892f1
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseGateway.cs
@@ -0,0 +1,60 @@
+using System.Collections.Generic;
+using System.Data;
+using Marina.DataAccess.Builders;
+using Marina.Infrastructure;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess {
+ public class DatabaseGateway : IDatabaseGateway {
+ private readonly IDatabaseConnectionFactory _connectionFactory;
+
+ public DatabaseGateway() : this( Resolve.DependencyFor< IDatabaseConnectionFactory >( ) ) {}
+
+ public DatabaseGateway( IDatabaseConnectionFactory connectionFactory ) {
+ _connectionFactory = connectionFactory;
+ }
+
+ public DataTable LoadTableUsing( string sqlQuery ) {
+ using ( IDatabaseConnection connection = _connectionFactory.Create( ) ) {
+ IDatabaseCommand command = connection.CreateCommandFor( sqlQuery );
+ return ( null != command ) ? command.ExecuteQuery( ) : null;
+ }
+ }
+
+ public IEnumerable< IDatabaseRow > FindAllRowsMatching( IQuery query ) {
+ using ( IDatabaseConnection connection = _connectionFactory.Create( ) ) {
+ DataTable table = connection.CreateCommandFor( query ).ExecuteQuery( );
+ if ( null != table ) {
+ foreach ( DataRow row in table.Rows ) {
+ yield return new DatabaseRow( row );
+ }
+ }
+ }
+ }
+
+ public void Execute( params IQuery[] queries ) {
+ Execute( ListFactory.From( queries ) );
+ }
+
+ public void Execute( IEnumerable< IQuery > queries ) {
+ using ( IDatabaseConnection connection = _connectionFactory.Create( ) ) {
+ foreach ( IQuery query in queries ) {
+ connection.CreateCommandFor( query ).ExecuteQuery( );
+ }
+ }
+ }
+
+ public long ExecuteScalar( IQuery query ) {
+ using ( IDatabaseConnection connection = _connectionFactory.Create( ) ) {
+ return connection.CreateCommandFor( query ).ExecuteScalarQuery( );
+ }
+ }
+
+ public IDatabaseRow LoadRowUsing( IQuery query ) {
+ using ( IDatabaseConnection connection = _connectionFactory.Create( ) ) {
+ DataTable table = connection.CreateCommandFor( query ).ExecuteQuery( );
+ return table.Rows.Count > 0 ? new DatabaseRow( table.Rows[ 0 ] ) : DatabaseRow.Blank;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseProviderFactory.cs b/slips/src/app/Marina/DataAccess/DatabaseProviderFactory.cs
new file mode 100644
index 0000000..f93d964
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseProviderFactory.cs
@@ -0,0 +1,10 @@
+using System.Data;
+using System.Data.Common;
+
+namespace Marina.DataAccess {
+ public class DatabaseProviderFactory : IDatabaseProviderFactory {
+ public IDbConnection CreateConnectionFor( string providerName ) {
+ return DbProviderFactories.GetFactory( providerName ).CreateConnection( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseRow.cs b/slips/src/app/Marina/DataAccess/DatabaseRow.cs
new file mode 100644
index 0000000..53d0b45
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseRow.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Data;
+
+namespace Marina.DataAccess {
+ public class DatabaseRow : IDatabaseRow {
+ public DatabaseRow( DataRow row ) {
+ _row = row;
+ }
+
+ public static readonly IDatabaseRow Blank = new BlankDatabaseRow( );
+
+ public T From< T >( DatabaseColumn column ) {
+ return ( T )Convert.ChangeType( _row[ column.ColumnName ], typeof( T ) );
+ }
+
+ private readonly DataRow _row;
+
+ public class BlankDatabaseRow : IDatabaseRow {
+ public T From< T >( DatabaseColumn column ) {
+ return default( T );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/DatabaseTransaction.cs b/slips/src/app/Marina/DataAccess/DatabaseTransaction.cs
new file mode 100644
index 0000000..78d87cf
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/DatabaseTransaction.cs
@@ -0,0 +1,19 @@
+using System.Transactions;
+
+namespace Marina.DataAccess {
+ internal class DatabaseTransaction : IDatabaseTransaction {
+ public DatabaseTransaction() {
+ _scope = new TransactionScope( );
+ }
+
+ public void Commit() {
+ _scope.Complete( );
+ }
+
+ public void Dispose() {
+ _scope.Dispose( );
+ }
+
+ private readonly TransactionScope _scope;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Exceptions/ObjectAlreadyAddedToIdentityMapException.cs b/slips/src/app/Marina/DataAccess/Exceptions/ObjectAlreadyAddedToIdentityMapException.cs
new file mode 100644
index 0000000..a2cf8c9
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Exceptions/ObjectAlreadyAddedToIdentityMapException.cs
@@ -0,0 +1,9 @@
+using System;
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess.Exceptions {
+ public class ObjectAlreadyAddedToIdentityMapException : Exception {
+ public ObjectAlreadyAddedToIdentityMapException( IDomainObject domainObject )
+ : base( "With ID Of: " + domainObject.ID( ) ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseCommand.cs b/slips/src/app/Marina/DataAccess/IDatabaseCommand.cs
new file mode 100644
index 0000000..ef6fbd4
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseCommand.cs
@@ -0,0 +1,9 @@
+using System.Data;
+
+namespace Marina.DataAccess {
+ public interface IDatabaseCommand {
+ DataTable ExecuteQuery();
+
+ long ExecuteScalarQuery();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseConfiguration.cs b/slips/src/app/Marina/DataAccess/IDatabaseConfiguration.cs
new file mode 100644
index 0000000..2fb0637
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseConfiguration.cs
@@ -0,0 +1,7 @@
+namespace Marina.DataAccess {
+ public interface IDatabaseConfiguration {
+ string ConnectionString();
+
+ string ProviderName();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseConnection.cs b/slips/src/app/Marina/DataAccess/IDatabaseConnection.cs
new file mode 100644
index 0000000..2316741
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseConnection.cs
@@ -0,0 +1,10 @@
+using System;
+using Marina.DataAccess.Builders;
+
+namespace Marina.DataAccess {
+ public interface IDatabaseConnection : IDisposable {
+ IDatabaseCommand CreateCommandFor( string sqlQuery );
+
+ IDatabaseCommand CreateCommandFor( IQuery query );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseConnectionFactory.cs b/slips/src/app/Marina/DataAccess/IDatabaseConnectionFactory.cs
new file mode 100644
index 0000000..4672c9a
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseConnectionFactory.cs
@@ -0,0 +1,5 @@
+namespace Marina.DataAccess {
+ public interface IDatabaseConnectionFactory {
+ IDatabaseConnection Create();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseGateway.cs b/slips/src/app/Marina/DataAccess/IDatabaseGateway.cs
new file mode 100644
index 0000000..f52ea21
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseGateway.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using System.Data;
+using Marina.DataAccess.Builders;
+
+namespace Marina.DataAccess {
+ public interface IDatabaseGateway {
+ DataTable LoadTableUsing( string sqlQuery );
+
+ IEnumerable< IDatabaseRow > FindAllRowsMatching( IQuery query );
+
+ void Execute( params IQuery[] queries );
+
+ void Execute( IEnumerable< IQuery > queries );
+
+ long ExecuteScalar( IQuery query );
+
+ IDatabaseRow LoadRowUsing( IQuery query );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseProviderFactory.cs b/slips/src/app/Marina/DataAccess/IDatabaseProviderFactory.cs
new file mode 100644
index 0000000..2fbb6b8
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseProviderFactory.cs
@@ -0,0 +1,7 @@
+using System.Data;
+
+namespace Marina.DataAccess {
+ public interface IDatabaseProviderFactory {
+ IDbConnection CreateConnectionFor( string providerName );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseRow.cs b/slips/src/app/Marina/DataAccess/IDatabaseRow.cs
new file mode 100644
index 0000000..baa07ee
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseRow.cs
@@ -0,0 +1,5 @@
+namespace Marina.DataAccess {
+ public interface IDatabaseRow {
+ T From< T >( DatabaseColumn column );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IDatabaseTransaction.cs b/slips/src/app/Marina/DataAccess/IDatabaseTransaction.cs
new file mode 100644
index 0000000..22d83a6
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IDatabaseTransaction.cs
@@ -0,0 +1,7 @@
+using System;
+
+namespace Marina.DataAccess {
+ internal interface IDatabaseTransaction : IDisposable {
+ void Commit();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IIdentityMap.cs b/slips/src/app/Marina/DataAccess/IIdentityMap.cs
new file mode 100644
index 0000000..28ad56e
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IIdentityMap.cs
@@ -0,0 +1,9 @@
+namespace Marina.DataAccess {
+ public interface IIdentityMap< T > {
+ void Add( T domainObject );
+
+ bool ContainsObjectWithIdOf( long idOfObjectToFind );
+
+ T FindObjectWithIdOf( long idOfObjectToFind );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/IdentityMap.cs b/slips/src/app/Marina/DataAccess/IdentityMap.cs
new file mode 100644
index 0000000..c251379
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/IdentityMap.cs
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+using Marina.DataAccess.Exceptions;
+using Marina.Domain.Interfaces;
+
+namespace Marina.DataAccess {
+ public class IdentityMap< T > : IIdentityMap< T > where T : IDomainObject {
+ public IdentityMap() {
+ _items = new List< T >( );
+ }
+
+ public void Add( T domainObject ) {
+ EnsureObjectHasNotAlreadyBeenAdded( domainObject );
+ _items.Add( domainObject );
+ }
+
+ public bool ContainsObjectWithIdOf( long idOfObjectToFind ) {
+ foreach ( T item in _items ) {
+ if ( item.ID( ).Equals( idOfObjectToFind ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public T FindObjectWithIdOf( long idOfObjectToFind ) {
+ foreach ( T item in _items ) {
+ if ( item.ID( ).Equals( idOfObjectToFind ) ) {
+ return item;
+ }
+ }
+ return default( T );
+ }
+
+ private void EnsureObjectHasNotAlreadyBeenAdded( T domainObject ) {
+ if ( ContainsObjectWithIdOf( domainObject.ID( ) ) ) {
+ throw new ObjectAlreadyAddedToIdentityMapException( domainObject );
+ }
+ }
+
+ private readonly IList< T > _items;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Repositories/CustomerRepository.cs b/slips/src/app/Marina/DataAccess/Repositories/CustomerRepository.cs
new file mode 100644
index 0000000..ade3e83
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Repositories/CustomerRepository.cs
@@ -0,0 +1,51 @@
+using Marina.DataAccess.DataMappers;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.Repositories {
+ public class CustomerRepository : ICustomerRepository {
+ public CustomerRepository()
+ : this( new IdentityMap< ICustomer >( ), Resolve.DependencyFor< ICustomerDataMapper >( ) ) {}
+
+ public CustomerRepository( IIdentityMap< ICustomer > identityMap, ICustomerDataMapper mapper ) {
+ _identityMap = identityMap;
+ _mapper = mapper;
+ }
+
+ public ICustomer FindBy( long customerId ) {
+ if ( _identityMap.ContainsObjectWithIdOf( customerId ) ) {
+ return _identityMap.FindObjectWithIdOf( customerId );
+ }
+ return FindCustomerBy( customerId );
+ }
+
+ public ICustomer FindBy( string username ) {
+ return _mapper.FindBy( username );
+ }
+
+ public void Save( ICustomer customer ) {
+ if ( _identityMap.ContainsObjectWithIdOf( customer.ID( ) ) ) {
+ _mapper.Update( customer );
+ }
+ else {
+ _mapper.Insert( customer );
+ _identityMap.Add( customer );
+ }
+ }
+
+ public ICustomer NewCustomer() {
+ return new Customer( );
+ }
+
+ private ICustomer FindCustomerBy( long customerId ) {
+ ICustomer customer = _mapper.FindBy( customerId );
+ _identityMap.Add( customer );
+ return customer;
+ }
+
+ private readonly IIdentityMap< ICustomer > _identityMap;
+ private readonly ICustomerDataMapper _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Repositories/DockRepository.cs b/slips/src/app/Marina/DataAccess/Repositories/DockRepository.cs
new file mode 100644
index 0000000..747ebc2
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Repositories/DockRepository.cs
@@ -0,0 +1,20 @@
+using Marina.DataAccess.DataMappers;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.Repositories {
+ public class DockRepository : IDockRepository {
+ public DockRepository() : this( Resolve.DependencyFor< IDockDataMapper >( ) ) {}
+
+ public DockRepository( IDockDataMapper mapper ) {
+ this.mapper = mapper;
+ }
+
+ public IDock FindBy( long dockId ) {
+ return mapper.FindBy( dockId );
+ }
+
+ private readonly IDockDataMapper mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Repositories/SlipsRepository.cs b/slips/src/app/Marina/DataAccess/Repositories/SlipsRepository.cs
new file mode 100644
index 0000000..c6f0b3a
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Repositories/SlipsRepository.cs
@@ -0,0 +1,58 @@
+using System.Collections.Generic;
+using Marina.DataAccess.DataMappers;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure;
+using Marina.Infrastructure.Container;
+
+namespace Marina.DataAccess.Repositories {
+ public class SlipsRepository : ISlipsRepository {
+ public SlipsRepository() : this( Resolve.DependencyFor< ISlipDataMapper >( ) ) {}
+
+ public SlipsRepository( ISlipDataMapper mapper ) {
+ this.mapper = mapper;
+ }
+
+ public IEnumerable< ISlip > AllAvailableSlips() {
+ return mapper.AllSlips( ).Where( Is.NotLeased( ) );
+ }
+
+ public IEnumerable< ISlip > AllAvailableSlipsFor( IDock dock ) {
+ return mapper.AllSlips( ).Where( Is.NotLeased( ).And( Is.OnDock( dock ) ) );
+ }
+
+ public ISlip FindBy( long slipId ) {
+ return mapper.FindBy( slipId );
+ }
+
+ private readonly ISlipDataMapper mapper;
+
+ private static class Is {
+ public static ISpecificationBuilder< ISlip > NotLeased() {
+ return new SpecificationBuilder< ISlip >( new IsNotLeased( ) );
+ }
+
+ public static ISpecificationBuilder< ISlip > OnDock( IDock dock ) {
+ return new SpecificationBuilder< ISlip >( new OnDockSpecification( dock ) );
+ }
+
+ private class IsNotLeased : ISpecification< ISlip > {
+ public bool IsSatisfiedBy( ISlip slip ) {
+ return !slip.IsLeased( );
+ }
+ }
+
+ private class OnDockSpecification : ISpecification< ISlip > {
+ private readonly IDock _dock;
+
+ public OnDockSpecification( IDock dock ) {
+ _dock = dock;
+ }
+
+ public bool IsSatisfiedBy( ISlip item ) {
+ return _dock.ID( ).Equals( item.Dock( ).ID( ) );
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/AuthorizationTable.cs b/slips/src/app/Marina/DataAccess/Schemas/AuthorizationTable.cs
new file mode 100644
index 0000000..73be973
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/AuthorizationTable.cs
@@ -0,0 +1,9 @@
+namespace Marina.DataAccess.Schemas {
+ public static class AuthorizationTable {
+ public const string TableName = "Authorize";
+ public static readonly DatabaseColumn AuthID = new DatabaseColumn( TableName, "AuthID" );
+ public static readonly DatabaseColumn UserName = new DatabaseColumn( TableName, "UserName" );
+ public static readonly DatabaseColumn Password = new DatabaseColumn( TableName, "Password" );
+ public static readonly DatabaseColumn CustomerID = new DatabaseColumn( TableName, "CustomerID" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/BoatTable.cs b/slips/src/app/Marina/DataAccess/Schemas/BoatTable.cs
new file mode 100644
index 0000000..3d4fe6b
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/BoatTable.cs
@@ -0,0 +1,11 @@
+namespace Marina.DataAccess.Schemas {
+ public static class BoatTable {
+ public const string TableName = "Boat";
+ public static readonly DatabaseColumn BoatID = new DatabaseColumn( TableName, "BoatID" );
+ public static readonly DatabaseColumn RegistrationNumber = new DatabaseColumn( TableName, "RegistrationNumber" );
+ public static readonly DatabaseColumn Manufacturer = new DatabaseColumn( TableName, "Manufacturer" );
+ public static readonly DatabaseColumn ModelYear = new DatabaseColumn( TableName, "ModelYear" );
+ public static readonly DatabaseColumn Length = new DatabaseColumn( TableName, "Length" );
+ public static readonly DatabaseColumn CustomerID = new DatabaseColumn( TableName, "CustomerID" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/CustomerTable.cs b/slips/src/app/Marina/DataAccess/Schemas/CustomerTable.cs
new file mode 100644
index 0000000..b719a75
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/CustomerTable.cs
@@ -0,0 +1,10 @@
+namespace Marina.DataAccess.Schemas {
+ public static class CustomerTable {
+ public const string TableName = "Customer";
+ public static readonly DatabaseColumn CustomerID = new DatabaseColumn( TableName, "CustomerID" );
+ public static readonly DatabaseColumn FirstName = new DatabaseColumn( TableName, "FirstName" );
+ public static readonly DatabaseColumn LastName = new DatabaseColumn( TableName, "LastName" );
+ public static readonly DatabaseColumn Phone = new DatabaseColumn( TableName, "Phone" );
+ public static readonly DatabaseColumn City = new DatabaseColumn( TableName, "City" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/DockTable.cs b/slips/src/app/Marina/DataAccess/Schemas/DockTable.cs
new file mode 100644
index 0000000..1350e82
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/DockTable.cs
@@ -0,0 +1,10 @@
+namespace Marina.DataAccess.Schemas {
+ public static class DockTable {
+ public const string TableName = "Dock";
+ public static readonly DatabaseColumn DockID = new DatabaseColumn( TableName, "DockID" );
+ public static readonly DatabaseColumn DockName = new DatabaseColumn( TableName, "DockName" );
+ public static readonly DatabaseColumn LocationId = new DatabaseColumn( TableName, "LocationId" );
+ public static readonly DatabaseColumn WaterService = new DatabaseColumn( TableName, "WaterService" );
+ public static readonly DatabaseColumn ElectricalService = new DatabaseColumn( TableName, "ElectricalService" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/LeaseTable.cs b/slips/src/app/Marina/DataAccess/Schemas/LeaseTable.cs
new file mode 100644
index 0000000..2581372
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/LeaseTable.cs
@@ -0,0 +1,11 @@
+namespace Marina.DataAccess.Schemas {
+ public static class LeaseTable {
+ public const string TableName = "Lease";
+ public static readonly DatabaseColumn ID = new DatabaseColumn( TableName, "LeaseID" );
+ public static readonly DatabaseColumn StartDate = new DatabaseColumn( TableName, "StartDate" );
+ public static readonly DatabaseColumn EndDate = new DatabaseColumn( TableName, "EndDate" );
+ public static readonly DatabaseColumn SlipID = new DatabaseColumn( TableName, "SlipID" );
+ public static readonly DatabaseColumn CustomerID = new DatabaseColumn( TableName, "CustomerID" );
+ public static readonly DatabaseColumn LeaseTypeID = new DatabaseColumn( TableName, "LeaseTypeID" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/LeaseType.cs b/slips/src/app/Marina/DataAccess/Schemas/LeaseType.cs
new file mode 100644
index 0000000..c36cae9
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/LeaseType.cs
@@ -0,0 +1,8 @@
+namespace Marina.DataAccess.Schemas {
+ public static class LeaseType {
+ public const string TableName = "LeaseType";
+ public static readonly DatabaseColumn LeaseTypeID = new DatabaseColumn( TableName, "LeaseTypeID" );
+ public static readonly DatabaseColumn LeaseTypeName = new DatabaseColumn( TableName, "LeaseTypeName" );
+ public static readonly DatabaseColumn StandardRateAmount = new DatabaseColumn( TableName, "StandardRateAmount" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/LocationTable.cs b/slips/src/app/Marina/DataAccess/Schemas/LocationTable.cs
new file mode 100644
index 0000000..eadee0b
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/LocationTable.cs
@@ -0,0 +1,7 @@
+namespace Marina.DataAccess.Schemas {
+ public class LocationTable {
+ public const string TableName = "Location";
+ public static readonly DatabaseColumn ID = new DatabaseColumn( TableName, "LocationId" );
+ public static readonly DatabaseColumn Name = new DatabaseColumn( TableName, "LocationName" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/DataAccess/Schemas/SlipTable.cs b/slips/src/app/Marina/DataAccess/Schemas/SlipTable.cs
new file mode 100644
index 0000000..fd69733
--- /dev/null
+++ b/slips/src/app/Marina/DataAccess/Schemas/SlipTable.cs
@@ -0,0 +1,9 @@
+namespace Marina.DataAccess.Schemas {
+ public static class SlipTable {
+ public const string TableName = "Slip";
+ public static readonly DatabaseColumn ID = new DatabaseColumn( TableName, "SlipID" );
+ public static readonly DatabaseColumn Width = new DatabaseColumn( TableName, "SlipWidth" );
+ public static readonly DatabaseColumn Length = new DatabaseColumn( TableName, "SlipLength" );
+ public static readonly DatabaseColumn DockID = new DatabaseColumn( TableName, "DockID" );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Boat.cs b/slips/src/app/Marina/Domain/Boat.cs
new file mode 100644
index 0000000..3f07174
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Boat.cs
@@ -0,0 +1,72 @@
+using System;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Boat : DomainObject, IBoat, IEquatable< Boat > {
+ public Boat( string registrationNumber, string manufacturer, DateTime yearOfModel, long length )
+ : this( -1, registrationNumber, manufacturer, yearOfModel, length ) {}
+
+ public Boat( long id, string registrationNumber, string manufacturer, DateTime yearOfModel, long length )
+ : base( id ) {
+ _registrationNumber = registrationNumber;
+ _manufacturer = manufacturer;
+ _yearOfModel = yearOfModel;
+ _length = length;
+ }
+
+ public string RegistrationNumber() {
+ return _registrationNumber;
+ }
+
+ public string Manufacturer() {
+ return _manufacturer;
+ }
+
+ public DateTime YearOfModel() {
+ return _yearOfModel;
+ }
+
+ public long LengthInFeet() {
+ return _length;
+ }
+
+ public bool Equals( Boat boat ) {
+ if ( boat == null ) {
+ return false;
+ }
+ if ( !Equals( _registrationNumber, boat._registrationNumber ) ) {
+ return false;
+ }
+ if ( !Equals( _manufacturer, boat._manufacturer ) ) {
+ return false;
+ }
+ if ( !Equals( _yearOfModel, boat._yearOfModel ) ) {
+ return false;
+ }
+ if ( _length != boat._length ) {
+ return false;
+ }
+ return true;
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as Boat );
+ }
+
+ public override int GetHashCode() {
+ int result = _registrationNumber != null ? _registrationNumber.GetHashCode( ) : 0;
+ result = 29*result + ( _manufacturer != null ? _manufacturer.GetHashCode( ) : 0 );
+ result = 29*result + _yearOfModel.GetHashCode( );
+ result = 29*result + ( int )_length;
+ return result;
+ }
+
+ private readonly string _registrationNumber;
+ private readonly string _manufacturer;
+ private readonly DateTime _yearOfModel;
+ private readonly long _length;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/BrokenRule.cs b/slips/src/app/Marina/Domain/BrokenRule.cs
new file mode 100644
index 0000000..1d7d56b
--- /dev/null
+++ b/slips/src/app/Marina/Domain/BrokenRule.cs
@@ -0,0 +1,15 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ internal class BrokenRule : IBrokenRule {
+ public BrokenRule( string message ) {
+ _message = message;
+ }
+
+ public string Message() {
+ return _message;
+ }
+
+ private readonly string _message;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Customer.cs b/slips/src/app/Marina/Domain/Customer.cs
new file mode 100644
index 0000000..8b9911c
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Customer.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using Marina.Domain.Exceptions;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+
+namespace Marina.Domain {
+ public class Customer : DomainObject, ICustomer {
+ public Customer()
+ : this( -1, new RichList< IBoat >( ), new RichList< ISlipLease >( ), CustomerRegistration.BlankRegistration( ) ) {}
+
+ public Customer( long id, IEnumerable< IBoat > registeredBoats, IEnumerable< ISlipLease > leases,
+ IRegistration registration ) : base( id ) {
+ _registeredBoats = ListFactory.From( registeredBoats );
+ _leases = ListFactory.From( leases );
+ _registration = registration;
+ }
+
+ public IRegistration Registration() {
+ return _registration;
+ }
+
+ public void RegisterAccount( string username, string password, string firstName, string lastName, string phoneNumber,
+ string city ) {
+ _registration = new CustomerRegistration( username, password, firstName, lastName, phoneNumber, city );
+ }
+
+ public void UpdateRegistrationTo( string username, string password, string firstName, string lastName,
+ string phoneNumber,
+ string city ) {
+ UpdateRegistrationTo( new CustomerRegistration( username, password, firstName, lastName, phoneNumber, city ) );
+ }
+
+ public void UpdateRegistrationTo( IRegistration registration ) {
+ _registration = registration ?? _registration;
+ }
+
+ public void RegisterBoat( string registrationNumber, string manufacturer, DateTime yearOfModel, long length ) {
+ RegisterBoat( new Boat( registrationNumber, manufacturer, yearOfModel, length ) );
+ }
+
+ public void RegisterBoat( IBoat unregisteredBoat ) {
+ if ( !IsBoatRegistered( unregisteredBoat ) ) {
+ _registeredBoats.Add( unregisteredBoat );
+ }
+ }
+
+ public IEnumerable< IBoat > RegisteredBoats() {
+ return _registeredBoats.All( );
+ }
+
+ public void Lease( ISlip slip, ILeaseDuration duration ) {
+ EnsureSlipIsNotLeased( slip );
+ _leases.Add( slip.LeaseTo( this, duration ) );
+ }
+
+ public IEnumerable< ISlipLease > Leases() {
+ return _leases.All( );
+ }
+
+ private void EnsureSlipIsNotLeased( ISlip slip ) {
+ if ( slip.IsLeased( ) ) {
+ throw new SlipIsAlreadyLeasedException( );
+ }
+ }
+
+ private bool IsBoatRegistered( IBoat boat ) {
+ return _registeredBoats.Contains( boat );
+ }
+
+ private readonly IRichList< IBoat > _registeredBoats;
+ private readonly IRichList< ISlipLease > _leases;
+ private IRegistration _registration;
+ public static readonly ICustomer Unknown = new UnknownCustomer( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/CustomerRegistration.cs b/slips/src/app/Marina/Domain/CustomerRegistration.cs
new file mode 100644
index 0000000..9e7b13b
--- /dev/null
+++ b/slips/src/app/Marina/Domain/CustomerRegistration.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class CustomerRegistration : IRegistration, IEquatable< CustomerRegistration > {
+ private CustomerRegistration()
+ : this( string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty ) {}
+
+ public CustomerRegistration( string userName, string password, string firstName, string lastName, string phoneNumber,
+ string city ) {
+ _userName = userName;
+ _password = password;
+ _firstName = firstName;
+ _lastName = lastName;
+ _phoneNumber = phoneNumber;
+ _city = city;
+ }
+
+ public string Username() {
+ return _userName;
+ }
+
+ public string Password() {
+ return _password;
+ }
+
+ public string FirstName() {
+ return _firstName;
+ }
+
+ public string LastName() {
+ return _lastName;
+ }
+
+ public string PhoneNumber() {
+ return _phoneNumber;
+ }
+
+ public string City() {
+ return _city;
+ }
+
+ public bool IsValid() {
+ foreach ( IBusinessRule businessRule in AllRules( ) ) {
+ if ( !businessRule.IsBroken( ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public IEnumerable< IBrokenRule > BrokenRules() {
+ foreach ( IBusinessRule businessRule in AllRules( ) ) {
+ if ( !businessRule.IsBroken( ) ) {
+ yield return businessRule.Description( );
+ }
+ }
+ }
+
+ private IEnumerable< IBusinessRule > AllRules() {
+ yield return new PasswordRule( _password );
+ yield return new UserNameRule( _userName );
+ }
+
+ public bool Equals( CustomerRegistration customerRegistration ) {
+ if ( customerRegistration == null ) {
+ return false;
+ }
+ if ( !Equals( _userName, customerRegistration._userName ) ) {
+ return false;
+ }
+ if ( !Equals( _password, customerRegistration._password ) ) {
+ return false;
+ }
+ if ( !Equals( _firstName, customerRegistration._firstName ) ) {
+ return false;
+ }
+ if ( !Equals( _lastName, customerRegistration._lastName ) ) {
+ return false;
+ }
+ if ( !Equals( _phoneNumber, customerRegistration._phoneNumber ) ) {
+ return false;
+ }
+ if ( !Equals( _city, customerRegistration._city ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as CustomerRegistration );
+ }
+
+ public override int GetHashCode() {
+ int result = _userName != null ? _userName.GetHashCode( ) : 0;
+ result = 29*result + ( _password != null ? _password.GetHashCode( ) : 0 );
+ result = 29*result + ( _firstName != null ? _firstName.GetHashCode( ) : 0 );
+ result = 29*result + ( _lastName != null ? _lastName.GetHashCode( ) : 0 );
+ result = 29*result + ( _phoneNumber != null ? _phoneNumber.GetHashCode( ) : 0 );
+ result = 29*result + ( _city != null ? _city.GetHashCode( ) : 0 );
+ return result;
+ }
+
+ private readonly string _userName;
+ private readonly string _password;
+ private readonly string _firstName;
+ private readonly string _lastName;
+ private readonly string _phoneNumber;
+ private readonly string _city;
+
+ private class PasswordRule : IBusinessRule {
+ private readonly string _password;
+
+ public PasswordRule( string password ) {
+ _password = password;
+ }
+
+ public bool IsBroken() {
+ return !string.IsNullOrEmpty( _password );
+ }
+
+ public IBrokenRule Description() {
+ return new BrokenRule( "Password cannot be blank" );
+ }
+ }
+
+ private class UserNameRule : IBusinessRule {
+ private readonly string _userName;
+
+ public UserNameRule( string userName ) {
+ _userName = userName;
+ }
+
+ public bool IsBroken() {
+ return !string.IsNullOrEmpty( _userName );
+ }
+
+ public IBrokenRule Description() {
+ return new BrokenRule( "Username cannot be blank" );
+ }
+ }
+
+ public static IRegistration BlankRegistration() {
+ return new CustomerRegistration( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/DateRange.cs b/slips/src/app/Marina/Domain/DateRange.cs
new file mode 100644
index 0000000..7460489
--- /dev/null
+++ b/slips/src/app/Marina/Domain/DateRange.cs
@@ -0,0 +1,22 @@
+using System;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ internal class DateRange : IDateRange {
+ public DateRange( DateTime startDate, DateTime endDate ) {
+ _startDate = startDate;
+ _endDate = endDate;
+ }
+
+ public DateTime Start() {
+ return _startDate;
+ }
+
+ public DateTime End() {
+ return _endDate;
+ }
+
+ private readonly DateTime _startDate;
+ private readonly DateTime _endDate;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Dock.cs b/slips/src/app/Marina/Domain/Dock.cs
new file mode 100644
index 0000000..6900cec
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Dock.cs
@@ -0,0 +1,33 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Dock : IDock {
+ private readonly long _id;
+ private readonly string _name;
+ private readonly ILocation _location;
+ private readonly IUtility _utility;
+
+ public Dock( long id, string name, ILocation location, IUtility utility ) {
+ _id = id;
+ _name = name;
+ _location = location;
+ _utility = utility;
+ }
+
+ public long ID() {
+ return _id;
+ }
+
+ public string Name() {
+ return _name;
+ }
+
+ public ILocation Location() {
+ return _location;
+ }
+
+ public bool IsUtilityEnabled( IUtility utility ) {
+ return _utility.IsEnabled( utility );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/DomainObject.cs b/slips/src/app/Marina/Domain/DomainObject.cs
new file mode 100644
index 0000000..2fefda9
--- /dev/null
+++ b/slips/src/app/Marina/Domain/DomainObject.cs
@@ -0,0 +1,19 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class DomainObject : IDomainObject {
+ private long _id;
+
+ public DomainObject( long id ) {
+ _id = id;
+ }
+
+ public long ID() {
+ return _id;
+ }
+
+ void IDomainObject.ChangeIdTo( long id ) {
+ _id = id;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Exceptions/SlipIsAlreadyLeasedException.cs b/slips/src/app/Marina/Domain/Exceptions/SlipIsAlreadyLeasedException.cs
new file mode 100644
index 0000000..be492b7
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Exceptions/SlipIsAlreadyLeasedException.cs
@@ -0,0 +1,5 @@
+using System;
+
+namespace Marina.Domain.Exceptions {
+ public class SlipIsAlreadyLeasedException : Exception {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IBoat.cs b/slips/src/app/Marina/Domain/Interfaces/IBoat.cs
new file mode 100644
index 0000000..1baf363
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IBoat.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Marina.Domain.Interfaces {
+ public interface IBoat : IDomainObject {
+ string RegistrationNumber();
+
+ string Manufacturer();
+
+ DateTime YearOfModel();
+
+ long LengthInFeet();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IBrokenRule.cs b/slips/src/app/Marina/Domain/Interfaces/IBrokenRule.cs
new file mode 100644
index 0000000..190dc0b
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IBrokenRule.cs
@@ -0,0 +1,5 @@
+namespace Marina.Domain.Interfaces {
+ public interface IBrokenRule {
+ string Message();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IBusinessRule.cs b/slips/src/app/Marina/Domain/Interfaces/IBusinessRule.cs
new file mode 100644
index 0000000..c0d3a79
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IBusinessRule.cs
@@ -0,0 +1,9 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain.Interfaces {
+ internal interface IBusinessRule {
+ bool IsBroken();
+
+ IBrokenRule Description();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ICustomer.cs b/slips/src/app/Marina/Domain/Interfaces/ICustomer.cs
new file mode 100644
index 0000000..677194c
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ICustomer.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+
+namespace Marina.Domain.Interfaces {
+ public interface ICustomer : IDomainObject {
+ void RegisterBoat( string registrationNumber, string manufacturer, DateTime yearOfModel, long length );
+
+ void RegisterBoat( IBoat unregisteredBoat );
+
+ IEnumerable< IBoat > RegisteredBoats();
+
+ void Lease( ISlip slip, ILeaseDuration duration );
+
+ IEnumerable< ISlipLease > Leases();
+
+ IRegistration Registration();
+
+ void RegisterAccount( string username, string password, string firstName,
+ string lastName, string phoneNumber, string city );
+
+ void UpdateRegistrationTo( IRegistration registration );
+
+ void UpdateRegistrationTo( string username, string password, string firstName, string lastName,
+ string phoneNumber,
+ string city );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IDateRange.cs b/slips/src/app/Marina/Domain/Interfaces/IDateRange.cs
new file mode 100644
index 0000000..ec53b90
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IDateRange.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace Marina.Domain.Interfaces {
+ public interface IDateRange {
+ DateTime Start();
+
+ DateTime End();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IDock.cs b/slips/src/app/Marina/Domain/Interfaces/IDock.cs
new file mode 100644
index 0000000..add87fb
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IDock.cs
@@ -0,0 +1,11 @@
+namespace Marina.Domain.Interfaces {
+ public interface IDock {
+ long ID();
+
+ string Name();
+
+ ILocation Location();
+
+ bool IsUtilityEnabled( IUtility utility );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IDomainObject.cs b/slips/src/app/Marina/Domain/Interfaces/IDomainObject.cs
new file mode 100644
index 0000000..c8a2c17
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IDomainObject.cs
@@ -0,0 +1,7 @@
+namespace Marina.Domain.Interfaces {
+ public interface IDomainObject {
+ long ID();
+
+ void ChangeIdTo( long id );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ILeaseDuration.cs b/slips/src/app/Marina/Domain/Interfaces/ILeaseDuration.cs
new file mode 100644
index 0000000..402398d
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ILeaseDuration.cs
@@ -0,0 +1,10 @@
+using System;
+using Marina.Infrastructure;
+
+namespace Marina.Domain.Interfaces {
+ public interface ILeaseDuration : IDomainObject, ISpecification< IDateRange > {
+ DateTime CalculateExpiryDateFrom( DateTime startDate );
+
+ string Name();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ILeaseType.cs b/slips/src/app/Marina/Domain/Interfaces/ILeaseType.cs
new file mode 100644
index 0000000..1fb50b9
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ILeaseType.cs
@@ -0,0 +1,7 @@
+namespace Marina.Domain.Interfaces {
+ public interface ILeaseType {
+ string Name();
+
+ double Rate();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ILocation.cs b/slips/src/app/Marina/Domain/Interfaces/ILocation.cs
new file mode 100644
index 0000000..2464e8c
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ILocation.cs
@@ -0,0 +1,5 @@
+namespace Marina.Domain.Interfaces {
+ public interface ILocation {
+ string Name();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IRange.cs b/slips/src/app/Marina/Domain/Interfaces/IRange.cs
new file mode 100644
index 0000000..e18cc33
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IRange.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Marina.Domain.Interfaces {
+ public interface IRange< T > where T : IComparable< T > {
+ T Start();
+
+ T End();
+
+ bool Contains( T value );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IRegistration.cs b/slips/src/app/Marina/Domain/Interfaces/IRegistration.cs
new file mode 100644
index 0000000..de470c6
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IRegistration.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain.Interfaces {
+ public interface IRegistration {
+ string Username();
+
+ string Password();
+
+ string FirstName();
+
+ string LastName();
+
+ string PhoneNumber();
+
+ string City();
+
+ bool IsValid();
+
+ IEnumerable< IBrokenRule > BrokenRules();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ISlip.cs b/slips/src/app/Marina/Domain/Interfaces/ISlip.cs
new file mode 100644
index 0000000..8ae576c
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ISlip.cs
@@ -0,0 +1,15 @@
+namespace Marina.Domain.Interfaces {
+ public interface ISlip : IDomainObject {
+ IDock Dock();
+
+ ILocation Location();
+
+ int Width();
+
+ int Length();
+
+ ISlipLease LeaseTo( ICustomer customer, ILeaseDuration duration );
+
+ bool IsLeased();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/ISlipLease.cs b/slips/src/app/Marina/Domain/Interfaces/ISlipLease.cs
new file mode 100644
index 0000000..219fb27
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/ISlipLease.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Marina.Domain.Interfaces {
+ public interface ISlipLease {
+ ILeaseDuration Duration();
+
+ DateTime StartDate();
+
+ DateTime ExpiryDate();
+
+ ISlip Slip();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Interfaces/IUtility.cs b/slips/src/app/Marina/Domain/Interfaces/IUtility.cs
new file mode 100644
index 0000000..77954d9
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Interfaces/IUtility.cs
@@ -0,0 +1,5 @@
+namespace Marina.Domain.Interfaces {
+ public interface IUtility {
+ bool IsEnabled( IUtility utility );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/LeaseDurations.cs b/slips/src/app/Marina/Domain/LeaseDurations.cs
new file mode 100644
index 0000000..e87e567
--- /dev/null
+++ b/slips/src/app/Marina/Domain/LeaseDurations.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class LeaseDurations {
+ public static readonly ILeaseDuration Daily = new LeaseDuration( "Daily", 1, 1 );
+ public static readonly ILeaseDuration Weekly = new LeaseDuration( "Weekly", 2, 7 );
+ public static readonly ILeaseDuration Monthly = new LeaseDuration( "Monthly", 3, 30 );
+ public static readonly ILeaseDuration Yearly = new LeaseDuration( "Yearly", 4, 365 );
+ private static readonly ILeaseDuration NoDuration = new LeaseDuration( "No Duration", -1, 0 );
+ private static readonly ILeaseDuration UnknownDuration = new LeaseDuration( "Unknown", -1, 0 );
+
+ private class LeaseDuration : DomainObject, ILeaseDuration {
+ private readonly int _days;
+ private readonly string _name;
+
+ public LeaseDuration( string name, long id, int days ) : base( id ) {
+ _days = days;
+ _name = name;
+ }
+
+ public DateTime CalculateExpiryDateFrom( DateTime startDate ) {
+ return startDate.AddDays( _days ).Date.AddHours( 11 );
+ }
+
+ public string Name() {
+ return _name;
+ }
+
+ public bool IsSatisfiedBy( IDateRange range ) {
+ TimeSpan daysInRange = range.End( ).Subtract( range.Start( ) );
+ return _days <= daysInRange.Days;
+ }
+ }
+
+ public static ILeaseDuration FindFor( DateTime startDate, DateTime endDate ) {
+ foreach ( ILeaseDuration duration in AllDurations( ) ) {
+ if ( duration.IsSatisfiedBy( new DateRange( startDate, endDate ) ) ) {
+ return duration;
+ }
+ }
+ return NoDuration;
+ }
+
+ private static IEnumerable< ILeaseDuration > AllDurations() {
+ yield return Yearly;
+ yield return Monthly;
+ yield return Weekly;
+ yield return Daily;
+ }
+
+ public static ILeaseDuration FindBy( string duration ) {
+ foreach ( ILeaseDuration leaseDuration in AllDurations( ) ) {
+ if ( string.Compare( leaseDuration.Name( ), duration, true ) == 0 ) {
+ return leaseDuration;
+ }
+ }
+ return UnknownDuration;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Location.cs b/slips/src/app/Marina/Domain/Location.cs
new file mode 100644
index 0000000..eb68748
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Location.cs
@@ -0,0 +1,15 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Location : ILocation {
+ public Location( string name ) {
+ _name = name;
+ }
+
+ public string Name() {
+ return _name;
+ }
+
+ private readonly string _name;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Range.cs b/slips/src/app/Marina/Domain/Range.cs
new file mode 100644
index 0000000..4b76b25
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Range.cs
@@ -0,0 +1,32 @@
+using System;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Range< T > : IRange< T > where T : IComparable< T > {
+ private readonly T start;
+ private readonly T end;
+
+ public Range( T start, T end ) {
+ if ( start.CompareTo( end ) <= 0 ) {
+ this.start = start;
+ this.end = end;
+ }
+ else {
+ this.start = end;
+ this.end = start;
+ }
+ }
+
+ public T Start() {
+ return start;
+ }
+
+ public T End() {
+ return end;
+ }
+
+ public bool Contains( T value ) {
+ return value.CompareTo( start ) >= 0 && value.CompareTo( end ) <= 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Repositories/ICustomerRepository.cs b/slips/src/app/Marina/Domain/Repositories/ICustomerRepository.cs
new file mode 100644
index 0000000..439bb12
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Repositories/ICustomerRepository.cs
@@ -0,0 +1,13 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain.Repositories {
+ public interface ICustomerRepository {
+ ICustomer FindBy( long customerId );
+
+ ICustomer FindBy( string username );
+
+ void Save( ICustomer customer );
+
+ ICustomer NewCustomer();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Repositories/IDockRepository.cs b/slips/src/app/Marina/Domain/Repositories/IDockRepository.cs
new file mode 100644
index 0000000..de9e51f
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Repositories/IDockRepository.cs
@@ -0,0 +1,7 @@
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain.Repositories {
+ public interface IDockRepository {
+ IDock FindBy( long dockId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Repositories/ISlipsRepository.cs b/slips/src/app/Marina/Domain/Repositories/ISlipsRepository.cs
new file mode 100644
index 0000000..8a23ca6
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Repositories/ISlipsRepository.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain.Repositories {
+ public interface ISlipsRepository {
+ IEnumerable< ISlip > AllAvailableSlips();
+
+ IEnumerable< ISlip > AllAvailableSlipsFor( IDock dock );
+
+ ISlip FindBy( long slipId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Slip.cs b/slips/src/app/Marina/Domain/Slip.cs
new file mode 100644
index 0000000..6b8a9b7
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Slip.cs
@@ -0,0 +1,46 @@
+using Marina.Domain.Exceptions;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Slip : DomainObject, ISlip {
+ public Slip( long id, IDock dock, int width, int length, bool isLeased ) : base( id ) {
+ _dock = dock;
+ _width = width;
+ _length = length;
+ _isLeased = isLeased;
+ }
+
+ public IDock Dock() {
+ return _dock;
+ }
+
+ public ILocation Location() {
+ return _dock.Location( );
+ }
+
+ public int Width() {
+ return _width;
+ }
+
+ public int Length() {
+ return _length;
+ }
+
+ public ISlipLease LeaseTo( ICustomer customer, ILeaseDuration duration ) {
+ if ( !IsLeased( ) ) {
+ _isLeased = true;
+ return new SlipLease( this, duration );
+ }
+ throw new SlipIsAlreadyLeasedException( );
+ }
+
+ public bool IsLeased() {
+ return _isLeased;
+ }
+
+ private readonly IDock _dock;
+ private readonly int _width;
+ private readonly int _length;
+ private bool _isLeased;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/SlipLease.cs b/slips/src/app/Marina/Domain/SlipLease.cs
new file mode 100644
index 0000000..297bbf0
--- /dev/null
+++ b/slips/src/app/Marina/Domain/SlipLease.cs
@@ -0,0 +1,37 @@
+using System;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class SlipLease : ISlipLease {
+ public SlipLease( ISlip slip, ILeaseDuration duration )
+ : this( slip, duration, DateTime.Now.Date, duration.CalculateExpiryDateFrom( DateTime.Now.Date ) ) {}
+
+ public SlipLease( ISlip slip, ILeaseDuration duration, DateTime startDate, DateTime expiryDate ) {
+ _slip = slip;
+ _duration = duration;
+ _startDate = startDate;
+ _expiryDate = expiryDate;
+ }
+
+ public ILeaseDuration Duration() {
+ return _duration;
+ }
+
+ public DateTime StartDate() {
+ return _startDate;
+ }
+
+ public DateTime ExpiryDate() {
+ return _expiryDate;
+ }
+
+ public ISlip Slip() {
+ return _slip;
+ }
+
+ private readonly ILeaseDuration _duration;
+ private readonly DateTime _startDate;
+ private readonly DateTime _expiryDate;
+ private readonly ISlip _slip;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/UnknownCustomer.cs b/slips/src/app/Marina/Domain/UnknownCustomer.cs
new file mode 100644
index 0000000..f79f4cc
--- /dev/null
+++ b/slips/src/app/Marina/Domain/UnknownCustomer.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class UnknownCustomer : ICustomer {
+ public void RegisterBoat( string registrationNumber, string manufacturer, DateTime yearOfModel, long length ) {}
+
+ public void RegisterBoat( IBoat unregisteredBoat ) {}
+
+ public IEnumerable< IBoat > RegisteredBoats() {
+ return new List< IBoat >( );
+ }
+
+ public void Lease( ISlip slip, ILeaseDuration duration ) {}
+
+ public IEnumerable< ISlipLease > Leases() {
+ return new List< ISlipLease >( );
+ }
+
+ public IRegistration Registration() {
+ return CustomerRegistration.BlankRegistration( );
+ }
+
+ public void RegisterAccount( string username, string password, string firstName, string lastName, string phoneNumber,
+ string city ) {}
+
+ public void UpdateRegistrationTo( IRegistration registration ) {}
+
+ public void UpdateRegistrationTo( string username, string password, string firstName, string lastName,
+ string phoneNumber, string city ) {}
+
+ public long ID() {
+ return -1;
+ }
+
+ public void ChangeIdTo( long id ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Domain/Utilities.cs b/slips/src/app/Marina/Domain/Utilities.cs
new file mode 100644
index 0000000..d318a86
--- /dev/null
+++ b/slips/src/app/Marina/Domain/Utilities.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Marina.Domain.Interfaces;
+
+namespace Marina.Domain {
+ public class Utilities {
+ public static readonly IUtility Water = new Utility( "Water" );
+ public static readonly IUtility Electrical = new Utility( "Electrical" );
+ private static readonly IUtility None = new Utility( "None" );
+
+ public static IUtility For( params IUtility[] utilities ) {
+ if ( null != utilities && 0 < utilities.Length ) {
+ return new UtilityComposite( utilities );
+ }
+ return None;
+ }
+
+ private class Utility : IUtility, IEquatable< Utility > {
+ private readonly string _name;
+
+ public Utility( string name ) {
+ _name = name;
+ }
+
+ public bool IsEnabled( IUtility utility ) {
+ return Equals( utility );
+ }
+
+ public bool Equals( Utility utility ) {
+ if ( utility == null ) {
+ return false;
+ }
+ return Equals( _name, utility._name );
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as Utility );
+ }
+
+ public override int GetHashCode() {
+ return _name.GetHashCode( );
+ }
+
+ public override string ToString() {
+ return _name;
+ }
+ }
+
+ private class UtilityComposite : IUtility {
+ private readonly IEnumerable< IUtility > _utilities;
+
+ public UtilityComposite( params IUtility[] utilities ) {
+ _utilities = new List< IUtility >( utilities );
+ }
+
+ public bool IsEnabled( IUtility utility ) {
+ return Equals( utility );
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ foreach ( IUtility utility in _utilities ) {
+ if ( utility != null ) {
+ if ( utility.Equals( obj ) ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public override int GetHashCode() {
+ return 0;
+ }
+
+ public override string ToString() {
+ StringBuilder builder = new StringBuilder( );
+ foreach ( IUtility utility in _utilities ) {
+ builder.Append( utility.ToString( ) );
+ }
+ return builder.ToString( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/BlankCommand.cs b/slips/src/app/Marina/Infrastructure/BlankCommand.cs
new file mode 100644
index 0000000..8fd0931
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/BlankCommand.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public class BlankCommand : ICommand {
+ public void Execute( ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItem.cs b/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItem.cs
new file mode 100644
index 0000000..36f512d
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItem.cs
@@ -0,0 +1,13 @@
+namespace Marina.Infrastructure.Configuration {
+ public class ConfigurationItem< T > {
+ private T item;
+
+ public ConfigurationItem( T item ) {
+ this.item = item;
+ }
+
+ public T Value( ) {
+ return item;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItems.cs b/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItems.cs
new file mode 100644
index 0000000..9a7973b
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Configuration/ConfigurationItems.cs
@@ -0,0 +1,15 @@
+using System.Configuration;
+using System.Xml;
+
+namespace Marina.Infrastructure.Configuration {
+ public class ConfigurationItems {
+ public static readonly ConfigurationItem< XmlElement > Log4NetConfigFile = new ConfigurationItem< XmlElement >(
+ LoadLog4NetConfig( ) );
+
+ private static XmlElement LoadLog4NetConfig( ) {
+ XmlDocument document = new XmlDocument( );
+ document.Load( ConfigurationManager.AppSettings[ "LogFileName" ] );
+ return document.DocumentElement;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Container/Custom/CustomDependencyContainer.cs b/slips/src/app/Marina/Infrastructure/Container/Custom/CustomDependencyContainer.cs
new file mode 100644
index 0000000..d37e452
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Container/Custom/CustomDependencyContainer.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure.Container.Custom {
+ public class CustomDependencyContainer : IDependencyContainer {
+ private static IDictionary< Type, object > list;
+
+ public CustomDependencyContainer( ) {
+ list = new Dictionary< Type, object >( );
+ }
+
+ public Interface GetMeAnImplementationOfAn< Interface >( ) {
+ Type currentType = typeof( Interface );
+ return ( Interface )list[ currentType ];
+ }
+
+ public void AddImplementationOf< Interface >( Interface objectToRegister ) {
+ list.Add( typeof( Interface ), objectToRegister );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Container/IDependencyContainer.cs b/slips/src/app/Marina/Infrastructure/Container/IDependencyContainer.cs
new file mode 100644
index 0000000..3533e23
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Container/IDependencyContainer.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure.Container {
+ public interface IDependencyContainer {
+ Interface GetMeAnImplementationOfAn< Interface >( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Container/InterfaceResolutionException.cs b/slips/src/app/Marina/Infrastructure/Container/InterfaceResolutionException.cs
new file mode 100644
index 0000000..d42b550
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Container/InterfaceResolutionException.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Marina.Infrastructure.Container {
+ public class InterfaceResolutionException : Exception {
+ public const string ExceptionMessageFormat = "Failed to resolve an implementation of an {0}";
+
+ public InterfaceResolutionException( Exception innerException, Type interfaceThatCouldNotBeResolvedForSomeReason )
+ : base(
+ string.Format( ExceptionMessageFormat, interfaceThatCouldNotBeResolvedForSomeReason.FullName ), innerException ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Container/Resolve.cs b/slips/src/app/Marina/Infrastructure/Container/Resolve.cs
new file mode 100644
index 0000000..53e602b
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Container/Resolve.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Marina.Infrastructure.Container {
+ public class Resolve {
+ private static IDependencyContainer container;
+
+ public static void InitializeWith( IDependencyContainer newContainer
+ ) {
+ container = newContainer;
+ }
+
+ public static Interface DependencyFor< Interface >() {
+ try {
+ return container.GetMeAnImplementationOfAn< Interface >( );
+ }
+ catch ( Exception e ) {
+ throw new InterfaceResolutionException( e, typeof( Interface ) );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Container/Windsor/WindsorDependencyContainer.cs b/slips/src/app/Marina/Infrastructure/Container/Windsor/WindsorDependencyContainer.cs
new file mode 100644
index 0000000..c35c6ce
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Container/Windsor/WindsorDependencyContainer.cs
@@ -0,0 +1,16 @@
+using Castle.Windsor;
+using Castle.Windsor.Configuration.Interpreters;
+
+namespace Marina.Infrastructure.Container.Windsor {
+ public class WindsorDependencyContainer : IDependencyContainer {
+ private readonly IWindsorContainer _container;
+
+ public WindsorDependencyContainer() {
+ _container = new WindsorContainer( new XmlInterpreter( @"windsor.config.xml" ) );
+ }
+
+ public Interface GetMeAnImplementationOfAn< Interface >() {
+ return _container.Resolve< Interface >( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/EnumerableMapper.cs b/slips/src/app/Marina/Infrastructure/EnumerableMapper.cs
new file mode 100644
index 0000000..0ba9bca
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/EnumerableMapper.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure {
+ internal class EnumerableMapper< TIn, TOut > : IMapper< IEnumerable< TIn >, IEnumerable< TOut > > {
+ public EnumerableMapper( IMapper< TIn, TOut > mapper ) {
+ _mapper = mapper;
+ }
+
+ public IEnumerable< TOut > MapFrom( IEnumerable< TIn > input ) {
+ foreach ( TIn item in input ) {
+ yield return _mapper.MapFrom( item );
+ }
+ }
+
+ private readonly IMapper< TIn, TOut > _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/ICommand.cs b/slips/src/app/Marina/Infrastructure/ICommand.cs
new file mode 100644
index 0000000..cd98ab5
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/ICommand.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface ICommand {
+ void Execute( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IFactory.cs b/slips/src/app/Marina/Infrastructure/IFactory.cs
new file mode 100644
index 0000000..0c835e0
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IFactory.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface IFactory< T > {
+ T Create( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IMapper.cs b/slips/src/app/Marina/Infrastructure/IMapper.cs
new file mode 100644
index 0000000..784bc41
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IMapper.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface IMapper< TIn, TOut > {
+ TOut MapFrom( TIn input );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IRichEnumerable.cs b/slips/src/app/Marina/Infrastructure/IRichEnumerable.cs
new file mode 100644
index 0000000..622bdf2
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IRichEnumerable.cs
@@ -0,0 +1,7 @@
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure {
+ public interface IRichEnumerable< T > : IEnumerable< T > {
+ IEnumerable< T > Where( ISpecification< T > criteriaToSatisfy );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IRichList.cs b/slips/src/app/Marina/Infrastructure/IRichList.cs
new file mode 100644
index 0000000..3bac655
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IRichList.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Marina.Infrastructure {
+ public interface IRichList< T > : IList< T > {
+ void AddRange( IEnumerable< T > collection );
+
+ ReadOnlyCollection< T > AsReadOnly();
+
+ int BinarySearch( int index, int count, T item, IComparer< T > comparer );
+
+ int BinarySearch( T item );
+
+ int BinarySearch( T item, IComparer< T > comparer );
+
+ IRichList< TOutput > ConvertAll< TOutput >( Converter< T, TOutput > converter );
+
+ void CopyTo( T[] array );
+
+ void CopyTo( int index, T[] array, int arrayIndex, int count );
+
+ bool Exists( Predicate< T > match );
+
+ T Find( Predicate< T > match );
+
+ IRichList< T > FindAll( Predicate< T > match );
+
+ int FindIndex( Predicate< T > match );
+
+ int FindIndex( int startIndex, Predicate< T > match );
+
+ int FindIndex( int startIndex, int count, Predicate< T > match );
+
+ T FindLast( Predicate< T > match );
+
+ int FindLastIndex( Predicate< T > match );
+
+ int FindLastIndex( int startIndex, Predicate< T > match );
+
+ int FindLastIndex( int startIndex, int count, Predicate< T > match );
+
+ void ForEach( Action< T > action );
+
+ IRichList< T > GetRange( int index, int count );
+
+ int IndexOf( T item, int index );
+
+ int IndexOf( T item, int index, int count );
+
+ void InsertRange( int index, IEnumerable< T > collection );
+
+ int LastIndexOf( T item );
+
+ int LastIndexOf( T item, int index );
+
+ int LastIndexOf( T item, int index, int count );
+
+ int RemoveAll( Predicate< T > match );
+
+ void RemoveRange( int index, int count );
+
+ void Reverse();
+
+ void Reverse( int index, int count );
+
+ void Sort();
+
+ void Sort( IComparer< T > comparer );
+
+ void Sort( int index, int count, IComparer< T > comparer );
+
+ void Sort( Comparison< T > comparison );
+
+ T[] ToArray();
+
+ void TrimExcess();
+
+ bool TrueForAll( Predicate< T > match );
+
+ int Capacity { get; set; }
+
+ void VisitAllItemWith( IVisitor< T > visitor );
+
+ Result GetResultOfVisitingAllItemsWith< Result >( IValueReturningVisitor< Result, T > visitor );
+
+ IEnumerable< Output > MapAllUsing< Output >( IMapper< T, Output > mapper );
+
+ IEnumerable< T > All();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/ISpecification.cs b/slips/src/app/Marina/Infrastructure/ISpecification.cs
new file mode 100644
index 0000000..852c66f
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/ISpecification.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface ISpecification< T > {
+ bool IsSatisfiedBy( T item );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/ISpecificationBuilder.cs b/slips/src/app/Marina/Infrastructure/ISpecificationBuilder.cs
new file mode 100644
index 0000000..14089db
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/ISpecificationBuilder.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface ISpecificationBuilder< T > : ISpecification< T > {
+ ISpecificationBuilder< T > And( ISpecification< T > specification );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/ITransformer.cs b/slips/src/app/Marina/Infrastructure/ITransformer.cs
new file mode 100644
index 0000000..4cbb54c
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/ITransformer.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface ITransformer {
+ Item To< Item >( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IValueReturningVisitor.cs b/slips/src/app/Marina/Infrastructure/IValueReturningVisitor.cs
new file mode 100644
index 0000000..160b039
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IValueReturningVisitor.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface IValueReturningVisitor< ValueToReturn, T > : IVisitor< T > {
+ ValueToReturn GetResult( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/IVisitor.cs b/slips/src/app/Marina/Infrastructure/IVisitor.cs
new file mode 100644
index 0000000..6c6e513
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/IVisitor.cs
@@ -0,0 +1,5 @@
+namespace Marina.Infrastructure {
+ public interface IVisitor< T > {
+ void Visit( T item );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/ListFactory.cs b/slips/src/app/Marina/Infrastructure/ListFactory.cs
new file mode 100644
index 0000000..0e19bcb
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/ListFactory.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure {
+ public class ListFactory {
+ public static IRichList< T > From< T >( IEnumerable< T > items ) {
+ if ( items == null ) {
+ return new RichList< T >( );
+ }
+ return new RichList< T >( items );
+ }
+
+ public static IEnumerable< T > For< T >( params T[] items ) {
+ IRichList< T > list = new RichList< T >( );
+ foreach ( T item in items ) {
+ list.Add( item );
+ }
+ return list;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs
new file mode 100644
index 0000000..37d91d8
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs
@@ -0,0 +1,7 @@
+namespace Marina.Infrastructure.Logging.Interfaces {
+ public interface ILog {
+ void Informational( string message );
+ void Informational( string messageFormat, params object[] args );
+ void CriticalError( string messageFormat, params object[] args );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs
new file mode 100644
index 0000000..0c71caf
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs
@@ -0,0 +1,7 @@
+using System;
+
+namespace Marina.Infrastructure.Logging.Interfaces {
+ public interface ILogFactory {
+ ILog CreateFor( Type type );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs
new file mode 100644
index 0000000..c8dae76
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs
@@ -0,0 +1,14 @@
+using System;
+using Marina.Infrastructure.Container;
+
+namespace Marina.Infrastructure.Logging.Interfaces {
+ public class Log {
+ public static ILog For( object itemThatRequiresLoggingServices ) {
+ return For( itemThatRequiresLoggingServices.GetType( ) );
+ }
+
+ public static ILog For( Type type ) {
+ return Resolve.DependencyFor< ILogFactory >( ).CreateFor( type );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs
new file mode 100644
index 0000000..a688728
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs
@@ -0,0 +1,8 @@
+using System.Xml;
+using log4net.Config;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public interface ILog4NetInitializationCommand {
+ void Execute( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs
new file mode 100644
index 0000000..888a088
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs
@@ -0,0 +1,19 @@
+using System.Xml;
+using log4net.Config;
+using Marina.Infrastructure.Configuration;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetInitializationCommand : ILog4NetInitializationCommand {
+ private readonly XmlElement configuration;
+
+ public Log4NetInitializationCommand( ) : this( ConfigurationItems.Log4NetConfigFile.Value( ) ) {}
+
+ public Log4NetInitializationCommand( XmlElement configuration ) {
+ this.configuration = configuration;
+ }
+
+ public void Execute( ) {
+ XmlConfigurator.Configure( configuration );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs
new file mode 100644
index 0000000..a225f55
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs
@@ -0,0 +1,23 @@
+using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetLog : ILog {
+ private log4net.ILog logToAdapt;
+
+ public Log4NetLog( log4net.ILog logToAdapt ) {
+ this.logToAdapt = logToAdapt;
+ }
+
+ public void Informational( string message ) {
+ logToAdapt.Info( message );
+ }
+
+ public void Informational( string messageFormat, params object[] args ) {
+ logToAdapt.InfoFormat( messageFormat, args );
+ }
+
+ public void CriticalError( string messageFormat, params object[] args ) {
+ logToAdapt.ErrorFormat( messageFormat, args );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs
new file mode 100644
index 0000000..996557f
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs
@@ -0,0 +1,30 @@
+using System;
+using log4net;
+using Marina.Infrastructure.Logging.Interfaces;
+using ILog=Marina.Infrastructure.Logging.Interfaces.ILog;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetLogFactory : ILogFactory {
+ private ILog4NetInitializationCommand initializationCommand;
+ private bool initialized;
+
+ public Log4NetLogFactory( ) : this( new Log4NetInitializationCommand( ) ) {}
+
+ public Log4NetLogFactory( ILog4NetInitializationCommand initializationCommand ) {
+ this.initializationCommand = initializationCommand;
+ }
+
+ public ILog CreateFor( Type typeThatRequiresLoggingServices ) {
+ WireUpConfiguration( );
+ return new Log4NetLog( LogManager.GetLogger( typeThatRequiresLoggingServices ) );
+ }
+
+ private void WireUpConfiguration( ) {
+ if ( initialized ) {
+ return;
+ }
+ initialized = true;
+ initializationCommand.Execute( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs
new file mode 100644
index 0000000..858d0f7
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs
@@ -0,0 +1,24 @@
+using System.IO;
+using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.TextWriterLogging {
+ public class TextWriterLog : ILog {
+ private readonly TextWriter _writer;
+
+ public TextWriterLog( TextWriter writer ) {
+ _writer = writer;
+ }
+
+ public void Informational( string message ) {
+ _writer.WriteLine( message );
+ }
+
+ public void Informational( string messageFormat, params object[] args ) {
+ _writer.WriteLine( messageFormat, args );
+ }
+
+ public void CriticalError( string messageFormat, params object[] args ) {
+ Informational( messageFormat, args );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs
new file mode 100644
index 0000000..7a2b344
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs
@@ -0,0 +1,10 @@
+using System;
+using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.TextWriterLogging {
+ public class TextWriterLogFactory : ILogFactory {
+ public ILog CreateFor( Type type ) {
+ return new TextWriterLog( Console.Out );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/RichEnumerable.cs b/slips/src/app/Marina/Infrastructure/RichEnumerable.cs
new file mode 100644
index 0000000..aa5f49d
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/RichEnumerable.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure {
+ public class RichEnumerable< T > : IRichEnumerable< T > {
+ private readonly IEnumerable< T > itemsToEnumerate;
+
+ public RichEnumerable( IEnumerable< T > itemsToEnumerate ) {
+ this.itemsToEnumerate = itemsToEnumerate;
+ }
+
+ public IEnumerable< T > Where( ISpecification< T > criteriaToSatisfy ) {
+ foreach ( T item in itemsToEnumerate ) {
+ if ( criteriaToSatisfy.IsSatisfiedBy( item ) ) {
+ yield return item;
+ }
+ }
+ }
+
+ IEnumerator< T > IEnumerable< T >.GetEnumerator() {
+ return itemsToEnumerate.GetEnumerator( );
+ }
+
+ public IEnumerator GetEnumerator() {
+ return ( ( IEnumerable< T > )this ).GetEnumerator( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/RichList.cs b/slips/src/app/Marina/Infrastructure/RichList.cs
new file mode 100644
index 0000000..ec6bfa0
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/RichList.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+
+namespace Marina.Infrastructure {
+ public class RichList< T > : List< T >, IRichList< T > {
+ public RichList( IEnumerable< T > collection )
+ : base( collection ) {}
+
+ public RichList( int capacity )
+ : base( capacity ) {}
+
+ public RichList() {}
+
+ public IEnumerable< Output > MapAllUsing< Output >( IMapper< T, Output > mapper ) {
+ return ConvertAll< Output >( mapper.MapFrom );
+ }
+
+ public IEnumerable< T > All() {
+ foreach ( T t in this ) {
+ yield return t;
+ }
+ }
+
+ public new IRichList< TOutput > ConvertAll< TOutput >( Converter< T, TOutput > converter ) {
+ return new RichList< TOutput >( base.ConvertAll( converter ) );
+ }
+
+ public new IRichList< T > FindAll( Predicate< T > match ) {
+ return new RichList< T >( base.FindAll( match ) );
+ }
+
+ public new IRichList< T > GetRange( int index, int count ) {
+ return new RichList< T >( base.GetRange( index, count ) );
+ }
+
+ public void VisitAllItemWith( IVisitor< T > visitor ) {
+ ForEach( visitor.Visit );
+ }
+
+ public Result GetResultOfVisitingAllItemsWith< Result >( IValueReturningVisitor< Result, T > visitor ) {
+ VisitAllItemWith( visitor );
+ return visitor.GetResult( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/SpecificationBuilder.cs b/slips/src/app/Marina/Infrastructure/SpecificationBuilder.cs
new file mode 100644
index 0000000..1651733
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/SpecificationBuilder.cs
@@ -0,0 +1,44 @@
+namespace Marina.Infrastructure {
+ public class SpecificationBuilder< T > : ISpecificationBuilder< T > {
+ public SpecificationBuilder() : this( new BlankSpecification( ) ) {}
+
+ public SpecificationBuilder( ISpecification< T > criteria ) {
+ _criteria = criteria;
+ }
+
+ public bool IsSatisfiedBy( T item ) {
+ return _criteria.IsSatisfiedBy( item );
+ }
+
+ public ISpecificationBuilder< T > And( ISpecification< T > specification ) {
+ _criteria = new AndSpecification< T >( _criteria, specification );
+ return this;
+ }
+
+ public ISpecification< T > Build() {
+ return _criteria;
+ }
+
+ public class BlankSpecification : ISpecification< T > {
+ public bool IsSatisfiedBy( T item ) {
+ return true;
+ }
+ }
+
+ private ISpecification< T > _criteria;
+
+ private class AndSpecification< K > : ISpecification< K > {
+ public AndSpecification( ISpecification< K > leftCriteria, ISpecification< K > rightCriteria ) {
+ this.leftCriteria = leftCriteria;
+ this.rightCriteria = rightCriteria;
+ }
+
+ public bool IsSatisfiedBy( K item ) {
+ return leftCriteria.IsSatisfiedBy( item ) && rightCriteria.IsSatisfiedBy( item );
+ }
+
+ private readonly ISpecification< K > leftCriteria;
+ private readonly ISpecification< K > rightCriteria;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Transform.cs b/slips/src/app/Marina/Infrastructure/Transform.cs
new file mode 100644
index 0000000..a47a9bc
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Transform.cs
@@ -0,0 +1,7 @@
+namespace Marina.Infrastructure {
+ public class Transform {
+ public static ITransformer From( object item ) {
+ return new Transformer( item );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Infrastructure/Transformer.cs b/slips/src/app/Marina/Infrastructure/Transformer.cs
new file mode 100644
index 0000000..bdd59c8
--- /dev/null
+++ b/slips/src/app/Marina/Infrastructure/Transformer.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace Marina.Infrastructure {
+ public class Transformer : ITransformer {
+ private object item;
+
+ public Transformer( object item ) {
+ this.item = item;
+ }
+
+ public Result To< Result >( ) {
+ EnsureItemIsNotNull( );
+ return ( Result )item;
+ }
+
+ private void EnsureItemIsNotNull( ) {
+ if ( item == null ) {
+ throw new NullReferenceException( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Marina.csproj b/slips/src/app/Marina/Marina.csproj
new file mode 100644
index 0000000..9fc4466
--- /dev/null
+++ b/slips/src/app/Marina/Marina.csproj
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F9AF658A-2A26-49DE-A964-7A846A8DCC2A}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Marina</RootNamespace>
+ <AssemblyName>Marina</AssemblyName>
+ <TargetFrameworkVersion>v3.5</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="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\castle\bin\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\castle\bin\Castle.DynamicProxy.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\castle\bin\Castle.MicroKernel.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\castle\bin\Castle.Windsor.dll</HintPath>
+ </Reference>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\log4net\bin\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Transactions" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DataAccess\Builders\DatabaseInsert.cs" />
+ <Compile Include="DataAccess\Builders\DatabaseSelect.cs" />
+ <Compile Include="DataAccess\Builders\DatabaseDelete.cs" />
+ <Compile Include="DataAccess\Builders\DatabaseUpdate.cs" />
+ <Compile Include="DataAccess\Builders\IDeleteQueryBuilder.cs" />
+ <Compile Include="DataAccess\Builders\IInsertQueryBuilder.cs" />
+ <Compile Include="DataAccess\Builders\IJoin.cs" />
+ <Compile Include="DataAccess\Builders\IQueryBuilder.cs" />
+ <Compile Include="DataAccess\Builders\ISelectQueryBuilder.cs" />
+ <Compile Include="DataAccess\Builders\IUpdateQueryBuilder.cs" />
+ <Compile Include="DataAccess\Builders\Query.cs" />
+ <Compile Include="DataAccess\Builders\SqlQuery.cs" />
+ <Compile Include="DataAccess\Builders\WhereClause.cs" />
+ <Compile Include="DataAccess\DatabaseColumn.cs" />
+ <Compile Include="DataAccess\DatabaseCommand.cs" />
+ <Compile Include="DataAccess\DatabaseCommandParameter.cs" />
+ <Compile Include="DataAccess\DatabaseConfiguration.cs" />
+ <Compile Include="DataAccess\DatabaseConnection.cs" />
+ <Compile Include="DataAccess\DatabaseConnectionFactory.cs" />
+ <Compile Include="DataAccess\DatabaseGateway.cs" />
+ <Compile Include="DataAccess\DatabaseProviderFactory.cs" />
+ <Compile Include="DataAccess\DatabaseRow.cs" />
+ <Compile Include="DataAccess\IDatabaseCommand.cs" />
+ <Compile Include="DataAccess\IDatabaseConfiguration.cs" />
+ <Compile Include="DataAccess\IDatabaseConnection.cs" />
+ <Compile Include="DataAccess\IDatabaseConnectionFactory.cs" />
+ <Compile Include="DataAccess\IDatabaseGateway.cs" />
+ <Compile Include="DataAccess\IDatabaseProviderFactory.cs" />
+ <Compile Include="DataAccess\IDatabaseRow.cs" />
+ <Compile Include="DataAccess\IdentityMap.cs" />
+ <Compile Include="DataAccess\IIdentityMap.cs" />
+ <Compile Include="DataAccess\Builders\IQuery.cs" />
+ <Compile Include="DataAccess\IDatabaseTransaction.cs" />
+ <Compile Include="DataAccess\DataMappers\BoatDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\CustomerDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\DockDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\IDockDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\LeaseDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\RegistrationDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\IBoatDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\ICustomerDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\IDataMapper.cs" />
+ <Compile Include="DataAccess\Exceptions\ObjectAlreadyAddedToIdentityMapException.cs" />
+ <Compile Include="DataAccess\DataMappers\IRegistrationDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\ILeaseDataMapper.cs" />
+ <Compile Include="DataAccess\Repositories\CustomerRepository.cs" />
+ <Compile Include="DataAccess\Repositories\DockRepository.cs" />
+ <Compile Include="DataAccess\DataMappers\ISlipDataMapper.cs" />
+ <Compile Include="DataAccess\DataMappers\SlipDataMapper.cs" />
+ <Compile Include="DataAccess\Schemas\AuthorizationTable.cs" />
+ <Compile Include="DataAccess\Schemas\BoatTable.cs" />
+ <Compile Include="DataAccess\Schemas\CustomerTable.cs" />
+ <Compile Include="DataAccess\Schemas\DockTable.cs" />
+ <Compile Include="DataAccess\Schemas\LeaseTable.cs" />
+ <Compile Include="DataAccess\Schemas\LeaseType.cs" />
+ <Compile Include="DataAccess\Schemas\LocationTable.cs" />
+ <Compile Include="DataAccess\Schemas\SlipTable.cs" />
+ <Compile Include="DataAccess\DatabaseTransaction.cs" />
+ <Compile Include="Domain\Boat.cs" />
+ <Compile Include="Domain\BrokenRule.cs" />
+ <Compile Include="Domain\Customer.cs" />
+ <Compile Include="Domain\CustomerRegistration.cs" />
+ <Compile Include="Domain\DateRange.cs" />
+ <Compile Include="Domain\Dock.cs" />
+ <Compile Include="Domain\DomainObject.cs" />
+ <Compile Include="Domain\Interfaces\IBusinessRule.cs" />
+ <Compile Include="Domain\Interfaces\IDateRange.cs" />
+ <Compile Include="Domain\Interfaces\IBoat.cs" />
+ <Compile Include="Domain\Interfaces\IBrokenRule.cs" />
+ <Compile Include="Domain\Interfaces\ICustomer.cs" />
+ <Compile Include="Domain\Interfaces\IDock.cs" />
+ <Compile Include="Domain\Interfaces\IDomainObject.cs" />
+ <Compile Include="Domain\Interfaces\ILeaseDuration.cs" />
+ <Compile Include="Domain\Interfaces\ILeaseType.cs" />
+ <Compile Include="Domain\Interfaces\ILocation.cs" />
+ <Compile Include="Domain\Interfaces\ISlipLease.cs" />
+ <Compile Include="Domain\Interfaces\IUtility.cs" />
+ <Compile Include="Domain\Interfaces\IRange.cs" />
+ <Compile Include="Domain\Interfaces\IRegistration.cs" />
+ <Compile Include="Domain\LeaseDurations.cs" />
+ <Compile Include="Domain\Location.cs" />
+ <Compile Include="Domain\Range.cs" />
+ <Compile Include="Domain\Repositories\ICustomerRepository.cs" />
+ <Compile Include="Domain\Repositories\IDockRepository.cs" />
+ <Compile Include="Domain\Interfaces\ISlip.cs" />
+ <Compile Include="Domain\Repositories\ISlipsRepository.cs" />
+ <Compile Include="DataAccess\Repositories\SlipsRepository.cs" />
+ <Compile Include="Domain\Slip.cs" />
+ <Compile Include="Domain\Exceptions\SlipIsAlreadyLeasedException.cs" />
+ <Compile Include="Domain\SlipLease.cs" />
+ <Compile Include="Domain\UnknownCustomer.cs" />
+ <Compile Include="Domain\Utilities.cs" />
+ <Compile Include="Infrastructure\Configuration\ConfigurationItem.cs" />
+ <Compile Include="Infrastructure\Configuration\ConfigurationItems.cs" />
+ <Compile Include="Infrastructure\Container\Custom\CustomDependencyContainer.cs" />
+ <Compile Include="Infrastructure\Container\Resolve.cs" />
+ <Compile Include="Infrastructure\Container\IDependencyContainer.cs" />
+ <Compile Include="Infrastructure\Container\InterfaceResolutionException.cs" />
+ <Compile Include="Infrastructure\Container\Windsor\WindsorDependencyContainer.cs" />
+ <Compile Include="Infrastructure\EnumerableMapper.cs" />
+ <Compile Include="Infrastructure\IRichEnumerable.cs" />
+ <Compile Include="Infrastructure\IRichList.cs" />
+ <Compile Include="Infrastructure\ISpecificationBuilder.cs" />
+ <Compile Include="Infrastructure\ITransformer.cs" />
+ <Compile Include="Infrastructure\IValueReturningVisitor.cs" />
+ <Compile Include="Infrastructure\IVisitor.cs" />
+ <Compile Include="Infrastructure\ListFactory.cs" />
+ <Compile Include="Infrastructure\Logging\Log4Net\ILog4NetInitializationCommand.cs" />
+ <Compile Include="Infrastructure\Logging\Log4Net\Log4NetInitializationCommand.cs" />
+ <Compile Include="Infrastructure\Logging\Log4Net\Log4NetLogFactory.cs" />
+ <Compile Include="Infrastructure\RichEnumerable.cs" />
+ <Compile Include="Infrastructure\RichList.cs" />
+ <Compile Include="Infrastructure\SpecificationBuilder.cs" />
+ <Compile Include="Infrastructure\Transform.cs" />
+ <Compile Include="Infrastructure\Transformer.cs" />
+ <Compile Include="Presentation\DTO\BoatRegistrationDTO.cs" />
+ <Compile Include="Presentation\DTO\DisplayLeaseDTO.cs" />
+ <Compile Include="Presentation\DTO\DisplayResponseLines.cs" />
+ <Compile Include="Presentation\DTO\LoginCredentialsDTO.cs" />
+ <Compile Include="Presentation\DTO\SubmitLeaseRequestDTO.cs" />
+ <Compile Include="Presentation\Mappers\ILeaseRequestDtoFromHttpRequestMapper.cs" />
+ <Compile Include="Presentation\Mappers\ILoginCredentialsMapper.cs" />
+ <Compile Include="Presentation\Mappers\INewBoatRegistrationMapper.cs" />
+ <Compile Include="Presentation\Mappers\LeaseRequestDtoFromHttpRequestMapper.cs" />
+ <Compile Include="Presentation\Mappers\LoginCredentialsMapper.cs" />
+ <Compile Include="Presentation\Mappers\NewBoatRegistrationMapper.cs" />
+ <Compile Include="Presentation\PayloadKeyNotFoundException.cs" />
+ <Compile Include="Presentation\Presenters\AvailableSlipsPresenter.cs" />
+ <Compile Include="Presentation\Presenters\CurrentLeasesPresenter.cs" />
+ <Compile Include="Presentation\Presenters\DockPresenter.cs" />
+ <Compile Include="Presentation\DTO\CustomerRegistrationDisplayDTO.cs" />
+ <Compile Include="Presentation\DTO\DockDisplayDTO.cs" />
+ <Compile Include="Presentation\DTO\SlipDisplayDTO.cs" />
+ <Compile Include="Presentation\DTO\UpdateCustomerRegistrationDTO.cs" />
+ <Compile Include="Presentation\Presenters\IAvailableSlipsPresenter.cs" />
+ <Compile Include="Presentation\Presenters\ICurrentLeasesPresenter.cs" />
+ <Compile Include="Presentation\Presenters\IDockPresenter.cs" />
+ <Compile Include="Presentation\Mappers\CustomerRegistrationPresentationMapper.cs" />
+ <Compile Include="Presentation\Mappers\ICustomerRegistrationPresentationMapper.cs" />
+ <Compile Include="Infrastructure\IMapper.cs" />
+ <Compile Include="Infrastructure\Logging\Interfaces\ILog.cs" />
+ <Compile Include="Infrastructure\Logging\Interfaces\ILogFactory.cs" />
+ <Compile Include="Infrastructure\Logging\Interfaces\Log.cs" />
+ <Compile Include="Infrastructure\Logging\Log4Net\Log4NetLog.cs" />
+ <Compile Include="Infrastructure\Logging\TextWriterLogging\TextWriterLog.cs" />
+ <Compile Include="Infrastructure\Logging\TextWriterLogging\TextWriterLogFactory.cs" />
+ <Compile Include="Presentation\Presenters\CustomerRegistrationPresenter.cs" />
+ <Compile Include="Presentation\DTO\DisplayResponseLineDTO.cs" />
+ <Compile Include="Presentation\DTO\RegisterCustomerDTO.cs" />
+ <Compile Include="Presentation\Presenters\ICustomerRegistrationPresenter.cs" />
+ <Compile Include="Presentation\Mappers\IUpdateRegistrationPresentationMapper.cs" />
+ <Compile Include="Presentation\Mappers\UpdateRegistrationPresentationMapper.cs" />
+ <Compile Include="Presentation\PayloadKey.cs" />
+ <Compile Include="Presentation\PayLoadKeys.cs" />
+ <Compile Include="Presentation\Presenters\ILeaseSlipPresenter.cs" />
+ <Compile Include="Presentation\Presenters\ILoginPresenter.cs" />
+ <Compile Include="Presentation\Presenters\IRegisterBoatPresenter.cs" />
+ <Compile Include="Presentation\Presenters\IUpdateCustomerRegistrationPresenter.cs" />
+ <Compile Include="Presentation\Presenters\IViewRegisteredBoatsPresenter.cs" />
+ <Compile Include="Presentation\Presenters\LeaseSlipPresenter.cs" />
+ <Compile Include="Presentation\Presenters\LoginPresenter.cs" />
+ <Compile Include="Presentation\Presenters\RegisterBoatPresenter.cs" />
+ <Compile Include="Presentation\Presenters\UpdateCustomerRegistrationPresenter.cs" />
+ <Compile Include="Presentation\Presenters\ViewRegisteredBoatsPresenter.cs" />
+ <Compile Include="Presentation\Views\IAvailableSlipsView.cs" />
+ <Compile Include="Presentation\Views\ICurrentLeasesView.cs" />
+ <Compile Include="Presentation\Views\ICustomerRegistrationView.cs" />
+ <Compile Include="Presentation\Views\IDockView.cs" />
+ <Compile Include="Presentation\Views\ILeaseSlipView.cs" />
+ <Compile Include="Presentation\Views\ILoginView.cs" />
+ <Compile Include="Presentation\Views\IRegisterBoatView.cs" />
+ <Compile Include="Presentation\Views\IRegisteredBoatsView.cs" />
+ <Compile Include="Presentation\Views\IUpdateRegistrationView.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Task\ApplicationStartupTask.cs" />
+ <Compile Include="Task\AuthenticationTask.cs" />
+ <Compile Include="Task\CatalogTasks.cs" />
+ <Compile Include="Task\IApplicationStartupTask.cs" />
+ <Compile Include="Task\IAuthenticationTask.cs" />
+ <Compile Include="Task\ILeaseTasks.cs" />
+ <Compile Include="Task\IRegistrationTasks.cs" />
+ <Compile Include="Task\ICatalogTasks.cs" />
+ <Compile Include="Task\LeaseTasks.cs" />
+ <Compile Include="Task\Mappers\BrokenRulesToDisplayItemMapper.cs" />
+ <Compile Include="Task\Mappers\DockToDisplayDTOMapper.cs" />
+ <Compile Include="Task\Mappers\IBrokenRulesToDisplayItemMapper.cs" />
+ <Compile Include="Task\Mappers\IDockToDisplayDTOMapper.cs" />
+ <Compile Include="Task\Mappers\ILeaseToDtoMapper.cs" />
+ <Compile Include="Task\Mappers\ISlipsToDisplayDTOMapper.cs" />
+ <Compile Include="Task\Mappers\LeaseToDtoMapper.cs" />
+ <Compile Include="Task\Mappers\SlipsToDisplayDTOMapper.cs" />
+ <Compile Include="Task\RegistrationTasks.cs" />
+ <Compile Include="Web\AuthenticationHttpModule.cs" />
+ <Compile Include="Web\Commands\AvailableSlipsCommand.cs" />
+ <Compile Include="Web\Commands\CommandNames.cs" />
+ <Compile Include="Web\Commands\RedirectCommand.cs" />
+ <Compile Include="Web\Handlers\AvailableSlipsHandler.cs" />
+ <Compile Include="Infrastructure\BlankCommand.cs" />
+ <Compile Include="Web\Handlers\Dispatcher.cs" />
+ <Compile Include="Web\FrontController.cs" />
+ <Compile Include="Web\Handlers\RequestHandler.cs" />
+ <Compile Include="Web\Handlers\RequestHandlerSpecification.cs" />
+ <Compile Include="Web\Http\HttpGateway.cs" />
+ <Compile Include="Infrastructure\ICommand.cs" />
+ <Compile Include="Infrastructure\IFactory.cs" />
+ <Compile Include="Web\Http\IHttpGateway.cs" />
+ <Compile Include="Web\Handlers\IRegisteredHandlers.cs" />
+ <Compile Include="Web\Handlers\IRequestHandler.cs" />
+ <Compile Include="Infrastructure\ISpecification.cs" />
+ <Compile Include="Web\Services\AuthenticationWebServices.cs" />
+ <Compile Include="Web\Services\CatalogWebServices.cs" />
+ <Compile Include="Web\Services\LeaseWebServices.cs" />
+ <Compile Include="Web\Services\RegistrationWebServices.cs" />
+ <Compile Include="Web\UnhandledExceptionsHttpModule.cs" />
+ <Compile Include="Web\Views\IView.cs" />
+ <Compile Include="Web\Views\IViewLuggageTransporter.cs" />
+ <Compile Include="Web\Views\IViewLuggageTicket.cs" />
+ <Compile Include="Web\Handlers\RegisteredHandlers.cs" />
+ <Compile Include="Web\Views\IWebView.cs" />
+ <Compile Include="Web\Views\Pages\AvailableSlipsWebView.cs" />
+ <Compile Include="Web\Views\Pages\IAvailableSlipsWebView.cs" />
+ <Compile Include="Web\Views\View.cs" />
+ <Compile Include="Web\Views\ViewLuggage.cs" />
+ <Compile Include="Web\Views\ViewLuggageTickets.cs" />
+ <Compile Include="Web\Redirect.cs" />
+ <Compile Include="Web\Views\ViewLuggageTransporter.cs" />
+ <Compile Include="Web\Views\WebView.cs" />
+ <Compile Include="Web\Views\WebViews.cs" />
+ <Compile Include="Web\CurrentHttpRequest.cs" />
+ <Compile Include="Web\GlobalApplication.cs" />
+ <Compile Include="Web\CurrentHttpContext.cs" />
+ <Compile Include="Web\IHttpRequest.cs" />
+ <Compile Include="Web\IHttpContext.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Web\Services\AuthenticationServices.asmx" />
+ <Content Include="Web\Services\CatalogServices.asmx" />
+ <Content Include="Web\Services\RegistrationServices.asmx" />
+ <Content Include="Web\Services\LeaseServices.asmx" />
+ </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> \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/BoatRegistrationDTO.cs b/slips/src/app/Marina/Presentation/DTO/BoatRegistrationDTO.cs
new file mode 100644
index 0000000..f34a70f
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/BoatRegistrationDTO.cs
@@ -0,0 +1,41 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class BoatRegistrationDTO {
+ private readonly string registrationNumber;
+ private readonly string manufacturer;
+ private readonly string modelYear;
+ private readonly string length;
+ private readonly long customerId;
+
+ public BoatRegistrationDTO( string registrationNumber, string manufacturer, string modelYear, string length,
+ long customerId ) {
+ this.registrationNumber = registrationNumber;
+ this.manufacturer = manufacturer;
+ this.modelYear = modelYear;
+ this.length = length;
+ this.customerId = customerId;
+ }
+
+ public string RegistrationNumber {
+ get { return registrationNumber; }
+ }
+
+ public string Manufacturer {
+ get { return manufacturer; }
+ }
+
+ public string ModelYear {
+ get { return modelYear; }
+ }
+
+ public string Length {
+ get { return length; }
+ }
+
+ public long CustomerId {
+ get { return customerId; }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/CustomerRegistrationDisplayDTO.cs b/slips/src/app/Marina/Presentation/DTO/CustomerRegistrationDisplayDTO.cs
new file mode 100644
index 0000000..3c517bf
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/CustomerRegistrationDisplayDTO.cs
@@ -0,0 +1,91 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class CustomerRegistrationDisplayDTO : IEquatable< CustomerRegistrationDisplayDTO > {
+ private CustomerRegistrationDisplayDTO() {}
+
+ public CustomerRegistrationDisplayDTO( string id, string userName, string firstName, string lastName, string phone,
+ string city ) {
+ _userName = userName;
+ _id = id;
+ _firstName = firstName;
+ _lastName = lastName;
+ _phone = phone;
+ _city = city;
+ }
+
+ public string Id {
+ get { return _id; }
+ }
+
+ public string UserName {
+ get { return _userName; }
+ }
+
+ public string FirstName {
+ get { return _firstName; }
+ }
+
+ public string LastName {
+ get { return _lastName; }
+ }
+
+ public string Phone {
+ get { return _phone; }
+ }
+
+ public string City {
+ get { return _city; }
+ }
+
+ public bool Equals( CustomerRegistrationDisplayDTO customerRegistrationDisplayDTO ) {
+ if ( customerRegistrationDisplayDTO == null ) {
+ return false;
+ }
+ if ( !Equals( _userName, customerRegistrationDisplayDTO._userName ) ) {
+ return false;
+ }
+ if ( !Equals( _firstName, customerRegistrationDisplayDTO._firstName ) ) {
+ return false;
+ }
+ if ( !Equals( _lastName, customerRegistrationDisplayDTO._lastName ) ) {
+ return false;
+ }
+ if ( !Equals( _phone, customerRegistrationDisplayDTO._phone ) ) {
+ return false;
+ }
+ if ( !Equals( _city, customerRegistrationDisplayDTO._city ) ) {
+ return false;
+ }
+ if ( !Equals( _id, customerRegistrationDisplayDTO._id ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as CustomerRegistrationDisplayDTO );
+ }
+
+ public override int GetHashCode() {
+ int result = _userName != null ? _userName.GetHashCode( ) : 0;
+ result = 29*result + ( _firstName != null ? _firstName.GetHashCode( ) : 0 );
+ result = 29*result + ( _lastName != null ? _lastName.GetHashCode( ) : 0 );
+ result = 29*result + ( _phone != null ? _phone.GetHashCode( ) : 0 );
+ result = 29*result + ( _city != null ? _city.GetHashCode( ) : 0 );
+ result = 29*result + ( _id != null ? _id.GetHashCode( ) : 0 );
+ return result;
+ }
+
+ private string _userName;
+ private string _firstName;
+ private string _lastName;
+ private string _phone;
+ private string _city;
+ private string _id;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/DisplayLeaseDTO.cs b/slips/src/app/Marina/Presentation/DTO/DisplayLeaseDTO.cs
new file mode 100644
index 0000000..a8c94cc
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/DisplayLeaseDTO.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class DisplayLeaseDTO {
+ public DisplayLeaseDTO( string slipID, string startDate, string expiryDate ) {
+ _slipID = slipID;
+ _startDate = startDate;
+ _expiryDate = expiryDate;
+ }
+
+ public string SlipID {
+ get { return _slipID; }
+ }
+
+ public string StartDate {
+ get { return _startDate; }
+ }
+
+ public string ExpiryDate {
+ get { return _expiryDate; }
+ }
+
+ private string _slipID;
+ private string _startDate;
+ private string _expiryDate;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/DisplayResponseLineDTO.cs b/slips/src/app/Marina/Presentation/DTO/DisplayResponseLineDTO.cs
new file mode 100644
index 0000000..b245db6
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/DisplayResponseLineDTO.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class DisplayResponseLineDTO : IEquatable< DisplayResponseLineDTO > {
+ private readonly string _message;
+
+ private DisplayResponseLineDTO() {}
+
+ public DisplayResponseLineDTO( string message ) {
+ _message = message;
+ }
+
+ public string Message {
+ get { return _message; }
+ }
+
+ public bool Equals( DisplayResponseLineDTO displayResponseLineDTO ) {
+ if ( displayResponseLineDTO == null ) {
+ return false;
+ }
+ return Equals( _message, displayResponseLineDTO._message );
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as DisplayResponseLineDTO );
+ }
+
+ public override int GetHashCode() {
+ return _message != null ? _message.GetHashCode( ) : 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/DisplayResponseLines.cs b/slips/src/app/Marina/Presentation/DTO/DisplayResponseLines.cs
new file mode 100644
index 0000000..4f8c74c
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/DisplayResponseLines.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class DisplayResponseLines : IEnumerable< DisplayResponseLineDTO > {
+ private readonly string[] _lineItems;
+
+ public DisplayResponseLines( params string[] messages ) {
+ _lineItems = messages;
+ }
+
+ IEnumerator< DisplayResponseLineDTO > IEnumerable< DisplayResponseLineDTO >.GetEnumerator() {
+ foreach ( string message in _lineItems ) {
+ yield return new DisplayResponseLineDTO( message );
+ }
+ }
+
+ public IEnumerator GetEnumerator() {
+ return ( ( IEnumerable< DisplayResponseLineDTO > )this ).GetEnumerator( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/DockDisplayDTO.cs b/slips/src/app/Marina/Presentation/DTO/DockDisplayDTO.cs
new file mode 100644
index 0000000..1a0e4d0
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/DockDisplayDTO.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class DockDisplayDTO {
+ private readonly string _name;
+ private readonly string _locationName;
+ private readonly string _waterService;
+ private readonly string _electricalService;
+
+ private DockDisplayDTO() {}
+
+ public DockDisplayDTO( string name, string locationName, string waterService, string electricalService ) {
+ _name = name;
+ _locationName = locationName;
+ _waterService = waterService;
+ _electricalService = electricalService;
+ }
+
+ public string Name {
+ get { return _name; }
+ }
+
+ public string LocationName {
+ get { return _locationName; }
+ }
+
+ public string WaterService {
+ get { return _waterService; }
+ }
+
+ public string ElectricalService {
+ get { return _electricalService; }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/LoginCredentialsDTO.cs b/slips/src/app/Marina/Presentation/DTO/LoginCredentialsDTO.cs
new file mode 100644
index 0000000..33365c1
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/LoginCredentialsDTO.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class LoginCredentialsDTO {
+ private readonly string username;
+ private readonly string password;
+
+ private LoginCredentialsDTO() {}
+
+ public LoginCredentialsDTO( string username, string password ) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public string Username {
+ get { return username; }
+ }
+
+ public string Password {
+ get { return password; }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/RegisterCustomerDTO.cs b/slips/src/app/Marina/Presentation/DTO/RegisterCustomerDTO.cs
new file mode 100644
index 0000000..339572e
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/RegisterCustomerDTO.cs
@@ -0,0 +1,47 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class RegisterCustomerDTO {
+ public RegisterCustomerDTO( string userName, string password, string firstName, string lastName, string phone,
+ string city ) {
+ _userName = userName;
+ _password = password;
+ _firstName = firstName;
+ _lastName = lastName;
+ _phone = phone;
+ _city = city;
+ }
+
+ public string UserName {
+ get { return _userName; }
+ }
+
+ public string Password {
+ get { return _password; }
+ }
+
+ public string FirstName {
+ get { return _firstName; }
+ }
+
+ public string LastName {
+ get { return _lastName; }
+ }
+
+ public string Phone {
+ get { return _phone; }
+ }
+
+ public string City {
+ get { return _city; }
+ }
+
+ private string _userName;
+ private string _password;
+ private string _firstName;
+ private string _lastName;
+ private string _phone;
+ private string _city;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/SlipDisplayDTO.cs b/slips/src/app/Marina/Presentation/DTO/SlipDisplayDTO.cs
new file mode 100644
index 0000000..59267e4
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/SlipDisplayDTO.cs
@@ -0,0 +1,48 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class SlipDisplayDTO {
+ private SlipDisplayDTO() {}
+
+ public SlipDisplayDTO( string dockId, string dockName, string width, string length, string locationName, string slipId ) {
+ _dockName = dockName;
+ _slipId = slipId;
+ _locationName = locationName;
+ _dockId = dockId;
+ _width = width;
+ _length = length;
+ }
+
+ public string DockName {
+ get { return _dockName; }
+ }
+
+ public string Width {
+ get { return _width; }
+ }
+
+ public string Length {
+ get { return _length; }
+ }
+
+ public string DockId {
+ get { return _dockId; }
+ }
+
+ public string LocationName {
+ get { return _locationName; }
+ }
+
+ public string SlipId {
+ get { return _slipId; }
+ }
+
+ private string _dockName;
+ private string _width;
+ private string _length;
+ private string _dockId;
+ private string _locationName;
+ private string _slipId;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/SubmitLeaseRequestDTO.cs b/slips/src/app/Marina/Presentation/DTO/SubmitLeaseRequestDTO.cs
new file mode 100644
index 0000000..a7899b1
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/SubmitLeaseRequestDTO.cs
@@ -0,0 +1,60 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class SubmitLeaseRequestDTO : IEquatable< SubmitLeaseRequestDTO > {
+ private SubmitLeaseRequestDTO() {}
+
+ public SubmitLeaseRequestDTO( long customerId, long slipId, string duration ) {
+ _customerId = customerId;
+ _slipId = slipId;
+ _duration = duration;
+ }
+
+ public long CustomerId {
+ get { return _customerId; }
+ }
+
+ public long SlipId {
+ get { return _slipId; }
+ }
+
+ public string Duration {
+ get { return _duration; }
+ }
+
+ public bool Equals( SubmitLeaseRequestDTO submitLeaseRequestDTO ) {
+ if ( submitLeaseRequestDTO == null ) {
+ return false;
+ }
+ if ( _customerId != submitLeaseRequestDTO._customerId ) {
+ return false;
+ }
+ if ( _slipId != submitLeaseRequestDTO._slipId ) {
+ return false;
+ }
+ if ( !Equals( _duration, submitLeaseRequestDTO._duration ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public override bool Equals( object obj ) {
+ if ( ReferenceEquals( this, obj ) ) {
+ return true;
+ }
+ return Equals( obj as SubmitLeaseRequestDTO );
+ }
+
+ public override int GetHashCode() {
+ int result = ( int )_customerId;
+ result = 29*result + ( int )_slipId;
+ result = 29*result + ( _duration != null ? _duration.GetHashCode( ) : 0 );
+ return result;
+ }
+
+ private readonly long _customerId;
+ private readonly long _slipId;
+ private readonly string _duration;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/DTO/UpdateCustomerRegistrationDTO.cs b/slips/src/app/Marina/Presentation/DTO/UpdateCustomerRegistrationDTO.cs
new file mode 100644
index 0000000..8f4681a
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/DTO/UpdateCustomerRegistrationDTO.cs
@@ -0,0 +1,53 @@
+using System;
+
+namespace Marina.Presentation.DTO {
+ [Serializable]
+ public class UpdateCustomerRegistrationDTO {
+ private long customerId;
+ private string username;
+ private string password;
+ private string firstName;
+ private string lastName;
+ private string phoneNumber;
+ private string city;
+
+ public UpdateCustomerRegistrationDTO( long customerId, string username, string password, string firstName,
+ string lastName, string phoneNumber, string city ) {
+ this.customerId = customerId;
+ this.username = username;
+ this.password = password;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.phoneNumber = phoneNumber;
+ this.city = city;
+ }
+
+ public long CustomerId {
+ get { return customerId; }
+ }
+
+ public string Username {
+ get { return username; }
+ }
+
+ public string Password {
+ get { return password; }
+ }
+
+ public string FirstName {
+ get { return firstName; }
+ }
+
+ public string LastName {
+ get { return lastName; }
+ }
+
+ public string PhoneNumber {
+ get { return phoneNumber; }
+ }
+
+ public string City {
+ get { return city; }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/CustomerRegistrationPresentationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/CustomerRegistrationPresentationMapper.cs
new file mode 100644
index 0000000..9d70078
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/CustomerRegistrationPresentationMapper.cs
@@ -0,0 +1,17 @@
+using Marina.Presentation.DTO;
+using Marina.Presentation.Views;
+
+namespace Marina.Presentation.Mappers {
+ public class CustomerRegistrationPresentationMapper : ICustomerRegistrationPresentationMapper {
+ public RegisterCustomerDTO MapFrom( ICustomerRegistrationView view ) {
+ return new RegisterCustomerDTO(
+ view.UserName( ),
+ view.Password( ),
+ view.FirstName( ),
+ view.LastName( ),
+ view.PhoneNumber( ),
+ view.City( )
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/ICustomerRegistrationPresentationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/ICustomerRegistrationPresentationMapper.cs
new file mode 100644
index 0000000..e39373b
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/ICustomerRegistrationPresentationMapper.cs
@@ -0,0 +1,8 @@
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Presentation.Views;
+
+namespace Marina.Presentation.Mappers {
+ public interface ICustomerRegistrationPresentationMapper :
+ IMapper< ICustomerRegistrationView, RegisterCustomerDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/ILeaseRequestDtoFromHttpRequestMapper.cs b/slips/src/app/Marina/Presentation/Mappers/ILeaseRequestDtoFromHttpRequestMapper.cs
new file mode 100644
index 0000000..720019c
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/ILeaseRequestDtoFromHttpRequestMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public interface ILeaseRequestDtoFromHttpRequestMapper : IMapper< IHttpRequest, SubmitLeaseRequestDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/ILoginCredentialsMapper.cs b/slips/src/app/Marina/Presentation/Mappers/ILoginCredentialsMapper.cs
new file mode 100644
index 0000000..aac8f81
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/ILoginCredentialsMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public interface ILoginCredentialsMapper : IMapper< IHttpRequest, LoginCredentialsDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/INewBoatRegistrationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/INewBoatRegistrationMapper.cs
new file mode 100644
index 0000000..8e115af
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/INewBoatRegistrationMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public interface INewBoatRegistrationMapper : IMapper< IHttpRequest, BoatRegistrationDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/IUpdateRegistrationPresentationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/IUpdateRegistrationPresentationMapper.cs
new file mode 100644
index 0000000..0c63fd7
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/IUpdateRegistrationPresentationMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public interface IUpdateRegistrationPresentationMapper : IMapper< IHttpRequest, UpdateCustomerRegistrationDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/LeaseRequestDtoFromHttpRequestMapper.cs b/slips/src/app/Marina/Presentation/Mappers/LeaseRequestDtoFromHttpRequestMapper.cs
new file mode 100644
index 0000000..ed5bbc6
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/LeaseRequestDtoFromHttpRequestMapper.cs
@@ -0,0 +1,14 @@
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public class LeaseRequestDtoFromHttpRequestMapper : ILeaseRequestDtoFromHttpRequestMapper {
+ public SubmitLeaseRequestDTO MapFrom( IHttpRequest input ) {
+ return new SubmitLeaseRequestDTO(
+ input.ParsePayloadFor( PayloadKeys.CustomerId ),
+ input.ParsePayloadFor( PayloadKeys.SlipId ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxLeaseDuration" ) )
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/LoginCredentialsMapper.cs b/slips/src/app/Marina/Presentation/Mappers/LoginCredentialsMapper.cs
new file mode 100644
index 0000000..9e13c13
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/LoginCredentialsMapper.cs
@@ -0,0 +1,13 @@
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public class LoginCredentialsMapper : ILoginCredentialsMapper {
+ public LoginCredentialsDTO MapFrom( IHttpRequest input ) {
+ return new LoginCredentialsDTO(
+ input.ParsePayloadFor( PayloadKeys.For( "uxUserNameTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxPasswordTextBox" ) )
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/NewBoatRegistrationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/NewBoatRegistrationMapper.cs
new file mode 100644
index 0000000..d815e6d
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/NewBoatRegistrationMapper.cs
@@ -0,0 +1,16 @@
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public class NewBoatRegistrationMapper : INewBoatRegistrationMapper {
+ public BoatRegistrationDTO MapFrom( IHttpRequest input ) {
+ return new BoatRegistrationDTO(
+ input.ParsePayloadFor( PayloadKeys.For( "uxRegistrationNumberTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxManufacturerTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxModelYearTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxLengthTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.CustomerId )
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Mappers/UpdateRegistrationPresentationMapper.cs b/slips/src/app/Marina/Presentation/Mappers/UpdateRegistrationPresentationMapper.cs
new file mode 100644
index 0000000..814fde5
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Mappers/UpdateRegistrationPresentationMapper.cs
@@ -0,0 +1,18 @@
+using Marina.Presentation.DTO;
+using Marina.Web;
+
+namespace Marina.Presentation.Mappers {
+ public class UpdateRegistrationPresentationMapper : IUpdateRegistrationPresentationMapper {
+ public UpdateCustomerRegistrationDTO MapFrom( IHttpRequest input ) {
+ return new UpdateCustomerRegistrationDTO(
+ input.ParsePayloadFor( PayloadKeys.CustomerId ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxUserNameTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxPasswordTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxFirstNameTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxLastNameTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxPhoneNumberTextBox" ) ),
+ input.ParsePayloadFor( PayloadKeys.For( "uxCityTextBox" ) )
+ );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/PayLoadKeys.cs b/slips/src/app/Marina/Presentation/PayLoadKeys.cs
new file mode 100644
index 0000000..6d91a96
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/PayLoadKeys.cs
@@ -0,0 +1,12 @@
+namespace Marina.Presentation {
+ public class PayloadKeys {
+ public static PayloadKey< long > DockId = new PayloadKey< long >( "DID" );
+ public static PayloadKey< long > LocationId = new PayloadKey< long >( "LID" );
+ public static PayloadKey< long > CustomerId = new PayloadKey< long >( "CID" );
+ public static PayloadKey< long > SlipId = new PayloadKey< long >( "SID" );
+
+ public static PayloadKey< string > For( string controlId ) {
+ return new PayloadKey< string >( controlId );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/PayloadKey.cs b/slips/src/app/Marina/Presentation/PayloadKey.cs
new file mode 100644
index 0000000..d4b31fb
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/PayloadKey.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Specialized;
+
+namespace Marina.Presentation
+{
+ public class PayloadKey< T > : IEquatable< PayloadKey< T > >
+ {
+ private readonly string _key;
+
+ public PayloadKey( string key )
+ {
+ _key = key;
+ }
+
+ public T ParseFrom( NameValueCollection payload )
+ {
+ EnsureKeyIsInPayload( payload );
+ return ( T )Convert.ChangeType( payload[ _key ], typeof( T ) );
+ }
+
+ private void EnsureKeyIsInPayload( NameValueCollection payload )
+ {
+ if( null == payload[ _key ] ) {
+ throw new PayloadKeyNotFoundException( _key );
+ }
+ }
+
+ public static implicit operator string( PayloadKey< T > item )
+ {
+ return item._key;
+ }
+
+ public bool Equals( PayloadKey< T > payloadKey )
+ {
+ return payloadKey != null && Equals( _key, payloadKey._key );
+ }
+
+ public override bool Equals( object obj )
+ {
+ return ReferenceEquals( this, obj ) || Equals( obj as PayloadKey< T > );
+ }
+
+ public override int GetHashCode( )
+ {
+ return _key.GetHashCode( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/PayloadKeyNotFoundException.cs b/slips/src/app/Marina/Presentation/PayloadKeyNotFoundException.cs
new file mode 100644
index 0000000..5cf4279
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/PayloadKeyNotFoundException.cs
@@ -0,0 +1,7 @@
+using System;
+
+namespace Marina.Presentation {
+ public class PayloadKeyNotFoundException : Exception {
+ public PayloadKeyNotFoundException( string key ) : base( "The payload key could not be found: " + key ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/AvailableSlipsPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/AvailableSlipsPresenter.cs
new file mode 100644
index 0000000..9dbe7f5
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/AvailableSlipsPresenter.cs
@@ -0,0 +1,25 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Views;
+using Marina.Task;
+
+namespace Marina.Presentation.Presenters {
+ public class AvailableSlipsPresenter : IAvailableSlipsPresenter {
+ private readonly IAvailableSlipsView view;
+ private readonly ICatalogTasks task;
+
+ public AvailableSlipsPresenter( IAvailableSlipsView view )
+ : this(
+ view,
+ Resolve.DependencyFor< ICatalogTasks >( )
+ ) {}
+
+ public AvailableSlipsPresenter( IAvailableSlipsView view, ICatalogTasks task ) {
+ this.view = view;
+ this.task = task;
+ }
+
+ public void Initialize() {
+ view.Display( task.GetAllAvailableSlips( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/CurrentLeasesPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/CurrentLeasesPresenter.cs
new file mode 100644
index 0000000..7f80cc4
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/CurrentLeasesPresenter.cs
@@ -0,0 +1,25 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class CurrentLeasesPresenter : ICurrentLeasesPresenter {
+ public CurrentLeasesPresenter( ICurrentLeasesView view )
+ : this( view, Resolve.DependencyFor< IHttpRequest >( ), Resolve.DependencyFor< ILeaseTasks >( ) ) {}
+
+ public CurrentLeasesPresenter( ICurrentLeasesView view, IHttpRequest request, ILeaseTasks task ) {
+ _view = view;
+ _request = request;
+ _task = task;
+ }
+
+ public void Initialize() {
+ _view.Display( _task.FindAllLeasesFor( _request.ParsePayloadFor( PayloadKeys.CustomerId ) ) );
+ }
+
+ private readonly ICurrentLeasesView _view;
+ private readonly IHttpRequest _request;
+ private readonly ILeaseTasks _task;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/CustomerRegistrationPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/CustomerRegistrationPresenter.cs
new file mode 100644
index 0000000..ea9ff8d
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/CustomerRegistrationPresenter.cs
@@ -0,0 +1,30 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Mappers;
+using Marina.Presentation.Views;
+using Marina.Task;
+
+namespace Marina.Presentation.Presenters {
+ public class CustomerRegistrationPresenter : ICustomerRegistrationPresenter {
+ private readonly ICustomerRegistrationView _view;
+ private readonly ICustomerRegistrationPresentationMapper _mapper;
+ private readonly IRegistrationTasks _task;
+
+ public CustomerRegistrationPresenter( ICustomerRegistrationView view ) : this(
+ view,
+ Resolve.DependencyFor< ICustomerRegistrationPresentationMapper >( ),
+ Resolve.DependencyFor< IRegistrationTasks >( )
+ ) {}
+
+ public CustomerRegistrationPresenter( ICustomerRegistrationView view,
+ ICustomerRegistrationPresentationMapper mapper,
+ IRegistrationTasks task ) {
+ _view = view;
+ _mapper = mapper;
+ _task = task;
+ }
+
+ public void RegisterCustomer( ) {
+ _view.Display( _task.RegisterNew( _mapper.MapFrom( _view ) ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/DockPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/DockPresenter.cs
new file mode 100644
index 0000000..4eb9402
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/DockPresenter.cs
@@ -0,0 +1,31 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class DockPresenter : IDockPresenter {
+ public DockPresenter( IDockView view )
+ : this(
+ view,
+ Resolve.DependencyFor< IHttpRequest >( ),
+ Resolve.DependencyFor< ICatalogTasks >( )
+ ) {}
+
+ public DockPresenter( IDockView view, IHttpRequest request, ICatalogTasks task ) {
+ _request = request;
+ _view = view;
+ _task = task;
+ }
+
+ public void Initialize() {
+ long dockId = _request.ParsePayloadFor( PayloadKeys.DockId );
+ _view.Display( _task.GetDockInformationBy( dockId ) );
+ _view.Display( _task.GetAvailableSlipsForDockBy( dockId ) );
+ }
+
+ private readonly IDockView _view;
+ private readonly ICatalogTasks _task;
+ private readonly IHttpRequest _request;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/IAvailableSlipsPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/IAvailableSlipsPresenter.cs
new file mode 100644
index 0000000..38d4dd3
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/IAvailableSlipsPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface IAvailableSlipsPresenter {
+ void Initialize( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/ICurrentLeasesPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/ICurrentLeasesPresenter.cs
new file mode 100644
index 0000000..e5c0efb
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/ICurrentLeasesPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface ICurrentLeasesPresenter {
+ void Initialize();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/ICustomerRegistrationPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/ICustomerRegistrationPresenter.cs
new file mode 100644
index 0000000..7089c7f
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/ICustomerRegistrationPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface ICustomerRegistrationPresenter {
+ void RegisterCustomer( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/IDockPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/IDockPresenter.cs
new file mode 100644
index 0000000..fb250d2
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/IDockPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface IDockPresenter {
+ void Initialize( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/ILeaseSlipPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/ILeaseSlipPresenter.cs
new file mode 100644
index 0000000..4908743
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/ILeaseSlipPresenter.cs
@@ -0,0 +1,7 @@
+namespace Marina.Presentation.Presenters {
+ public interface ILeaseSlipPresenter {
+ void Initialize();
+
+ void SubmitLeaseRequest();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/ILoginPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/ILoginPresenter.cs
new file mode 100644
index 0000000..554ef98
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/ILoginPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface ILoginPresenter {
+ void Login( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/IRegisterBoatPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/IRegisterBoatPresenter.cs
new file mode 100644
index 0000000..37f558f
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/IRegisterBoatPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface IRegisterBoatPresenter {
+ void SubmitRegistration( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/IUpdateCustomerRegistrationPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/IUpdateCustomerRegistrationPresenter.cs
new file mode 100644
index 0000000..f74171c
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/IUpdateCustomerRegistrationPresenter.cs
@@ -0,0 +1,7 @@
+namespace Marina.Presentation.Presenters {
+ public interface IUpdateCustomerRegistrationPresenter {
+ void Initialize( );
+
+ void UpdateRegistration( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/IViewRegisteredBoatsPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/IViewRegisteredBoatsPresenter.cs
new file mode 100644
index 0000000..4bee850
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/IViewRegisteredBoatsPresenter.cs
@@ -0,0 +1,5 @@
+namespace Marina.Presentation.Presenters {
+ public interface IViewRegisteredBoatsPresenter {
+ void Initialize();
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/LeaseSlipPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/LeaseSlipPresenter.cs
new file mode 100644
index 0000000..e24441c
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/LeaseSlipPresenter.cs
@@ -0,0 +1,41 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Mappers;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class LeaseSlipPresenter : ILeaseSlipPresenter {
+ public LeaseSlipPresenter( ILeaseSlipView view )
+ : this(
+ view,
+ Resolve.DependencyFor< IHttpRequest >( ),
+ Resolve.DependencyFor< ICatalogTasks >( ),
+ Resolve.DependencyFor< ILeaseTasks >( ),
+ Resolve.DependencyFor< ILeaseRequestDtoFromHttpRequestMapper >( )
+ ) {}
+
+ public LeaseSlipPresenter( ILeaseSlipView view, IHttpRequest request, ICatalogTasks task, ILeaseTasks leaseTask,
+ ILeaseRequestDtoFromHttpRequestMapper mapper ) {
+ _view = view;
+ _request = request;
+ _task = task;
+ _leaseTask = leaseTask;
+ _mapper = mapper;
+ }
+
+ public void Initialize() {
+ _view.Display( _task.FindSlipBy( _request.ParsePayloadFor( PayloadKeys.SlipId ) ) );
+ }
+
+ public void SubmitLeaseRequest() {
+ _view.Display( _leaseTask.RequestLeaseUsing( _mapper.MapFrom( _request ) ) );
+ }
+
+ private readonly ILeaseSlipView _view;
+ private readonly IHttpRequest _request;
+ private readonly ICatalogTasks _task;
+ private readonly ILeaseTasks _leaseTask;
+ private readonly ILeaseRequestDtoFromHttpRequestMapper _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/LoginPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/LoginPresenter.cs
new file mode 100644
index 0000000..94ae726
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/LoginPresenter.cs
@@ -0,0 +1,34 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Mappers;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class LoginPresenter : ILoginPresenter {
+ public LoginPresenter( ILoginView view )
+ : this(
+ view,
+ Resolve.DependencyFor< IHttpRequest >( ),
+ Resolve.DependencyFor< IAuthenticationTask >( ),
+ Resolve.DependencyFor< ILoginCredentialsMapper >( )
+ ) {}
+
+ public LoginPresenter( ILoginView view, IHttpRequest request, IAuthenticationTask task,
+ ILoginCredentialsMapper mapper ) {
+ _view = view;
+ _request = request;
+ _task = task;
+ _mapper = mapper;
+ }
+
+ public void Login() {
+ _view.Display( _task.AuthenticateUserUsing( _mapper.MapFrom( _request ) ) );
+ }
+
+ private readonly ILoginView _view;
+ private readonly IHttpRequest _request;
+ private readonly IAuthenticationTask _task;
+ private readonly ILoginCredentialsMapper _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/RegisterBoatPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/RegisterBoatPresenter.cs
new file mode 100644
index 0000000..693c1ff
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/RegisterBoatPresenter.cs
@@ -0,0 +1,33 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Mappers;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class RegisterBoatPresenter : IRegisterBoatPresenter {
+ public RegisterBoatPresenter( IRegisterBoatView view )
+ : this( view,
+ Resolve.DependencyFor< IHttpRequest >( ),
+ Resolve.DependencyFor< IRegistrationTasks >( ),
+ Resolve.DependencyFor< INewBoatRegistrationMapper >( )
+ ) {}
+
+ public RegisterBoatPresenter( IRegisterBoatView view, IHttpRequest request, IRegistrationTasks task,
+ INewBoatRegistrationMapper mapper ) {
+ _view = view;
+ _request = request;
+ _task = task;
+ _mapper = mapper;
+ }
+
+ public void SubmitRegistration() {
+ _view.Display( _task.AddNewBoatUsing( _mapper.MapFrom( _request ) ) );
+ }
+
+ private readonly IRegisterBoatView _view;
+ private readonly IHttpRequest _request;
+ private readonly IRegistrationTasks _task;
+ private readonly INewBoatRegistrationMapper _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/UpdateCustomerRegistrationPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/UpdateCustomerRegistrationPresenter.cs
new file mode 100644
index 0000000..8a4047f
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/UpdateCustomerRegistrationPresenter.cs
@@ -0,0 +1,44 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Mappers;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class UpdateCustomerRegistrationPresenter : IUpdateCustomerRegistrationPresenter {
+ public UpdateCustomerRegistrationPresenter( IUpdateRegistrationView view ) :
+ this(
+ view,
+ Resolve.DependencyFor< IHttpRequest >( ),
+ Resolve.DependencyFor< IRegistrationTasks >( ),
+ Resolve.DependencyFor< IUpdateRegistrationPresentationMapper >( )
+ ) {}
+
+ public UpdateCustomerRegistrationPresenter( IUpdateRegistrationView view, IHttpRequest request,
+ IRegistrationTasks task,
+ IUpdateRegistrationPresentationMapper mapper ) {
+ _request = request;
+ _view = view;
+ _task = task;
+ _mapper = mapper;
+ }
+
+ public void Initialize() {
+ _view.Display( _task.LoadRegistrationFor( CustomerId( ) ) );
+ }
+
+ public void UpdateRegistration() {
+ _view.Display( _task.UpdateRegistrationFor( _mapper.MapFrom( _request ) ) );
+ Initialize( );
+ }
+
+ private long CustomerId() {
+ return _request.ParsePayloadFor( PayloadKeys.CustomerId );
+ }
+
+ private readonly IUpdateRegistrationView _view;
+ private readonly IRegistrationTasks _task;
+ private readonly IUpdateRegistrationPresentationMapper _mapper;
+ private readonly IHttpRequest _request;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Presenters/ViewRegisteredBoatsPresenter.cs b/slips/src/app/Marina/Presentation/Presenters/ViewRegisteredBoatsPresenter.cs
new file mode 100644
index 0000000..6728c01
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Presenters/ViewRegisteredBoatsPresenter.cs
@@ -0,0 +1,25 @@
+using Marina.Infrastructure.Container;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+
+namespace Marina.Presentation.Presenters {
+ public class ViewRegisteredBoatsPresenter : IViewRegisteredBoatsPresenter {
+ public ViewRegisteredBoatsPresenter( IRegisteredBoatsView view )
+ : this( view, Resolve.DependencyFor< IRegistrationTasks >( ), Resolve.DependencyFor< IHttpRequest >( ) ) {}
+
+ public ViewRegisteredBoatsPresenter( IRegisteredBoatsView view, IRegistrationTasks task, IHttpRequest request ) {
+ _view = view;
+ _task = task;
+ _request = request;
+ }
+
+ public void Initialize() {
+ _view.Display( _task.AllBoatsFor( _request.ParsePayloadFor( PayloadKeys.CustomerId ) ) );
+ }
+
+ private readonly IRegisteredBoatsView _view;
+ private readonly IRegistrationTasks _task;
+ private readonly IHttpRequest _request;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/IAvailableSlipsView.cs b/slips/src/app/Marina/Presentation/Views/IAvailableSlipsView.cs
new file mode 100644
index 0000000..c421e91
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/IAvailableSlipsView.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface IAvailableSlipsView {
+ void Display( IEnumerable< SlipDisplayDTO > availableSlips );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/ICurrentLeasesView.cs b/slips/src/app/Marina/Presentation/Views/ICurrentLeasesView.cs
new file mode 100644
index 0000000..682dfe5
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/ICurrentLeasesView.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface ICurrentLeasesView {
+ void Display( IEnumerable< DisplayLeaseDTO > leases );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/ICustomerRegistrationView.cs b/slips/src/app/Marina/Presentation/Views/ICustomerRegistrationView.cs
new file mode 100644
index 0000000..be50275
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/ICustomerRegistrationView.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface ICustomerRegistrationView {
+ string UserName( );
+
+ string Password( );
+
+ string FirstName( );
+
+ string LastName( );
+
+ string PhoneNumber( );
+
+ string City( );
+
+ void Display( IEnumerable< DisplayResponseLineDTO > response );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/IDockView.cs b/slips/src/app/Marina/Presentation/Views/IDockView.cs
new file mode 100644
index 0000000..975248c
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/IDockView.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface IDockView {
+ void Display( DockDisplayDTO dto );
+ void Display( IEnumerable< SlipDisplayDTO > availableSlips );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/ILeaseSlipView.cs b/slips/src/app/Marina/Presentation/Views/ILeaseSlipView.cs
new file mode 100644
index 0000000..2751a54
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/ILeaseSlipView.cs
@@ -0,0 +1,9 @@
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface ILeaseSlipView {
+ void Display( SlipDisplayDTO slip );
+
+ void Display( DisplayResponseLineDTO response );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/ILoginView.cs b/slips/src/app/Marina/Presentation/Views/ILoginView.cs
new file mode 100644
index 0000000..b5d7c8f
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/ILoginView.cs
@@ -0,0 +1,7 @@
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface ILoginView {
+ void Display( DisplayResponseLineDTO responseMessage );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/IRegisterBoatView.cs b/slips/src/app/Marina/Presentation/Views/IRegisterBoatView.cs
new file mode 100644
index 0000000..42559b7
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/IRegisterBoatView.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface IRegisterBoatView {
+ void Display( IEnumerable< DisplayResponseLineDTO > response );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/IRegisteredBoatsView.cs b/slips/src/app/Marina/Presentation/Views/IRegisteredBoatsView.cs
new file mode 100644
index 0000000..9162695
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/IRegisteredBoatsView.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface IRegisteredBoatsView {
+ void Display( IEnumerable< BoatRegistrationDTO > boats );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Presentation/Views/IUpdateRegistrationView.cs b/slips/src/app/Marina/Presentation/Views/IUpdateRegistrationView.cs
new file mode 100644
index 0000000..8474113
--- /dev/null
+++ b/slips/src/app/Marina/Presentation/Views/IUpdateRegistrationView.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Presentation.Views {
+ public interface IUpdateRegistrationView {
+ void Display( CustomerRegistrationDisplayDTO customerRegistration );
+ void Display( IEnumerable< DisplayResponseLineDTO > response );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Properties/AssemblyInfo.cs b/slips/src/app/Marina/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f9b9f7f
--- /dev/null
+++ b/slips/src/app/Marina/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("Marina")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Marina")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[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("997b23e8-9d54-4169-a5a3-ace0266a1964")]
+
+// 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")]
diff --git a/slips/src/app/Marina/Task/ApplicationStartupTask.cs b/slips/src/app/Marina/Task/ApplicationStartupTask.cs
new file mode 100644
index 0000000..e55eccf
--- /dev/null
+++ b/slips/src/app/Marina/Task/ApplicationStartupTask.cs
@@ -0,0 +1,14 @@
+using Marina.Infrastructure.Container;
+using Marina.Infrastructure.Container.Windsor;
+
+namespace Marina.Task {
+ public class ApplicationStartupTask : IApplicationStartupTask {
+ public static void ApplicationBegin( ) {
+ new ApplicationStartupTask( ).Execute( );
+ }
+
+ public void Execute( ) {
+ Resolve.InitializeWith( new WindsorDependencyContainer( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/AuthenticationTask.cs b/slips/src/app/Marina/Task/AuthenticationTask.cs
new file mode 100644
index 0000000..75424a9
--- /dev/null
+++ b/slips/src/app/Marina/Task/AuthenticationTask.cs
@@ -0,0 +1,41 @@
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Presentation.DTO;
+using Marina.Web.Http;
+
+namespace Marina.Task {
+ public class AuthenticationTask : IAuthenticationTask {
+ public AuthenticationTask( ICustomerRepository customers, IHttpGateway gateway ) {
+ _customers = customers;
+ _gateway = gateway;
+ }
+
+ public DisplayResponseLineDTO AuthenticateUserUsing( LoginCredentialsDTO credentials ) {
+ if ( CheckIfPasswordMatches( credentials, _customers.FindBy( credentials.Username ) ) ) {
+ _gateway.AddAuthenticationCookieFor( credentials.Username, _customers.FindBy( credentials.Username ).ID( ) );
+ return ValidCredentialsMessage( credentials.Username );
+ }
+ else {
+ return InvalidCredentialsMessage( );
+ }
+ }
+
+ private static DisplayResponseLineDTO ValidCredentialsMessage( string username ) {
+ return new DisplayResponseLineDTO( string.Format( "Currently logged in as {0}", username ) );
+ }
+
+ private static DisplayResponseLineDTO InvalidCredentialsMessage() {
+ return new DisplayResponseLineDTO( "Invalid credentials specified" );
+ }
+
+ private static bool CheckIfPasswordMatches( LoginCredentialsDTO credentials, ICustomer customer ) {
+ if ( customer != null && customer.Registration( ) != null ) {
+ return customer.Registration( ).Password( ).Equals( credentials.Password );
+ }
+ return false;
+ }
+
+ private readonly ICustomerRepository _customers;
+ private readonly IHttpGateway _gateway;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/CatalogTasks.cs b/slips/src/app/Marina/Task/CatalogTasks.cs
new file mode 100644
index 0000000..e3c18a2
--- /dev/null
+++ b/slips/src/app/Marina/Task/CatalogTasks.cs
@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task.Mappers;
+
+namespace Marina.Task {
+ public class CatalogTasks : ICatalogTasks {
+ public CatalogTasks()
+ : this(
+ Resolve.DependencyFor< ISlipsRepository >( ),
+ Resolve.DependencyFor< ISlipsToDisplayDTOMapper >( ),
+ Resolve.DependencyFor< IDockRepository >( ),
+ Resolve.DependencyFor< IDockToDisplayDTOMapper >( )
+ ) {}
+
+ public CatalogTasks( ISlipsRepository slipRepository, ISlipsToDisplayDTOMapper slipMapper,
+ IDockRepository dockRepository, IDockToDisplayDTOMapper dockMapper ) {
+ _slips = slipRepository;
+ _slipMapper = slipMapper;
+ _docks = dockRepository;
+ _dockMapper = dockMapper;
+ }
+
+ public IEnumerable< SlipDisplayDTO > GetAvailableSlipsForDockBy( long dockId ) {
+ IDock dock = _docks.FindBy( dockId );
+ foreach ( ISlip slip in _slips.AllAvailableSlipsFor( dock ) ) {
+ yield return _slipMapper.MapFrom( slip );
+ }
+ }
+
+ public DockDisplayDTO GetDockInformationBy( long dockId ) {
+ return _dockMapper.MapFrom( _docks.FindBy( dockId ) );
+ }
+
+ public IEnumerable< SlipDisplayDTO > GetAllAvailableSlips() {
+ foreach ( ISlip availableSlip in _slips.AllAvailableSlips( ) ) {
+ yield return _slipMapper.MapFrom( availableSlip );
+ }
+ }
+
+ public SlipDisplayDTO FindSlipBy( long slipId ) {
+ return _slipMapper.MapFrom( _slips.FindBy( slipId ) );
+ }
+
+ private readonly ISlipsRepository _slips;
+ private readonly ISlipsToDisplayDTOMapper _slipMapper;
+ private readonly IDockRepository _docks;
+ private readonly IDockToDisplayDTOMapper _dockMapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/IApplicationStartupTask.cs b/slips/src/app/Marina/Task/IApplicationStartupTask.cs
new file mode 100644
index 0000000..8fcdf6e
--- /dev/null
+++ b/slips/src/app/Marina/Task/IApplicationStartupTask.cs
@@ -0,0 +1,5 @@
+namespace Marina.Task {
+ public interface IApplicationStartupTask {
+ void Execute( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/IAuthenticationTask.cs b/slips/src/app/Marina/Task/IAuthenticationTask.cs
new file mode 100644
index 0000000..9072578
--- /dev/null
+++ b/slips/src/app/Marina/Task/IAuthenticationTask.cs
@@ -0,0 +1,7 @@
+using Marina.Presentation.DTO;
+
+namespace Marina.Task {
+ public interface IAuthenticationTask {
+ DisplayResponseLineDTO AuthenticateUserUsing( LoginCredentialsDTO credentials );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/ICatalogTasks.cs b/slips/src/app/Marina/Task/ICatalogTasks.cs
new file mode 100644
index 0000000..5d438a2
--- /dev/null
+++ b/slips/src/app/Marina/Task/ICatalogTasks.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task {
+ public interface ICatalogTasks {
+ IEnumerable< SlipDisplayDTO > GetAvailableSlipsForDockBy( long dockId );
+
+ DockDisplayDTO GetDockInformationBy( long dockId );
+
+ IEnumerable< SlipDisplayDTO > GetAllAvailableSlips();
+
+ SlipDisplayDTO FindSlipBy( long slipId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/ILeaseTasks.cs b/slips/src/app/Marina/Task/ILeaseTasks.cs
new file mode 100644
index 0000000..f781a29
--- /dev/null
+++ b/slips/src/app/Marina/Task/ILeaseTasks.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task {
+ public interface ILeaseTasks {
+ IEnumerable< DisplayLeaseDTO > FindAllLeasesFor( long customerId );
+
+ DisplayResponseLineDTO RequestLeaseUsing( SubmitLeaseRequestDTO request );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/IRegistrationTasks.cs b/slips/src/app/Marina/Task/IRegistrationTasks.cs
new file mode 100644
index 0000000..97974b3
--- /dev/null
+++ b/slips/src/app/Marina/Task/IRegistrationTasks.cs
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task {
+ public interface IRegistrationTasks {
+ IEnumerable< DisplayResponseLineDTO > RegisterNew( RegisterCustomerDTO customer );
+
+ IEnumerable< DisplayResponseLineDTO > AddNewBoatUsing( BoatRegistrationDTO boat );
+
+ CustomerRegistrationDisplayDTO LoadRegistrationFor( long customerId );
+
+ IEnumerable< DisplayResponseLineDTO > UpdateRegistrationFor( UpdateCustomerRegistrationDTO registration );
+
+ IEnumerable< BoatRegistrationDTO > AllBoatsFor( long customerId );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/LeaseTasks.cs b/slips/src/app/Marina/Task/LeaseTasks.cs
new file mode 100644
index 0000000..1dfb592
--- /dev/null
+++ b/slips/src/app/Marina/Task/LeaseTasks.cs
@@ -0,0 +1,39 @@
+using System.Collections.Generic;
+using Marina.Domain;
+using Marina.Domain.Exceptions;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Task.Mappers;
+
+namespace Marina.Task {
+ public class LeaseTasks : ILeaseTasks {
+ public LeaseTasks( ICustomerRepository customers, ISlipsRepository slips, ILeaseToDtoMapper mapper ) {
+ _customers = customers;
+ _slips = slips;
+ _mapper = mapper;
+ }
+
+ public IEnumerable< DisplayLeaseDTO > FindAllLeasesFor( long customerId ) {
+ return new EnumerableMapper< ISlipLease, DisplayLeaseDTO >( _mapper )
+ .MapFrom( _customers.FindBy( customerId ).Leases( ) );
+ }
+
+ public DisplayResponseLineDTO RequestLeaseUsing( SubmitLeaseRequestDTO request ) {
+ ICustomer customer = _customers.FindBy( request.CustomerId );
+ try {
+ customer.Lease( _slips.FindBy( request.SlipId ), LeaseDurations.FindBy( request.Duration ) );
+ _customers.Save( customer );
+ return new DisplayResponseLineDTO( "Success!" );
+ }
+ catch ( SlipIsAlreadyLeasedException ) {
+ return new DisplayResponseLineDTO( "Slip is already leased!" );
+ }
+ }
+
+ private readonly ICustomerRepository _customers;
+ private readonly ISlipsRepository _slips;
+ private readonly ILeaseToDtoMapper _mapper;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/BrokenRulesToDisplayItemMapper.cs b/slips/src/app/Marina/Task/Mappers/BrokenRulesToDisplayItemMapper.cs
new file mode 100644
index 0000000..5a9aee6
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/BrokenRulesToDisplayItemMapper.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public class BrokenRulesToDisplayItemMapper : IBrokenRulesToDisplayItemMapper {
+ public IEnumerable< DisplayResponseLineDTO > MapFrom( IEnumerable< IBrokenRule > input ) {
+ foreach ( IBrokenRule brokenRule in input ) {
+ yield return new DisplayResponseLineDTO( brokenRule.Message( ) );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/DockToDisplayDTOMapper.cs b/slips/src/app/Marina/Task/Mappers/DockToDisplayDTOMapper.cs
new file mode 100644
index 0000000..89ef037
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/DockToDisplayDTOMapper.cs
@@ -0,0 +1,16 @@
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public class DockToDisplayDTOMapper : IDockToDisplayDTOMapper {
+ public DockDisplayDTO MapFrom( IDock input ) {
+ return
+ new DockDisplayDTO(
+ input.Name( ),
+ input.Location( ).Name( ),
+ input.IsUtilityEnabled( Utilities.Water ).ToString( ),
+ input.IsUtilityEnabled( Utilities.Electrical ).ToString( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/IBrokenRulesToDisplayItemMapper.cs b/slips/src/app/Marina/Task/Mappers/IBrokenRulesToDisplayItemMapper.cs
new file mode 100644
index 0000000..1af9300
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/IBrokenRulesToDisplayItemMapper.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public interface IBrokenRulesToDisplayItemMapper :
+ IMapper< IEnumerable< IBrokenRule >, IEnumerable< DisplayResponseLineDTO > > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/IDockToDisplayDTOMapper.cs b/slips/src/app/Marina/Task/Mappers/IDockToDisplayDTOMapper.cs
new file mode 100644
index 0000000..264a92a
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/IDockToDisplayDTOMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public interface IDockToDisplayDTOMapper : IMapper< IDock, DockDisplayDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/ILeaseToDtoMapper.cs b/slips/src/app/Marina/Task/Mappers/ILeaseToDtoMapper.cs
new file mode 100644
index 0000000..473ed68
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/ILeaseToDtoMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public interface ILeaseToDtoMapper : IMapper< ISlipLease, DisplayLeaseDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/ISlipsToDisplayDTOMapper.cs b/slips/src/app/Marina/Task/Mappers/ISlipsToDisplayDTOMapper.cs
new file mode 100644
index 0000000..95f97ba
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/ISlipsToDisplayDTOMapper.cs
@@ -0,0 +1,7 @@
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public interface ISlipsToDisplayDTOMapper : IMapper< ISlip, SlipDisplayDTO > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/LeaseToDtoMapper.cs b/slips/src/app/Marina/Task/Mappers/LeaseToDtoMapper.cs
new file mode 100644
index 0000000..a776f52
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/LeaseToDtoMapper.cs
@@ -0,0 +1,12 @@
+using Marina.Domain.Interfaces;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public class LeaseToDtoMapper : ILeaseToDtoMapper {
+ public DisplayLeaseDTO MapFrom( ISlipLease input ) {
+ return new DisplayLeaseDTO( input.Slip( ).ID( ).ToString( ),
+ input.StartDate( ).ToString( ),
+ input.ExpiryDate( ).ToString( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/Mappers/SlipsToDisplayDTOMapper.cs b/slips/src/app/Marina/Task/Mappers/SlipsToDisplayDTOMapper.cs
new file mode 100644
index 0000000..c5ba592
--- /dev/null
+++ b/slips/src/app/Marina/Task/Mappers/SlipsToDisplayDTOMapper.cs
@@ -0,0 +1,16 @@
+using Marina.Domain.Interfaces;
+using Marina.Presentation.DTO;
+
+namespace Marina.Task.Mappers {
+ public class SlipsToDisplayDTOMapper : ISlipsToDisplayDTOMapper {
+ public SlipDisplayDTO MapFrom( ISlip input ) {
+ return
+ new SlipDisplayDTO( input.Dock( ).ID( ).ToString( ),
+ input.Dock( ).Name( ),
+ input.Width( ).ToString( ),
+ input.Length( ).ToString( ),
+ input.Location( ).Name( ),
+ input.ID( ).ToString( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Task/RegistrationTasks.cs b/slips/src/app/Marina/Task/RegistrationTasks.cs
new file mode 100644
index 0000000..44c60ee
--- /dev/null
+++ b/slips/src/app/Marina/Task/RegistrationTasks.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using Marina.Domain.Interfaces;
+using Marina.Domain.Repositories;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task.Mappers;
+
+namespace Marina.Task {
+ public class RegistrationTasks : IRegistrationTasks {
+ public RegistrationTasks()
+ : this(
+ Resolve.DependencyFor< IBrokenRulesToDisplayItemMapper >( ),
+ Resolve.DependencyFor< ICustomerRepository >( )
+ ) {}
+
+ public RegistrationTasks( IBrokenRulesToDisplayItemMapper mapper, ICustomerRepository customers ) {
+ _mapper = mapper;
+ _customers = customers;
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > RegisterNew( RegisterCustomerDTO customer ) {
+ if ( null == _customers.FindBy( customer.UserName ) ) {
+ ICustomer newCustomer = _customers.NewCustomer( );
+ newCustomer.RegisterAccount( customer.UserName,
+ customer.Password,
+ customer.FirstName,
+ customer.LastName,
+ customer.Phone,
+ customer.City );
+ if ( !newCustomer.Registration( ).IsValid( ) ) {
+ return _mapper.MapFrom( newCustomer.Registration( ).BrokenRules( ) );
+ }
+ else {
+ _customers.Save( newCustomer );
+ return new DisplayResponseLines( "Success!" );
+ }
+ }
+ else {
+ return
+ new DisplayResponseLines(
+ string.Format( "The username {0} is already taken. Please try another!", customer.UserName ) );
+ }
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > AddNewBoatUsing( BoatRegistrationDTO boat ) {
+ ICustomer customer = _customers.FindBy( boat.CustomerId );
+ customer.RegisterBoat( boat.RegistrationNumber,
+ boat.Manufacturer,
+ new DateTime( Convert.ToInt32( boat.ModelYear ), 1, 1 ),
+ Convert.ToInt64( boat.Length ) );
+ _customers.Save( customer );
+ return new DisplayResponseLines( "Success!" );
+ }
+
+ public CustomerRegistrationDisplayDTO LoadRegistrationFor( long customerId ) {
+ IRegistration registration = _customers.FindBy( customerId ).Registration( );
+ return
+ new CustomerRegistrationDisplayDTO( customerId.ToString( ),
+ registration.Username( ),
+ registration.FirstName( ),
+ registration.LastName( ),
+ registration.PhoneNumber( ),
+ registration.City( )
+ );
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > UpdateRegistrationFor( UpdateCustomerRegistrationDTO registration ) {
+ ICustomer customer = _customers.FindBy( registration.CustomerId );
+
+ customer.UpdateRegistrationTo( registration.Username, registration.Password, registration.FirstName,
+ registration.LastName, registration.PhoneNumber, registration.City );
+ if ( customer.Registration( ).IsValid( ) ) {
+ _customers.Save( customer );
+ }
+ return _mapper.MapFrom( customer.Registration( ).BrokenRules( ) );
+ }
+
+ public IEnumerable< BoatRegistrationDTO > AllBoatsFor( long customerId ) {
+ ICustomer customer = _customers.FindBy( customerId );
+
+ foreach ( IBoat boat in customer.RegisteredBoats( ) ) {
+ yield return
+ new BoatRegistrationDTO( boat.RegistrationNumber( ), boat.Manufacturer( ), boat.YearOfModel( ).ToString( ),
+ boat.LengthInFeet( ).ToString( ), customerId );
+ }
+ }
+
+ private readonly IBrokenRulesToDisplayItemMapper _mapper;
+ private readonly ICustomerRepository _customers;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/AuthenticationHttpModule.cs b/slips/src/app/Marina/Web/AuthenticationHttpModule.cs
new file mode 100644
index 0000000..c90c317
--- /dev/null
+++ b/slips/src/app/Marina/Web/AuthenticationHttpModule.cs
@@ -0,0 +1,28 @@
+using System.Security.Principal;
+using System.Web;
+using System.Web.Security;
+
+namespace Marina.Web {
+ public class AuthenticationHttpModule : IHttpModule {
+ public void Init( HttpApplication context ) {
+ context.AuthenticateRequest += delegate { AuthenticateHttpRequest( ); };
+ }
+
+ public void Dispose() {}
+
+ public void AuthenticateHttpRequest() {
+ HttpCookie cookie = GetCookieFrom( HttpContext.Current );
+ if ( null != cookie ) {
+ BindPrincipalToThreadUsing( FormsAuthentication.Decrypt( cookie.Value ).Name );
+ }
+ }
+
+ private HttpCookie GetCookieFrom( HttpContext context ) {
+ return context.Request.Cookies[ FormsAuthentication.FormsCookieName ];
+ }
+
+ private void BindPrincipalToThreadUsing( string username ) {
+ HttpContext.Current.User = new GenericPrincipal( new GenericIdentity( username ), new string[] {"Customer"} );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Commands/AvailableSlipsCommand.cs b/slips/src/app/Marina/Web/Commands/AvailableSlipsCommand.cs
new file mode 100644
index 0000000..4c14b14
--- /dev/null
+++ b/slips/src/app/Marina/Web/Commands/AvailableSlipsCommand.cs
@@ -0,0 +1,23 @@
+using Marina.Infrastructure;
+using Marina.Infrastructure.Container;
+using Marina.Task;
+using Marina.Web.Views.Pages;
+
+namespace Marina.Web.Commands {
+ public class AvailableSlipsCommand : ICommand {
+ public AvailableSlipsCommand() : this( new AvailableSlipsWebView( ), Resolve.DependencyFor< ICatalogTasks >( ) ) {}
+
+ public AvailableSlipsCommand( IAvailableSlipsWebView view, ICatalogTasks task ) {
+ _view = view;
+ _task = task;
+ }
+
+ public void Execute() {
+ _view.AddToBag( _task.GetAllAvailableSlips( ) );
+ _view.Render( );
+ }
+
+ private readonly IAvailableSlipsWebView _view;
+ private readonly ICatalogTasks _task;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Commands/CommandNames.cs b/slips/src/app/Marina/Web/Commands/CommandNames.cs
new file mode 100644
index 0000000..a676be7
--- /dev/null
+++ b/slips/src/app/Marina/Web/Commands/CommandNames.cs
@@ -0,0 +1,5 @@
+namespace Marina.Web.Commands {
+ public class CommandNames {
+ public const string AvailableSlips = "AvailableSlips.marina";
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Commands/RedirectCommand.cs b/slips/src/app/Marina/Web/Commands/RedirectCommand.cs
new file mode 100644
index 0000000..c87c423
--- /dev/null
+++ b/slips/src/app/Marina/Web/Commands/RedirectCommand.cs
@@ -0,0 +1,11 @@
+using Marina.Infrastructure;
+using Marina.Web.Views;
+
+namespace Marina.Web.Commands {
+ public class RedirectCommand : ICommand {
+ public void Execute() {
+ Redirect.To( WebViews.Login );
+ //throw new Exception( "Could not find a handler for request" );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/CurrentHttpContext.cs b/slips/src/app/Marina/Web/CurrentHttpContext.cs
new file mode 100644
index 0000000..8f3b959
--- /dev/null
+++ b/slips/src/app/Marina/Web/CurrentHttpContext.cs
@@ -0,0 +1,135 @@
+using System;
+using System.Collections;
+using System.Security.Principal;
+using System.Web;
+using System.Web.Caching;
+using System.Web.Profile;
+using System.Web.SessionState;
+
+namespace Marina.Web {
+ public class CurrentHttpContext : IHttpContext {
+ public void AddError( Exception errorInfo ) {
+ Current( ).AddError( errorInfo );
+ }
+
+ public void ClearError() {
+ Current( ).ClearError( );
+ }
+
+ public object GetSection( string sectionName ) {
+ return Current( ).GetSection( sectionName );
+ }
+
+ public void RewritePath( string path ) {
+ Current( ).RewritePath( path );
+ }
+
+ public void RewritePath( string path, bool rebaseClientPath ) {
+ Current( ).RewritePath( path, rebaseClientPath );
+ }
+
+ public void RewritePath( string filePath, string pathInfo, string queryString ) {
+ Current( ).RewritePath( filePath, pathInfo, queryString );
+ }
+
+ public void RewritePath( string filePath, string pathInfo, string queryString, bool setClientFilePath ) {
+ Current( ).RewritePath( filePath, pathInfo, queryString, setClientFilePath );
+ }
+
+ public HttpApplication ApplicationInstance {
+ get { return Current( ).ApplicationInstance; }
+ set { Current( ).ApplicationInstance = value; }
+ }
+
+ public HttpApplicationState Application {
+ get { return Current( ).Application; }
+ }
+
+ public IHttpHandler Handler {
+ get { return Current( ).Handler; }
+ set { Current( ).Handler = value; }
+ }
+
+ public IHttpHandler PreviousHandler {
+ get { return Current( ).PreviousHandler; }
+ }
+
+ public IHttpHandler CurrentHandler {
+ get { return Current( ).CurrentHandler; }
+ }
+
+ public HttpRequest Request {
+ get { return Current( ).Request; }
+ }
+
+ public HttpResponse Response {
+ get { return Current( ).Response; }
+ }
+
+ public TraceContext Trace {
+ get { return Current( ).Trace; }
+ }
+
+ public IDictionary Items {
+ get { return Current( ).Items; }
+ }
+
+ public HttpSessionState Session {
+ get { return Current( ).Session; }
+ }
+
+ public HttpServerUtility Server {
+ get { return Current( ).Server; }
+ }
+
+ public Exception Error {
+ get { return Current( ).Error; }
+ }
+
+ public Exception[] AllErrors {
+ get { return Current( ).AllErrors; }
+ }
+
+ public IPrincipal User {
+ get { return Current( ).User; }
+ set { Current( ).User = value; }
+ }
+
+ public ProfileBase Profile {
+ get { return Current( ).Profile; }
+ }
+
+ public bool SkipAuthorization {
+ get { return Current( ).SkipAuthorization; }
+ set { Current( ).SkipAuthorization = value; }
+ }
+
+ public bool IsDebuggingEnabled {
+ get { return Current( ).IsDebuggingEnabled; }
+ }
+
+ public bool IsCustomErrorEnabled {
+ get { return Current( ).IsCustomErrorEnabled; }
+ }
+
+ public DateTime Timestamp {
+ get { return Current( ).Timestamp; }
+ }
+
+ public Cache Cache {
+ get { return Current( ).Cache; }
+ }
+
+ public RequestNotification CurrentNotification {
+ get { return Current( ).CurrentNotification; }
+ }
+
+ public bool IsPostNotification {
+ get { return Current( ).IsPostNotification; }
+ }
+
+ private HttpContext Current() {
+ return HttpContext.Current;
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/CurrentHttpRequest.cs b/slips/src/app/Marina/Web/CurrentHttpRequest.cs
new file mode 100644
index 0000000..35c4fa5
--- /dev/null
+++ b/slips/src/app/Marina/Web/CurrentHttpRequest.cs
@@ -0,0 +1,20 @@
+using System.Collections.Specialized;
+using Marina.Presentation;
+
+namespace Marina.Web {
+ public class CurrentHttpRequest : IHttpRequest {
+ public CurrentHttpRequest( IHttpContext context ) {
+ _context = context;
+ }
+
+ public T ParsePayloadFor< T >( PayloadKey< T > key ) {
+ return key.ParseFrom( Payload( ) );
+ }
+
+ private NameValueCollection Payload() {
+ return new NameValueCollection( _context.Request.Params );
+ }
+
+ private readonly IHttpContext _context;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/FrontController.cs b/slips/src/app/Marina/Web/FrontController.cs
new file mode 100644
index 0000000..8090cb9
--- /dev/null
+++ b/slips/src/app/Marina/Web/FrontController.cs
@@ -0,0 +1,21 @@
+using System.Web;
+using Marina.Web.Handlers;
+using Marina.Web.Http;
+
+namespace Marina.Web {
+ public class FrontController : IHttpHandler {
+ public FrontController( IHttpGateway gateway ) {
+ _gateway = gateway;
+ }
+
+ public void ProcessRequest( HttpContext context ) {
+ new Dispatcher( ).FindFor( _gateway ).Execute( );
+ }
+
+ public bool IsReusable {
+ get { return true; }
+ }
+
+ private IHttpGateway _gateway;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/GlobalApplication.cs b/slips/src/app/Marina/Web/GlobalApplication.cs
new file mode 100644
index 0000000..452587f
--- /dev/null
+++ b/slips/src/app/Marina/Web/GlobalApplication.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Web;
+using Marina.Infrastructure.Logging.Interfaces;
+using Marina.Task;
+
+namespace Marina.Web {
+ public class GlobalApplication : HttpApplication {
+ public void Application_Start( object sender, EventArgs e ) {
+ ApplicationStartupTask.ApplicationBegin( );
+ Log.For(this).Informational("Application Startup completed");
+ }
+
+ public void Application_Error( object sender, EventArgs e ) {
+ Log.For( this ).Informational( "Unhandled error occurred" );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/AvailableSlipsHandler.cs b/slips/src/app/Marina/Web/Handlers/AvailableSlipsHandler.cs
new file mode 100644
index 0000000..a8c69d5
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/AvailableSlipsHandler.cs
@@ -0,0 +1,7 @@
+using Marina.Web.Commands;
+
+namespace Marina.Web.Handlers {
+ public class AvailableSlipsHandler : RequestHandler {
+ public AvailableSlipsHandler() : base( For( CommandNames.AvailableSlips ), new AvailableSlipsCommand( ) ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/Dispatcher.cs b/slips/src/app/Marina/Web/Handlers/Dispatcher.cs
new file mode 100644
index 0000000..af1bd84
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/Dispatcher.cs
@@ -0,0 +1,24 @@
+using Marina.Infrastructure;
+using Marina.Web.Commands;
+using Marina.Web.Http;
+
+namespace Marina.Web.Handlers {
+ public class Dispatcher {
+ private readonly IRegisteredHandlers handlers;
+
+ public Dispatcher() : this( new RegisteredHandlers( ) ) {}
+
+ public Dispatcher( IRegisteredHandlers handlers ) {
+ this.handlers = handlers;
+ }
+
+ public ICommand FindFor( IHttpGateway request ) {
+ foreach ( IRequestHandler handler in handlers.All( ) ) {
+ if ( handler.IsSatisfiedBy( request ) ) {
+ return handler;
+ }
+ }
+ return new RedirectCommand( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/IRegisteredHandlers.cs b/slips/src/app/Marina/Web/Handlers/IRegisteredHandlers.cs
new file mode 100644
index 0000000..3049638
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/IRegisteredHandlers.cs
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+using Marina.Web.Handlers;
+
+namespace Marina.Web.Handlers {
+ public interface IRegisteredHandlers {
+ IEnumerable< IRequestHandler > All( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/IRequestHandler.cs b/slips/src/app/Marina/Web/Handlers/IRequestHandler.cs
new file mode 100644
index 0000000..e33552e
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/IRequestHandler.cs
@@ -0,0 +1,6 @@
+using Marina.Infrastructure;
+using Marina.Web.Http;
+
+namespace Marina.Web.Handlers {
+ public interface IRequestHandler : ISpecification< IHttpGateway >, ICommand {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/RegisteredHandlers.cs b/slips/src/app/Marina/Web/Handlers/RegisteredHandlers.cs
new file mode 100644
index 0000000..1f6395f
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/RegisteredHandlers.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Marina.Web.Handlers {
+ public class RegisteredHandlers : IRegisteredHandlers {
+ public IEnumerable< IRequestHandler > All() {
+ yield return new AvailableSlipsHandler( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/RequestHandler.cs b/slips/src/app/Marina/Web/Handlers/RequestHandler.cs
new file mode 100644
index 0000000..a2162ef
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/RequestHandler.cs
@@ -0,0 +1,26 @@
+using Marina.Infrastructure;
+using Marina.Web.Http;
+
+namespace Marina.Web.Handlers {
+ public class RequestHandler : IRequestHandler {
+ public RequestHandler( ISpecification< IHttpGateway > specification, ICommand command ) {
+ _specification = specification;
+ _command = command;
+ }
+
+ public bool IsSatisfiedBy( IHttpGateway item ) {
+ return _specification.IsSatisfiedBy( item );
+ }
+
+ public void Execute() {
+ _command.Execute( );
+ }
+
+ public static ISpecification< IHttpGateway > For( string commandName ) {
+ return new RequestHandlerSpecification( commandName );
+ }
+
+ private readonly ISpecification< IHttpGateway > _specification;
+ private readonly ICommand _command;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Handlers/RequestHandlerSpecification.cs b/slips/src/app/Marina/Web/Handlers/RequestHandlerSpecification.cs
new file mode 100644
index 0000000..51dd893
--- /dev/null
+++ b/slips/src/app/Marina/Web/Handlers/RequestHandlerSpecification.cs
@@ -0,0 +1,16 @@
+using Marina.Infrastructure;
+using Marina.Web.Http;
+
+namespace Marina.Web.Handlers {
+ public class RequestHandlerSpecification : ISpecification< IHttpGateway > {
+ private readonly string _commandName;
+
+ public RequestHandlerSpecification( string commandName ) {
+ _commandName = commandName;
+ }
+
+ public bool IsSatisfiedBy( IHttpGateway item ) {
+ return item.Destination( ).Contains( _commandName );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Http/HttpGateway.cs b/slips/src/app/Marina/Web/Http/HttpGateway.cs
new file mode 100644
index 0000000..4b91315
--- /dev/null
+++ b/slips/src/app/Marina/Web/Http/HttpGateway.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Specialized;
+using System.Security.Principal;
+using System.Web;
+using System.Web.Security;
+using Marina.Infrastructure.Logging.Interfaces;
+using Marina.Presentation;
+using Marina.Web.Views;
+
+namespace Marina.Web.Http {
+ public class HttpGateway : IHttpGateway {
+ public HttpGateway( IHttpContext context ) {
+ _context = context;
+ }
+
+ public string Destination() {
+ return _context.Request.RawUrl;
+ }
+
+ public void RedirectTo( IView view ) {
+ try {
+ _context.Server.Transfer( view.Name( ) );
+ }
+ catch ( Exception ex ) {
+ Log.For( this ).CriticalError( ex.StackTrace );
+ }
+ }
+
+ public void AddAuthenticationCookieFor( string username, long customerId ) {
+ AddCookieToResponse( username, customerId );
+ BindPrincipalToCurrentThread( username );
+ }
+
+ public T ParsePayloadFor< T >( PayloadKey< T > key ) {
+ return key.ParseFrom( Payload( ) );
+ }
+
+ public bool ContainsPayload< T >( PayloadKey< T > key ) {
+ try {
+ ParsePayloadFor( key );
+ return true;
+ }
+ catch ( PayloadKeyNotFoundException ) {
+ return false;
+ }
+ }
+
+ private NameValueCollection Payload() {
+ return new NameValueCollection( _context.Request.Params );
+ }
+
+ private void BindPrincipalToCurrentThread( string username ) {
+ _context.User = new GenericPrincipal( new GenericIdentity( username ), new string[] {"Customer"} );
+ }
+
+ private void AddCookieToResponse( string username, long customerId ) {
+ FormsAuthenticationTicket ticket =
+ new FormsAuthenticationTicket( 1, username, DateTime.Now, DateTime.Now.AddMinutes( 20 ), false,
+ customerId.ToString( ) );
+
+ _context.Response.Cookies.Add( CreateCookieFrom( ticket ) );
+ _context.Response.Cookies.Add( new HttpCookie( PayloadKeys.CustomerId, customerId.ToString( ) ) );
+ }
+
+ private HttpCookie CreateCookieFrom( FormsAuthenticationTicket ticket ) {
+ return new HttpCookie( FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt( ticket ) );
+ }
+
+ private IHttpContext _context;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Http/IHttpGateway.cs b/slips/src/app/Marina/Web/Http/IHttpGateway.cs
new file mode 100644
index 0000000..93164ad
--- /dev/null
+++ b/slips/src/app/Marina/Web/Http/IHttpGateway.cs
@@ -0,0 +1,16 @@
+using Marina.Presentation;
+using Marina.Web.Views;
+
+namespace Marina.Web.Http {
+ public interface IHttpGateway {
+ string Destination();
+
+ void RedirectTo( IView view );
+
+ void AddAuthenticationCookieFor( string username, long customerId );
+
+ bool ContainsPayload< T >( PayloadKey< T > key );
+
+ T ParsePayloadFor< T >( PayloadKey< T > key );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/IHttpContext.cs b/slips/src/app/Marina/Web/IHttpContext.cs
new file mode 100644
index 0000000..186b8c4
--- /dev/null
+++ b/slips/src/app/Marina/Web/IHttpContext.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections;
+using System.Security.Principal;
+using System.Web;
+using System.Web.Caching;
+using System.Web.Profile;
+using System.Web.SessionState;
+
+namespace Marina.Web {
+ public interface IHttpContext {
+ void AddError( Exception errorInfo );
+
+ void ClearError( );
+
+ object GetSection( string sectionName );
+
+ void RewritePath( string path );
+
+ void RewritePath( string path, bool rebaseClientPath );
+
+ void RewritePath( string filePath, string pathInfo, string queryString );
+
+ void RewritePath( string filePath, string pathInfo, string queryString, bool setClientFilePath );
+
+ HttpApplication ApplicationInstance { get; set; }
+
+ HttpApplicationState Application { get; }
+
+ IHttpHandler Handler { get; set; }
+
+ IHttpHandler PreviousHandler { get; }
+
+ IHttpHandler CurrentHandler { get; }
+
+ HttpRequest Request { get; }
+
+ HttpResponse Response { get; }
+
+ TraceContext Trace { get; }
+
+ IDictionary Items { get; }
+
+ HttpSessionState Session { get; }
+
+ HttpServerUtility Server { get; }
+
+ Exception Error { get; }
+
+ Exception[] AllErrors { get; }
+
+ IPrincipal User { get; set; }
+
+ ProfileBase Profile { get; }
+
+ bool SkipAuthorization { get; set; }
+
+ bool IsDebuggingEnabled { get; }
+
+ bool IsCustomErrorEnabled { get; }
+
+ DateTime Timestamp { get; }
+
+ Cache Cache { get; }
+
+ RequestNotification CurrentNotification { get; }
+
+ bool IsPostNotification { get; }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/IHttpRequest.cs b/slips/src/app/Marina/Web/IHttpRequest.cs
new file mode 100644
index 0000000..be92c04
--- /dev/null
+++ b/slips/src/app/Marina/Web/IHttpRequest.cs
@@ -0,0 +1,7 @@
+using Marina.Presentation;
+
+namespace Marina.Web {
+ public interface IHttpRequest {
+ T ParsePayloadFor< T >( PayloadKey< T > key );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Redirect.cs b/slips/src/app/Marina/Web/Redirect.cs
new file mode 100644
index 0000000..de4a5fe
--- /dev/null
+++ b/slips/src/app/Marina/Web/Redirect.cs
@@ -0,0 +1,10 @@
+using System.Web;
+using Marina.Web.Views;
+
+namespace Marina.Web {
+ public class Redirect {
+ public static void To( IView page ) {
+ HttpContext.Current.Server.Transfer( page.Name( ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/AuthenticationServices.asmx b/slips/src/app/Marina/Web/Services/AuthenticationServices.asmx
new file mode 100644
index 0000000..773ace4
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/AuthenticationServices.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="AuthenticationWebServices.cs" Class="Marina.Web.Services.AuthenticationWebServices" %> \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/AuthenticationWebServices.cs b/slips/src/app/Marina/Web/Services/AuthenticationWebServices.cs
new file mode 100644
index 0000000..f4002f6
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/AuthenticationWebServices.cs
@@ -0,0 +1,21 @@
+using System.Web.Services;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task;
+
+namespace Marina.Web.Services {
+ public class AuthenticationWebServices : IAuthenticationTask {
+ public AuthenticationWebServices() : this( Resolve.DependencyFor< IAuthenticationTask >( ) ) {}
+
+ public AuthenticationWebServices( IAuthenticationTask realTask ) {
+ this.realTask = realTask;
+ }
+
+ [WebMethod]
+ public DisplayResponseLineDTO AuthenticateUserUsing( LoginCredentialsDTO credentials ) {
+ return realTask.AuthenticateUserUsing( credentials );
+ }
+
+ private readonly IAuthenticationTask realTask;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/CatalogServices.asmx b/slips/src/app/Marina/Web/Services/CatalogServices.asmx
new file mode 100644
index 0000000..67943dc
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/CatalogServices.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="CatalogWebServices.cs" Class="Marina.Web.Services.CatalogWebServices" %> \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/CatalogWebServices.cs b/slips/src/app/Marina/Web/Services/CatalogWebServices.cs
new file mode 100644
index 0000000..6982cdd
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/CatalogWebServices.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using System.Web.Services;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task;
+
+namespace Marina.Web.Services {
+ public class CatalogWebServices {
+ public CatalogWebServices() : this( Resolve.DependencyFor< ICatalogTasks >( ) ) {}
+
+ public CatalogWebServices( ICatalogTasks underlyingTask ) {
+ _underlyingTask = underlyingTask;
+ }
+
+ public IEnumerable< SlipDisplayDTO > GetAvailableSlipsForDockBy( long dockId ) {
+ return _underlyingTask.GetAvailableSlipsForDockBy( dockId );
+ }
+
+ [WebMethod]
+ public DockDisplayDTO GetDockInformationBy( long dockId ) {
+ return _underlyingTask.GetDockInformationBy( dockId );
+ }
+
+ public IEnumerable< SlipDisplayDTO > GetAllAvailableSlips() {
+ return _underlyingTask.GetAllAvailableSlips( );
+ }
+
+ [WebMethod]
+ public SlipDisplayDTO FindSlipBy( long slipId ) {
+ return _underlyingTask.FindSlipBy( slipId );
+ }
+
+ private readonly ICatalogTasks _underlyingTask;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/LeaseServices.asmx b/slips/src/app/Marina/Web/Services/LeaseServices.asmx
new file mode 100644
index 0000000..648db51
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/LeaseServices.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="LeaseWebServices.cs" Class="Marina.Web.Services.LeaseWebServices" %> \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/LeaseWebServices.cs b/slips/src/app/Marina/Web/Services/LeaseWebServices.cs
new file mode 100644
index 0000000..b09cc76
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/LeaseWebServices.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+using System.Web.Services;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task;
+
+namespace Marina.Web.Services {
+ public class LeaseWebServices {
+ public LeaseWebServices() : this( Resolve.DependencyFor< ILeaseTasks >( ) ) {}
+
+ public LeaseWebServices( ILeaseTasks underlyingTask ) {
+ _underlyingTask = underlyingTask;
+ }
+
+ public IEnumerable< DisplayLeaseDTO > FindAllLeasesFor( long customerId ) {
+ return _underlyingTask.FindAllLeasesFor( customerId );
+ }
+
+ [WebMethod]
+ public DisplayResponseLineDTO RequestLeaseUsing( SubmitLeaseRequestDTO request ) {
+ return _underlyingTask.RequestLeaseUsing( request );
+ }
+
+ private readonly ILeaseTasks _underlyingTask;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/RegistrationServices.asmx b/slips/src/app/Marina/Web/Services/RegistrationServices.asmx
new file mode 100644
index 0000000..364b737
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/RegistrationServices.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="RegistrationWebServices.cs" Class="Marina.Web.Services.RegistrationWebServices" %> \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Services/RegistrationWebServices.cs b/slips/src/app/Marina/Web/Services/RegistrationWebServices.cs
new file mode 100644
index 0000000..ac98fe5
--- /dev/null
+++ b/slips/src/app/Marina/Web/Services/RegistrationWebServices.cs
@@ -0,0 +1,38 @@
+using System.Collections.Generic;
+using System.Web.Services;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Task;
+
+namespace Marina.Web.Services {
+ public class RegistrationWebServices {
+ public RegistrationWebServices() : this( Resolve.DependencyFor< IRegistrationTasks >( ) ) {}
+
+ public RegistrationWebServices( IRegistrationTasks underlyingTask ) {
+ _underlyingTask = underlyingTask;
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > RegisterNew( RegisterCustomerDTO customer ) {
+ return _underlyingTask.RegisterNew( customer );
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > AddNewBoatUsing( BoatRegistrationDTO boat ) {
+ return _underlyingTask.AddNewBoatUsing( boat );
+ }
+
+ [WebMethod]
+ public CustomerRegistrationDisplayDTO LoadRegistrationFor( long customerId ) {
+ return _underlyingTask.LoadRegistrationFor( customerId );
+ }
+
+ public IEnumerable< DisplayResponseLineDTO > UpdateRegistrationFor( UpdateCustomerRegistrationDTO registration ) {
+ return _underlyingTask.UpdateRegistrationFor( registration );
+ }
+
+ public IEnumerable< BoatRegistrationDTO > AllBoatsFor( long customerId ) {
+ return _underlyingTask.AllBoatsFor( customerId );
+ }
+
+ private readonly IRegistrationTasks _underlyingTask;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/UnhandledExceptionsHttpModule.cs b/slips/src/app/Marina/Web/UnhandledExceptionsHttpModule.cs
new file mode 100644
index 0000000..d2267f2
--- /dev/null
+++ b/slips/src/app/Marina/Web/UnhandledExceptionsHttpModule.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Web;
+using Marina.Infrastructure.Logging.Interfaces;
+using Marina.Web.Views;
+
+namespace Marina.Web {
+ public class UnhandledExceptionsHttpModule : IHttpModule {
+ public void Init( HttpApplication context ) {
+ context.Error += delegate {
+ foreach ( Exception exception in context.Context.AllErrors ) {
+ Log.For( this ).CriticalError( exception.ToString( ) );
+ }
+ Redirect.To( WebViews.Login );
+ };
+ }
+
+ public void Dispose() {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/IView.cs b/slips/src/app/Marina/Web/Views/IView.cs
new file mode 100644
index 0000000..55c1595
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/IView.cs
@@ -0,0 +1,7 @@
+namespace Marina.Web.Views {
+ public interface IView {
+ string Name( );
+
+ void Render( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/IViewLuggageTicket.cs b/slips/src/app/Marina/Web/Views/IViewLuggageTicket.cs
new file mode 100644
index 0000000..231a008
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/IViewLuggageTicket.cs
@@ -0,0 +1,3 @@
+namespace Marina.Web.Views {
+ public interface IViewLuggageTicket< T > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/IViewLuggageTransporter.cs b/slips/src/app/Marina/Web/Views/IViewLuggageTransporter.cs
new file mode 100644
index 0000000..7256f86
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/IViewLuggageTransporter.cs
@@ -0,0 +1,7 @@
+namespace Marina.Web.Views {
+ public interface IViewLuggageTransporter< T > {
+ void Add( T value );
+
+ T Value( );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/IWebView.cs b/slips/src/app/Marina/Web/Views/IWebView.cs
new file mode 100644
index 0000000..52af842
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/IWebView.cs
@@ -0,0 +1,5 @@
+namespace Marina.Web.Views {
+ public interface IWebView< T > : IView {
+ void AddToBag( T slips );
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/Pages/AvailableSlipsWebView.cs b/slips/src/app/Marina/Web/Views/Pages/AvailableSlipsWebView.cs
new file mode 100644
index 0000000..bf930a7
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/Pages/AvailableSlipsWebView.cs
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using Marina.Infrastructure.Container;
+using Marina.Presentation.DTO;
+using Marina.Web.Http;
+
+namespace Marina.Web.Views.Pages {
+ public class AvailableSlipsWebView : WebView< IEnumerable< SlipDisplayDTO > >, IAvailableSlipsWebView {
+ public AvailableSlipsWebView()
+ : this(
+ ViewLuggage.TransporterFor( ViewLuggageTickets.AvailableSlips ),
+ Resolve.DependencyFor< IHttpGateway >( ) ) {}
+
+ public AvailableSlipsWebView( IViewLuggageTransporter< IEnumerable< SlipDisplayDTO > > viewBag, IHttpGateway gateway )
+ : base( "AvailableSlips.aspx", viewBag, gateway ) {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/Pages/IAvailableSlipsWebView.cs b/slips/src/app/Marina/Web/Views/Pages/IAvailableSlipsWebView.cs
new file mode 100644
index 0000000..83535da
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/Pages/IAvailableSlipsWebView.cs
@@ -0,0 +1,6 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Web.Views.Pages {
+ public interface IAvailableSlipsWebView : IWebView< IEnumerable< SlipDisplayDTO > > {}
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/View.cs b/slips/src/app/Marina/Web/Views/View.cs
new file mode 100644
index 0000000..9f22d8d
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/View.cs
@@ -0,0 +1,28 @@
+using Marina.Infrastructure.Container;
+using Marina.Web.Http;
+
+namespace Marina.Web.Views {
+ public class View : IView {
+ public View( string name ) : this( name, Resolve.DependencyFor< IHttpGateway >( ) ) {}
+
+ public View( string name, IHttpGateway gateway ) {
+ _name = name;
+ _gateway = gateway;
+ }
+
+ public string Name() {
+ return _name;
+ }
+
+ public void Render() {
+ _gateway.RedirectTo( this );
+ }
+
+ public override string ToString() {
+ return Name( );
+ }
+
+ private readonly string _name;
+ private readonly IHttpGateway _gateway;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/ViewLuggage.cs b/slips/src/app/Marina/Web/Views/ViewLuggage.cs
new file mode 100644
index 0000000..7e9580d
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/ViewLuggage.cs
@@ -0,0 +1,11 @@
+namespace Marina.Web.Views {
+ public class ViewLuggage {
+ public static IViewLuggageTransporter< T > TransporterFor< T >( IViewLuggageTicket< T > ticket ) {
+ return new ViewLuggageTransporter< T >( ticket );
+ }
+
+ public static T ClaimFor< T >( IViewLuggageTicket< T > ticket ) {
+ return new ViewLuggageTransporter< T >( ticket ).Value( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/ViewLuggageTickets.cs b/slips/src/app/Marina/Web/Views/ViewLuggageTickets.cs
new file mode 100644
index 0000000..3c30368
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/ViewLuggageTickets.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+
+namespace Marina.Web.Views {
+ public class ViewLuggageTickets {
+ public static IViewLuggageTicket< IEnumerable< SlipDisplayDTO > > AvailableSlips =
+ new ViewBagItem< IEnumerable< SlipDisplayDTO > >( );
+
+ public static IViewLuggageTicket< IEnumerable< DisplayResponseLineDTO > > ResponseMessages =
+ new ViewBagItem< IEnumerable< DisplayResponseLineDTO > >( );
+
+ private class ViewBagItem< T > : IViewLuggageTicket< T > {}
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/ViewLuggageTransporter.cs b/slips/src/app/Marina/Web/Views/ViewLuggageTransporter.cs
new file mode 100644
index 0000000..a86c734
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/ViewLuggageTransporter.cs
@@ -0,0 +1,32 @@
+using System.Collections;
+using System.Web;
+
+namespace Marina.Web.Views {
+ public class ViewLuggageTransporter< Luggage > : IViewLuggageTransporter< Luggage > {
+ public ViewLuggageTransporter( IViewLuggageTicket< Luggage > key ) : this( key, HttpContext.Current.Items ) {}
+
+ private ViewLuggageTransporter( IViewLuggageTicket< Luggage > key, IDictionary items ) {
+ _ticket = key;
+ _items = items;
+ }
+
+ public Luggage Value() {
+ foreach ( DictionaryEntry entry in _items ) {
+ if ( entry.Value is Luggage ) {
+ return ( Luggage )entry.Value;
+ }
+ //if ( entry.Key.Equals( _ticket ) ) {
+ // return ( Luggage )entry.Value;
+ //}
+ }
+ return default( Luggage );
+ }
+
+ public void Add( Luggage value ) {
+ _items.Add( _ticket, value );
+ }
+
+ private readonly IViewLuggageTicket< Luggage > _ticket;
+ private readonly IDictionary _items;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/WebView.cs b/slips/src/app/Marina/Web/Views/WebView.cs
new file mode 100644
index 0000000..f517479
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/WebView.cs
@@ -0,0 +1,27 @@
+using Marina.Web.Http;
+
+namespace Marina.Web.Views {
+ public class WebView< T > : IWebView< T > {
+ public WebView( string name, IViewLuggageTransporter< T > viewBag, IHttpGateway gateway ) {
+ this.name = name;
+ this.gateway = gateway;
+ this.viewBag = viewBag;
+ }
+
+ public string Name() {
+ return name;
+ }
+
+ public void Render() {
+ gateway.RedirectTo( this );
+ }
+
+ public void AddToBag( T slips ) {
+ viewBag.Add( slips );
+ }
+
+ private readonly string name;
+ private readonly IHttpGateway gateway;
+ private readonly IViewLuggageTransporter< T > viewBag;
+ }
+} \ No newline at end of file
diff --git a/slips/src/app/Marina/Web/Views/WebViews.cs b/slips/src/app/Marina/Web/Views/WebViews.cs
new file mode 100644
index 0000000..6431606
--- /dev/null
+++ b/slips/src/app/Marina/Web/Views/WebViews.cs
@@ -0,0 +1,18 @@
+using Marina.Web.Views.Pages;
+
+namespace Marina.Web.Views {
+ public class WebViews {
+ public static readonly IAvailableSlipsWebView AvailableSlips = new AvailableSlipsWebView( );
+
+ public static readonly IView ContactUs = new View( "ContactUs.aspx" );
+ public static readonly IView Default = new View( "Default.aspx" );
+ public static readonly IView DockView = new View( "DockView.aspx" );
+ public static readonly IView Login = new View( "Login.aspx" );
+ public static readonly IView RegisterBoat = new View( "RegisterBoat.aspx" );
+ public static readonly IView Registration = new View( "Registration.aspx" );
+ public static readonly IView UpdateCustomerRegistration = new View( "UpdateCustomerRegistration.aspx" );
+ public static readonly IView ViewRegisteredBoats = new View( "ViewRegisteredBoats.aspx" );
+ public static readonly IView CurrentLeases = new View( "CurrentLeases.aspx" );
+ public static readonly IView LeaseSlip = new View( "LeaseSlip.aspx" );
+ }
+} \ No newline at end of file