-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAL, composition root, console launcher (#1)
* add data access project * data access layer init create * refactoring * composition root added * console launcher
- Loading branch information
Showing
33 changed files
with
1,149 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
[Oo]bj | ||
[Dd]ebug | ||
[Rr]elease | ||
*.user | ||
*.suo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
CardManagement.Api/CardManagement.Api/CardManagement.Api.fsproj.user
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace CardManagement.Common | ||
|
||
[<AutoOpen>] | ||
module Common = | ||
let inline (|HasLength|) x = | ||
fun () -> (^a: (member Length: int) x) | ||
|
||
let inline (|HasCount|) x = | ||
fun () -> (^a: (member Count: int) x) | ||
|
||
let inline length (HasLength f) = f() | ||
|
||
let inline isNullOrEmpty arg = | ||
if arg = null || (length arg) = 0 then true | ||
else false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace CardManagement.Common | ||
|
||
module ErrorMessages = | ||
|
||
open Errors | ||
|
||
let private entityDescription = sprintf "[%s] entity with id [%s]" | ||
|
||
let dataRelatedErrorMessage = | ||
function | ||
| EntityAlreadyExists (name, id) -> entityDescription name id |> sprintf "%s already exists." | ||
| EntityNotFound (name, id) -> entityDescription name id |> sprintf "%s was not found." | ||
| EntityIsInUse (name, id) -> entityDescription name id |> sprintf "%s is in use." | ||
| UpdateError (name, id, message) -> | ||
message |> (entityDescription name id |> sprintf "%s failed to update. Details:\n%s") | ||
| InvalidDbData { EntityName = name; EntityId = id; Message = message } -> | ||
message |> (entityDescription name id |> sprintf "%s is invalid. Details:\n%s") | ||
|
||
let validationMessage { FieldPath = path; Message = message } = | ||
sprintf "Field [%s] is invalid. Message: %s" path message | ||
|
||
let operationNotAllowedMessage { Operation = op; Reason = reason } = | ||
sprintf "Operation [%s] is not allowed. Reason: %s" op reason | ||
|
||
let errorMessage error = | ||
match error with | ||
| ValidationError v -> validationMessage v | ||
| OperationNotAllowed o -> operationNotAllowedMessage o | ||
| DataError d -> dataRelatedErrorMessage d | ||
| Bug b -> sprintf "Oops, something went wrong." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="appsettings.Development.json"> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="appsettings.json"> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup /> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CardManagement.Common\CardManagement.Common.fsproj" /> | ||
<ProjectReference Include="..\CardManagement.Data\CardManagement.Data.fsproj" /> | ||
<ProjectReference Include="..\CardManagement.Infrastructure\CardManagement.Infrastructure.fsproj" /> | ||
<ProjectReference Include="..\CardManagement\CardManagement.fsproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Update="FSharp.Core" Version="4.6.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Learn more about F# at http://fsharp.org | ||
|
||
open System | ||
|
||
open CardManagement.CardDomainCommandModels | ||
open CardManagement.Infrastructure | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
let createUserCmd = | ||
{ CreateUserCommandModel.Name = "Roman" | ||
Address = | ||
{ CreateAddressCommandModel.Country = "Russia" | ||
City = "SaintPetersburg" | ||
PostalCode = "12345" | ||
AddressLine1 = "Rubinstein st. 13" | ||
AddressLine2 = "ap. 1" } } | ||
|
||
printfn "creating user:\n%A\n" createUserCmd | ||
let user = CompositionRoot.createUser createUserCmd |> Async.RunSynchronously | ||
printfn "user created:\n%A\n" user | ||
match user with | ||
| Ok user -> | ||
printfn "getting user with id %A" user.Id | ||
let user = CompositionRoot.getUser user.Id |> Async.RunSynchronously | ||
printfn "finished getting user:\n%A" user | ||
| Error e -> printfn "Error occured:\n%A" e | ||
Console.ReadLine() |> ignore | ||
0 // return an integer exit code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"MongoDB": { | ||
"Database": "CardDb", | ||
"Host": "localhost", | ||
"Port": 27017, | ||
"User": "root", | ||
"Password": "example" | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
Oops, something went wrong.