Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
f9f9faa
update NuGet packages to latest published under ArqiSoft account
pshenichnov Dec 28, 2018
91ad8ca
publish some required by other projects NuGet packages
pshenichnov Jan 2, 2019
898e3cc
Publish Osdr MachineLearning package
pshenichnov Jan 4, 2019
f1dec45
refresh docker-compose files for integration and end-to-end tests
pshenichnov Jan 7, 2019
a0bcaca
build integration tests docker images and activate them in compose files
pshenichnov Jan 7, 2019
55d8714
add travis ci integration
Jan 11, 2019
a034b4a
test travis ci integration
Jan 11, 2019
f05f4c3
continue to test travis ci integration
Jan 11, 2019
d6d7907
change YAML format
Jan 11, 2019
1891301
minor
Jan 11, 2019
b751f8d
test
Jan 11, 2019
7ee46a3
change travis flow
Jan 11, 2019
eb58e0a
tune travis flow
Jan 12, 2019
1eda641
try caching
Jan 12, 2019
a73d205
change flow
Jan 12, 2019
2d5c4a5
build all docker images
Jan 12, 2019
d2cb796
add name to one of build service scripts
Jan 12, 2019
39893a8
cache docker images
Jan 12, 2019
d6cdc07
changes
Jan 12, 2019
3ffe881
test
Jan 12, 2019
7c1cfb9
test
Jan 13, 2019
4c1d348
test
Jan 13, 2019
19357a1
test
Jan 13, 2019
8eb9724
travis-ci integration
Jan 13, 2019
27db6c2
travis-ci integration
pshenichnov Jan 13, 2019
4223726
travis-ci integration
pshenichnov Jan 13, 2019
7695c30
travis-ci integration
pshenichnov Jan 13, 2019
2f1c6c5
travis-ci integration
pshenichnov Jan 13, 2019
4b6186a
travis-ci integration
pshenichnov Jan 13, 2019
7b5ba3e
travis-ci integration
pshenichnov Jan 13, 2019
cadaf60
travis-ci integration
pshenichnov Jan 13, 2019
c10dd77
travis-ci integration
pshenichnov Jan 13, 2019
6f41e4e
travis-ci integration
pshenichnov Jan 13, 2019
1af627e
travis-ci integration
pshenichnov Jan 13, 2019
9fbf143
travis-ci integration
pshenichnov Jan 14, 2019
0cb706e
travis-ci integration
pshenichnov Jan 14, 2019
e6a8d01
travis-ci integration
pshenichnov Jan 14, 2019
46b6017
travis-ci integration
pshenichnov Jan 14, 2019
7071939
travis-ci integration
pshenichnov Jan 14, 2019
ed38330
travis-ci integration
pshenichnov Jan 14, 2019
9098e24
travis-ci integration
pshenichnov Jan 14, 2019
5129d91
travis-ci integration
pshenichnov Jan 14, 2019
5d5fc4e
travis-ci integration
pshenichnov Jan 14, 2019
8b5187f
travis-ci integration
pshenichnov Jan 15, 2019
1f56612
travis-ci integration
pshenichnov Jan 15, 2019
8c1efd5
travis-ci integration
pshenichnov Jan 15, 2019
520c925
travis-ci integration
pshenichnov Jan 15, 2019
dbf940c
refresh docker-compose.yml for e2e tests
pshenichnov Jan 18, 2019
4eaaf69
setup Microscopy format support
pshenichnov Jun 22, 2019
8e0b44e
LEAN-34 Setup Microscopy format support in Core services
yeskela Jun 27, 2019
ec82c81
move microscopy domain into NuGet
yeskela Jul 5, 2019
1d0c148
update core services Dockerfile
yeskela Jul 5, 2019
ca90c1a
tune Dockerfile for integration test projects
yeskela Jul 6, 2019
34ed4b4
fix broken test
yeskela Jul 6, 2019
ad86e56
fix broken microscopy saga - images weren't processed properly
yeskela Jul 6, 2019
bcf1a08
enable web api integration tests
pshenichnov Jul 6, 2019
cedccd7
try to run only one single test in Web API tests
pshenichnov Jul 6, 2019
cc6e165
enable all web api tests
pshenichnov Jul 6, 2019
8db6ddc
another try to fix web api integration tests in travis-ci
pshenichnov Jul 6, 2019
2cde229
Added DATE tag to Leanda Core images
RickZee Jul 7, 2019
33f7186
Added DATE tag to Leanda Core images
RickZee Jul 7, 2019
b346c77
LEAN-44 Implement capabilities configuration on back-end
RickZee Jul 10, 2019
59d37e0
store bio metadata under 'Properties' section in document DB
pshenichnov Aug 4, 2019
cba5893
Support generic Metadata on back-end
pshenichnov Aug 6, 2019
b60aee6
fix broken integration test
pshenichnov Aug 6, 2019
352dac0
extended patch entities/files/{id} functionality with metadata
AleksanderSidorenko Aug 6, 2019
d56c7f2
Merge branch 'master' of https://github.com/ArqiSoft/leanda-core
AleksanderSidorenko Aug 6, 2019
92bfe16
generic file metadata
pshenichnov Aug 6, 2019
1645b07
changed bio meta persistence model
AleksanderSidorenko Aug 7, 2019
8ef4b5f
Merge branch 'master' of https://github.com/ArqiSoft/leanda-core
AleksanderSidorenko Aug 7, 2019
147c063
LEAN-61 bugfix
AleksanderSidorenko Aug 8, 2019
22c5e4b
LEAN-60
AleksanderSidorenko Aug 8, 2019
f1033b6
LEAN-65 fixed broken test
AleksanderSidorenko Aug 10, 2019
061c93e
LEAN-66
AleksanderSidorenko Aug 12, 2019
a1eb62f
fixed tests
AleksanderSidorenko Aug 14, 2019
6a9c064
minor fix
AleksanderSidorenko Aug 14, 2019
73b7ef5
get Mongo database name from connection string
pshenichnov Aug 15, 2019
3540f6c
debug travis ci integration tests
pshenichnov Aug 15, 2019
acf59dc
enable web api integration tests trace
pshenichnov Aug 15, 2019
5cbc280
enable all web api integration tests
pshenichnov Aug 15, 2019
c8d3fcb
update FluentAssertion NuGet
pshenichnov Aug 15, 2019
5e24626
extend docker-compose timeout to 60 sec
pshenichnov Aug 16, 2019
12229fe
LEAN-70
Aug 17, 2019
1259544
LEAN-81
Aug 27, 2019
dbb5a59
LEAN-81 fix in tests
Aug 27, 2019
4934710
LEAN-77
Aug 28, 2019
7ef5d03
trigger commit
Aug 30, 2019
0884b44
immediate commit
Sep 2, 2019
86789da
e2e tests alive
AleksanderSidorenko Sep 2, 2019
3083777
add Categories project
pshenichnov Sep 17, 2019
a9c821f
Added Events and Aggregates for Category Module
nizami Sep 17, 2019
29b2da8
new endpoints
pshenichnov Sep 18, 2019
04727ee
issue appropriate commands from POST/PUT categories tree controller
pshenichnov Sep 18, 2019
e1d1dec
category tree command and event handlers
pshenichnov Sep 18, 2019
e9dd826
setup general Core services + integration tests
pshenichnov Sep 19, 2019
335f730
/api/categories/{id}/tree endpoint
pshenichnov Sep 19, 2019
956755e
attempt to fix build
AleksanderSidorenko Sep 23, 2019
f8667c4
fix build
AleksanderSidorenko Sep 23, 2019
45a1361
blank commit
AleksanderSidorenko Sep 23, 2019
92dc715
fix build
AleksanderSidorenko Sep 23, 2019
bd71341
blank commit
AleksanderSidorenko Sep 23, 2019
abe2000
reverted masstransit update
AleksanderSidorenko Sep 23, 2019
a3c1bf9
LEAN-100
AleksanderSidorenko Sep 25, 2019
9b24aaf
empty commit
AleksanderSidorenko Sep 25, 2019
9f3b76a
Added tests and update method for Category Tree
nizami Sep 25, 2019
f32dd4f
Added new UpdatedPersisted Event. Fixed Tests
nizami Sep 25, 2019
26b9738
Just a space for Travic
nizami Sep 25, 2019
7ddb6c9
fixed tests
AleksanderSidorenko Sep 25, 2019
28c2a98
Changed endpoints
nizami Sep 26, 2019
7f01b79
Merge branch 'master' of https://github.com/ArqiSoft/leanda-core
nizami Sep 26, 2019
b8ff276
intermediate commit
AleksanderSidorenko Sep 30, 2019
9dc82df
category tree validation
AleksanderSidorenko Oct 1, 2019
2003a57
Added category delete logic
nizami Oct 2, 2019
b2f4704
some tidy ups in code
AleksanderSidorenko Oct 2, 2019
6e0de7c
build fix
AleksanderSidorenko Oct 3, 2019
ad5c071
empty commit
AleksanderSidorenko Oct 3, 2019
abdce4b
Merge pull request #1 from ArqiSoft/category-tree-validation
AleksanderSidorenko Oct 3, 2019
d7b3017
LEAN-103 Added Delete all Category Tree logic
nizami Oct 4, 2019
498fa2e
Merge master
nizami Oct 4, 2019
054afce
Fix Travis build
nizami Oct 4, 2019
e92e671
Fix for DELETE Categories endpoint
nizami Oct 7, 2019
ee92711
Added tagging for entities
nizami Oct 25, 2019
106a04f
Merge master. Fix conflicts
nizami Oct 25, 2019
9f9921a
Added readme, build badge
RickZee Oct 29, 2019
7742a0c
Modified endpoints. Added Delete and Get Categories tests
nizami Oct 30, 2019
cdcd2d2
Added ES to test docker-compose.yml
nizami Oct 30, 2019
592ed36
Resolved PR comments
nizami Oct 30, 2019
34d8dec
Fixeb build errors
nizami Oct 30, 2019
b488e72
Build fix
nizami Oct 31, 2019
7f12ac5
Modified docker-compose
nizami Oct 31, 2019
bbbbe33
Added categories-service to docker-compose
nizami Oct 31, 2019
bf29797
Skip Tests
nizami Oct 31, 2019
53e3e7e
Empty commit
nizami Oct 31, 2019
8ccf955
Removed ES from docker-compose
nizami Oct 31, 2019
021c804
Skipped unstable tests
nizami Oct 31, 2019
50e6480
fix broken swagger
pshenichnov Nov 3, 2019
0e5cfb7
configured keycloak with inial admin user
AleksanderSidorenko Nov 4, 2019
6ff7170
Added Moq for Categories.
nizami Nov 5, 2019
716639f
Merge branch 'feat/LEAN-105-Implement-POST-method-to-tag-Entities' of…
nizami Nov 5, 2019
af03dd6
applied admin attribute for put and delete endpoints
AleksanderSidorenko Nov 5, 2019
be05035
Fixed tests. Modified Categories Moq methods
nizami Nov 5, 2019
fe3a5cc
Merge pull request #3 from ArqiSoft/configure-keycloak-initial-settings
yeskela Nov 5, 2019
babc781
Merge branch 'master' into feat/LEAN-105-Implement-POST-method-to-tag…
nizami Nov 5, 2019
21c5ab4
Fixed tests
nizami Nov 5, 2019
1f51783
added test files
Nov 8, 2019
80b9e97
e2e are working. that`s pretty good.
AleksanderSidorenko Nov 10, 2019
84c720f
Merge branch 'feat/LEAN-105-Implement-POST-method-to-tag-Entities' in…
AleksanderSidorenko Nov 10, 2019
f44a8b7
two more tests are working
AleksanderSidorenko Nov 11, 2019
f27d2f8
stabilized last set of tests
AleksanderSidorenko Nov 13, 2019
8ecb66e
Merge pull request #2 from ArqiSoft/feat/LEAN-105-Implement-POST-meth…
yeskela Nov 13, 2019
bfb803f
immediate commit
AleksanderSidorenko Nov 13, 2019
caa70be
fixed comments in pr
AleksanderSidorenko Nov 14, 2019
d0d64cf
added one more test case
Nov 15, 2019
f6cdd5a
non-functional changes
AleksanderSidorenko Nov 15, 2019
233f795
uncommented e2e tests
AleksanderSidorenko Nov 15, 2019
1d4a68f
added handling for non existing category trees/entities, increased te…
AleksanderSidorenko Nov 17, 2019
26dbf51
fixed delete functionality
AleksanderSidorenko Nov 21, 2019
6ba8b74
added test for update node in category tree
AleksanderSidorenko Nov 22, 2019
88aec50
non functional changes
AleksanderSidorenko Nov 22, 2019
af88809
fixed subset of comments
AleksanderSidorenko Nov 25, 2019
305c593
fixed tests
AleksanderSidorenko Nov 26, 2019
9cb6728
increased waiting time
AleksanderSidorenko Nov 26, 2019
fc53856
fixing tests
AleksanderSidorenko Nov 26, 2019
bc45cbf
test fix
AleksanderSidorenko Nov 26, 2019
1abb390
refactoring
AleksanderSidorenko Nov 26, 2019
b8ca12d
refactoring
AleksanderSidorenko Nov 26, 2019
ba8cec3
Merge pull request #5 from ArqiSoft/DELETE-endpoints-for-'api/categor…
AleksanderSidorenko Nov 27, 2019
aa6f62b
Merge pull request #6 from ArqiSoft/Increase-test-coverage-for-Catego…
AleksanderSidorenko Nov 27, 2019
16d3d27
Merge branch 'master' of https://github.com/ArqiSoft/leanda-core into…
AleksanderSidorenko Nov 27, 2019
91b19bc
Merge pull request #4 from ArqiSoft/ategories-e2e-tests
AleksanderSidorenko Nov 27, 2019
85a8be1
fix
AleksanderSidorenko Nov 27, 2019
9afc59e
Merge pull request #7 from ArqiSoft/ategories-e2e-tests
AleksanderSidorenko Nov 27, 2019
a7e323c
implemented functionality, covered with tests
AleksanderSidorenko Nov 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IDENTITY_SERVER_URL=https://id.leanda.io/auth/realms/OSDR
CORE_API_URL=http://localhost:28611/api
BLOB_STORAGE_API_URL=http://localhost:18006/api
IMAGING_URL=http://localhost:7972/api
SIGNALR_URL=http://localhost:28611/signalr
METADATA_URL=http://localhost:63790/api
PROXY_JSMOL_URL=http://localhost:28611/api/proxy/jsmol
KETCHER_URL=https://osdr.dev.dataledger.io/ketcher/indigo/layout
OSDR_LOG_FOLDER=logs
OSDR_TEMP_FILES_FOLDER=./temp
REALM=OSDR
OSDR_LOG_LEVEL=Debug
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
67 changes: 67 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

OsdrWebDeploy/
source/packages/

# Build results
[Dd]ebug/
[Rr]elease/
x64/
[Bb]uild/
!Source/Osdr.Mvc/OsdrWeb/Widgets/3rd/pdfjs/build
!Source/Osdr.Ng2/src/client/assets/3rd/pdf-js/build
!Source/Osdr.Mvc/3rd/
[Bb]in/
[Oo]bj/
[Dd]ist/
[Xx]unit/
[Xx]unit-results.xml

# User-specific files
*.suo
*.user
*.sln.docstates
.vs/
.vscode/
project.lock.json

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# Node/Bower
bower_components/
node_modules/

.DS_Store
._.DS_Store
._*

#NuGet packages
*.nupkg

# Auto-generated JS, CSS files
packages/

!Source/Services/Imaging/Sds.Imaging.Processing/bin/gsdll32.dll
!Source/Services/Imaging/Sds.Imaging.Processing/bin/gsdll64.dll
!Source/Services/Imaging/Sds.Imaging.Processing/bin/Select.Html.dep
!Source/Services/Imaging/Sds.Imaging.Rasterizers/bin/gsdll32.dll
!Source/Services/Imaging/Sds.Imaging.Rasterizers/bin/gsdll64.dll
!Source/Services/Imaging/Sds.Imaging.Rasterizers/bin/Select.Html.dep
/Source/Osdr.Services/Logging/elasticsearch
/Source/Services/Logging/elasticsearch
/Source/Services/OsdrService/Sds.Osdr.Domain.BddTests/Resources/Aspirin.mol.svg
81 changes: 81 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
language: minimal

services:
- docker

branches:
only:
- master

os:
- linux

env:
global:
- DATE=`TZ=America/New_York date "+%Y-%m-%d-%H%M"`
- DOCKER_CACHE_FILE=/home/travis/docker/docker-cache.tar
- LEANDA_PERSISTENCE_IMAGE="leanda/core-persistence"
- LEANDA_FRONTEND_IMAGE="leanda/core-frontend"
- LEANDA_BACKEND_IMAGE="leanda/core-backend"
- LEANDA_SAGAHOST_IMAGE="leanda/core-sagahost"
- LEANDA_WEBAPI_IMAGE="leanda/core-web-api"
- LEANDA_WEBAPI_INTEGRATION_TESTS_IMAGE="leanda/webapi-integration"

cache:
directories:
- /home/travis/docker/

jobs:
include:
- stage: Build
name: Build Leanda Back-End, Front-End, Sagahost, Persistence and Web API services
script:
- docker build -t $LEANDA_PERSISTENCE_IMAGE:ci -f Sds.Osdr.Persistence/Dockerfile .
- docker build -t $LEANDA_FRONTEND_IMAGE:ci -f Sds.Osdr.Domain.FrontEnd/Dockerfile .
- docker build -t $LEANDA_BACKEND_IMAGE:ci -f Sds.Osdr.Domain.BackEnd/Dockerfile .
- docker build -t $LEANDA_SAGAHOST_IMAGE:ci -f Sds.Osdr.Domain.SagaHost/Dockerfile .
- docker build -t $LEANDA_WEBAPI_IMAGE:ci -f Sds.Osdr.WebApi/Dockerfile .
- if [ -d $DOCKER_CACHE_FILE ]; then rm $DOCKER_CACHE_FILE; fi
- docker save -o $DOCKER_CACHE_FILE $LEANDA_PERSISTENCE_IMAGE:ci $LEANDA_FRONTEND_IMAGE:ci $LEANDA_BACKEND_IMAGE:ci $LEANDA_SAGAHOST_IMAGE:ci $LEANDA_WEBAPI_IMAGE:ci
- stage: Integration tests
name: Run Web API integration tests
script:
- docker load -i $DOCKER_CACHE_FILE
- docker build -t $LEANDA_WEBAPI_INTEGRATION_TESTS_IMAGE:ci -f Sds.Osdr.WebApi.IntegrationTests/Dockerfile .
- docker images
- yes | cp -rf Sds.Osdr.WebApi.IntegrationTests/.env.travis-ci Sds.Osdr.WebApi.IntegrationTests/.env
- cd Sds.Osdr.WebApi.IntegrationTests && docker-compose up --abort-on-container-exit
- script:
- docker load -i $DOCKER_CACHE_FILE
- docker build -t leanda/integration:ci -f Sds.Osdr.IntegrationTests/Dockerfile .
- docker images
- yes | cp -rf Sds.Osdr.IntegrationTests/.env.travis-ci Sds.Osdr.IntegrationTests/.env
- cd Sds.Osdr.IntegrationTests && docker-compose up --abort-on-container-exit
name: Run processing integration tests
- stage: Deploy
name: Deploy new images to docker hub
script:
- docker load -i $DOCKER_CACHE_FILE
- docker tag $LEANDA_PERSISTENCE_IMAGE:ci $LEANDA_PERSISTENCE_IMAGE:latest
- docker tag $LEANDA_PERSISTENCE_IMAGE:ci $LEANDA_PERSISTENCE_IMAGE:$DATE
- docker tag $LEANDA_FRONTEND_IMAGE:ci $LEANDA_FRONTEND_IMAGE:latest
- docker tag $LEANDA_FRONTEND_IMAGE:ci $LEANDA_FRONTEND_IMAGE:$DATE
- docker tag $LEANDA_BACKEND_IMAGE:ci $LEANDA_BACKEND_IMAGE:latest
- docker tag $LEANDA_BACKEND_IMAGE:ci $LEANDA_BACKEND_IMAGE:$DATE
- docker tag $LEANDA_SAGAHOST_IMAGE:ci $LEANDA_SAGAHOST_IMAGE:latest
- docker tag $LEANDA_SAGAHOST_IMAGE:ci $LEANDA_SAGAHOST_IMAGE:$DATE
- docker tag $LEANDA_WEBAPI_IMAGE:ci $LEANDA_WEBAPI_IMAGE:latest
- docker tag $LEANDA_WEBAPI_IMAGE:ci $LEANDA_WEBAPI_IMAGE:$DATE
- docker images
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- docker push $LEANDA_PERSISTENCE_IMAGE:latest
- docker push $LEANDA_PERSISTENCE_IMAGE:$DATE
- docker push $LEANDA_FRONTEND_IMAGE:latest
- docker push $LEANDA_FRONTEND_IMAGE:$DATE
- docker push $LEANDA_BACKEND_IMAGE:latest
- docker push $LEANDA_BACKEND_IMAGE:$DATE
- docker push $LEANDA_SAGAHOST_IMAGE:latest
- docker push $LEANDA_SAGAHOST_IMAGE:$DATE
- docker push $LEANDA_WEBAPI_IMAGE:latest
- docker push $LEANDA_WEBAPI_IMAGE:$DATE
- rm -f $DOCKER_CACHE_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using CQRSlite.Domain;
using CQRSlite.Domain.Exception;
using Leanda.Categories.Domain;
using Leanda.Categories.Domain.Commands;
using Leanda.Categories.Domain.Events;
using MassTransit;
using Serilog;
using System;
using System.Threading.Tasks;

namespace Leanda.Categories.BackEnd.CommandHandlers
{
public class CategoryTreeCommandHandler : IConsumer<CreateCategoryTree>,
IConsumer<UpdateCategoryTree>,
IConsumer<DeleteCategoryTree>,
IConsumer<DeleteCategoryTreeNode>
{
private readonly ISession _session;

public CategoryTreeCommandHandler(ISession session)
{
_session = session ?? throw new ArgumentNullException(nameof(session));
}

public async Task Consume(ConsumeContext<CreateCategoryTree> context)
{
var tree = new CategoryTree(context.Message.Id, userId: context.Message.UserId, nodes: context.Message.Nodes);

await _session.Add(tree);

await _session.Commit();
}

public async Task Consume(ConsumeContext<UpdateCategoryTree> context)
{
var tree = await _session.Get<CategoryTree>(context.Message.Id);

tree.Update(context.Message.UserId, context.Message.ParentId, context.Message.Nodes);

await _session.Commit();
}

public async Task Consume(ConsumeContext<DeleteCategoryTree> context)
{
var tree = await _session.Get<CategoryTree>(context.Message.Id);

tree.Delete(context.Message.UserId);

await _session.Commit();
}

public async Task Consume(ConsumeContext<DeleteCategoryTreeNode> context)
{
var tree = await _session.Get<CategoryTree>(context.Message.Id);

tree.DeleteNode(context.Message.UserId, context.Message.NodeId);

await _session.Commit();
}
}
}
89 changes: 89 additions & 0 deletions Leanda.Categories/Domain/Aggregates/CategoryTree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using CQRSlite.Domain;
using Leanda.Categories.Domain.Events;
using Leanda.Categories.Domain.ValueObjects;
using System;
using System.Collections.Generic;

namespace Leanda.Categories.Domain
{
public class CategoryTree : AggregateRoot
{
/// <summary>
/// User Id of the person who created the file
/// </summary>
public Guid CreatedBy { get; private set; }

/// <summary>
/// Date and time when file was created
/// </summary>
public DateTimeOffset CreatedDateTime { get; private set; }

/// <summary>
/// User Id of person who changed the file last time
/// </summary>
public Guid UpdatedBy { get; protected set; }

/// <summary>
/// Date and time when file was changed last time
/// </summary>
public DateTimeOffset UpdatedDateTime { get; protected set; }

public List<TreeNode> Nodes { get; protected set; }

private void Apply(CategoryTreeCreated e)
{
CreatedBy = e.UserId;
CreatedDateTime = e.TimeStamp;
UpdatedBy = e.UserId;
UpdatedDateTime = e.TimeStamp;
Nodes = e.Nodes;
}

private void Apply(CategoryTreeUpdated e)
{
UpdatedBy = e.UserId;
UpdatedDateTime = e.TimeStamp;

if (e.ParentId == null)
{
Nodes = e.Nodes;
}
else
{
Nodes.UpdateCategoryNodeById(e.Id, e.Nodes);
}
}

private void Apply(CategoryTreeNodeDeleted e)
{
UpdatedBy = e.UserId;
UpdatedDateTime = e.TimeStamp;
Nodes.DeleteCategoryNodeById(e.Id);
}

protected CategoryTree()
{
}

public CategoryTree(Guid id, Guid userId, List<TreeNode> nodes)
{
Id = id;
ApplyChange(new CategoryTreeCreated(Id, userId, nodes));
}

public void Update(Guid userId, Guid? parentId, List<TreeNode> nodes)
{
ApplyChange(new CategoryTreeUpdated(Id, userId, parentId, nodes));
}

public void DeleteNode(Guid userId, Guid nodeId)
{
ApplyChange(new CategoryTreeNodeDeleted(Id, userId, nodeId));
}

public void Delete(Guid userId)
{
ApplyChange(new CategoryTreeDeleted(Id, userId));
}
}
}
14 changes: 14 additions & 0 deletions Leanda.Categories/Domain/Commands/AddEntityCategories.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MassTransit;
using System;
using System.Collections.Generic;

namespace Leanda.Categories.Domain.Commands
{
public interface AddEntityCategories : CorrelatedBy<Guid>
{
Guid Id { get; }
Guid EntityId { get; }
IEnumerable<Guid> CategoriesIds { get; }
Guid UserId { get; }
}
}
Loading