├── .gitignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── LICENSE ├── README.md ├── media ├── sello.png └── sello.vsdx └── src ├── Sello.Model ├── Sello.Model.csproj ├── ShipmentItem.cs ├── ShipmentRequest.cs ├── StockRequest.cs ├── StockResponse.cs └── StockUpdateRequest.cs ├── Sello.OrderService ├── .vscode │ ├── launch.json │ └── tasks.json ├── Controllers │ ├── HealthController.cs │ └── OrderController.cs ├── Dockerfile ├── Model │ ├── Customer.cs │ ├── Order.cs │ └── OrderItem.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Sello.OrderService.Open-Api.xml ├── Sello.OrderService.csproj ├── Startup.cs └── appsettings.json ├── Sello.ShipmentService ├── .funcignore ├── .gitignore ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── DockerFile ├── ProcessShipmentQueue │ └── workflow.json ├── Sello.ShipmentService.code-workspace ├── Sello.ShipmentService.csproj ├── SelloShipmentFunction.cs ├── ShipmentQueue │ └── workflow.json ├── connections.json ├── host.json ├── nuget.config └── workflow-designtime │ └── host.json ├── Sello.WarehouseService ├── .funcignore ├── .gitignore ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── DockerFile ├── GetStock │ └── workflow.json ├── Sello.WarehouseService.code-workspace ├── Sello.WarehouseService.csproj ├── UpdateStock │ └── workflow.json ├── connections.json ├── host.json ├── nuget.config └── workflow-designtime │ └── host.json ├── Sello.code-workspace └── Sello.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions", 4 | "ms-dotnettools.csharp" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Attach to .NET Functions", 6 | "type": "coreclr", 7 | "request": "attach", 8 | "processId": "${command:azureFunctions.pickProcess}" 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "azureFunctions.deploySubpath": "src\\Sello.ShipmentService/bin/Release/netcoreapp3.1/publish", 3 | "azureFunctions.projectLanguage": "C#", 4 | "azureFunctions.projectRuntime": "~3", 5 | "debug.internalConsoleOptions": "neverOpen", 6 | "azureFunctions.preDeployTask": "publish" 7 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "clean", 6 | "command": "dotnet", 7 | "args": [ 8 | "clean", 9 | "/property:GenerateFullPaths=true", 10 | "/consoleloggerparameters:NoSummary" 11 | ], 12 | "type": "process", 13 | "problemMatcher": "$msCompile", 14 | "options": { 15 | "cwd": "${workspaceFolder}/src\\Sello.ShipmentService" 16 | } 17 | }, 18 | { 19 | "label": "build", 20 | "command": "dotnet", 21 | "args": [ 22 | "build", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "type": "process", 27 | "dependsOn": "clean", 28 | "group": { 29 | "kind": "build", 30 | "isDefault": true 31 | }, 32 | "problemMatcher": "$msCompile", 33 | "options": { 34 | "cwd": "${workspaceFolder}/src\\Sello.ShipmentService" 35 | } 36 | }, 37 | { 38 | "label": "clean release", 39 | "command": "dotnet", 40 | "args": [ 41 | "clean", 42 | "--configuration", 43 | "Release", 44 | "/property:GenerateFullPaths=true", 45 | "/consoleloggerparameters:NoSummary" 46 | ], 47 | "type": "process", 48 | "problemMatcher": "$msCompile", 49 | "options": { 50 | "cwd": "${workspaceFolder}/src\\Sello.ShipmentService" 51 | } 52 | }, 53 | { 54 | "label": "publish", 55 | "command": "dotnet", 56 | "args": [ 57 | "publish", 58 | "--configuration", 59 | "Release", 60 | "/property:GenerateFullPaths=true", 61 | "/consoleloggerparameters:NoSummary" 62 | ], 63 | "type": "process", 64 | "dependsOn": "clean release", 65 | "problemMatcher": "$msCompile", 66 | "options": { 67 | "cwd": "${workspaceFolder}/src\\Sello.ShipmentService" 68 | } 69 | }, 70 | { 71 | "type": "func", 72 | "dependsOn": "build", 73 | "options": { 74 | "cwd": "${workspaceFolder}/src\\Sello.ShipmentService/bin/Debug/netcoreapp3.1" 75 | }, 76 | "command": "host start", 77 | "isBackground": true, 78 | "problemMatcher": "$func-watch" 79 | } 80 | ] 81 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Codit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sello E-Commerce Platform - Running Logic Apps Anywhere 2 | 3 | ## Scenario 4 | Sello provides an e-commerce platform allowing their customers to purchase products from the catalog and initiate shipments to their homes. 5 | 6 | They are planning on going to the cloud but unfortunately depend on legacy systems, such as a SQL Server database, and decided to use a multi-phase migration. 7 | 8 | As part of their application modernization, Sello wants to run cloud-native application on-premises to be ready when they migrate to the cloud. By packaging their apps as containers and run them on Kubernetes on-premises in order to connect to their legacy systems such as SQL Server. 9 | 10 | Their landscape contains the following components: 11 | - An **Order service** where customers can create an order 12 | - This exposes a REST endpoint which is served by a .NET Core Web API. Every order request will check the warehouse service to see if the order is available and initiate a shipment 13 | - A **Warehouse service** to manage the stock of products that are available 14 | - Provides REST endpoint to verify stock of a product and update it once shipments are initiated. All stock information is stored in an on-premises SQL database. 15 | - A **Shipment service** to initiate shipments for orders 16 | - Provides a REST endpoint to accept new shipment requests which will be handled asynchronously 17 | 18 | ![Sello Overview](./media/sello.png) 19 | 20 | ## How to run it? 21 | 22 | ### Pre-requisites 23 | 24 | Create a product table in a (local) sql server 25 | 26 | ```sql 27 | CREATE TABLE [dbo].[Product]( 28 | [Id] [int] IDENTITY(1,1) NOT NULL, 29 | [Description] [varchar](500) NOT NULL, 30 | [Stock] [int] NOT NULL) 31 | ``` 32 | 33 | ### Running our services 34 | 35 | #### Running the Warehouse service 36 | 37 | We'll start by building the image: 38 | 39 | ```shell 40 | ❯ docker build .\src\ --tag sello-warehouseservice -f .\src\Sello.WarehouseService\Dockerfile --no-cache 41 | ``` 42 | 43 | You can easily run the service locally: 44 | 45 | ```shell 46 | ❯ docker run -d -p 5002:80 -e "AzureWebJobsStorage=" -e "sql-connectionString=" sello-warehouseservice 47 | ``` 48 | 49 | Get the callback URL for GetStock Logic App via cURL: 50 | ```shell 51 | ❯ curl --location --request POST 'http://localhost:5002/runtime/webhooks/flow/api/management/workflows/GetStock/triggers/manual/listCallbackUrl?api-version=2019-10-01-edge-preview&code=' --header "Content-Length: 0" 52 | { 53 | "value": "https://localhost:443/api/GetStock/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=", 54 | "method": "POST", 55 | "basePath": "https://localhost/api/GetStock/triggers/manual/invoke", 56 | "queries": { 57 | "api-version": "2020-05-01-preview", 58 | "sp": "/triggers/manual/run", 59 | "sv": "1.0", 60 | "sig": "" 61 | } 62 | } 63 | 64 | > ⚠ *When using those trigger url's, don't forget to change the url for using in your docker container.* 65 | 66 | Get the callback URL for UpdateStock Logic App via cURL: 67 | ```shell 68 | ❯ curl --location --request POST 'http://localhost:5002/runtime/webhooks/flow/api/management/workflows/UpdateStock/triggers/manual/listCallbackUrl?api-version=2019-10-01-edge-preview&code=' --header "Content-Length: 0" 69 | { 70 | "value": "https://localhost:443/api/UpdateStock/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=", 71 | "method": "POST", 72 | "basePath": "https://localhost/api/UpdateStock/triggers/manual/invoke", 73 | "queries": { 74 | "api-version": "2020-05-01-preview", 75 | "sp": "/triggers/manual/run", 76 | "sv": "1.0", 77 | "sig": "" 78 | } 79 | } 80 | ``` 81 | 82 | #### Running the Shipment service 83 | 84 | We'll start by building the image: 85 | 86 | ```shell 87 | ❯ docker build .\src\ --tag sello-shipmentservice -f .\src\Sello.ShipmentService\Dockerfile --no-cache 88 | ``` 89 | 90 | You can easily run the service locally: 91 | 92 | ```shell 93 | ❯ docker run -d -p 5001:80 -e "AzureWebJobsStorage=" -e "servicebus-connectionString=" -e "warehouse_setstockurl=" sello-shipmentservice 94 | ``` 95 | 96 | Get the callback URL for ShipmentQueue Logic App via cURL: 97 | ```shell 98 | ❯ curl --location --request POST 'http://localhost:5001/runtime/webhooks/flow/api/management/workflows/ShipmentQueue/triggers/manual/listCallbackUrl?api-version=2019-10-01-edge-preview&code=' --header "Content-Length: 0" 99 | { 100 | "value": "https://localhost:443/api/ShipmentQueue/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=", 101 | "method": "POST", 102 | "basePath": "https://localhost/api/ShipmentQueue/triggers/manual/invoke", 103 | "queries": { 104 | "api-version": "2020-05-01-preview", 105 | "sp": "/triggers/manual/run", 106 | "sv": "1.0", 107 | "sig": "" 108 | } 109 | } 110 | ``` 111 | 112 | #### Running the Order API 113 | 114 | We'll start by building the image: 115 | 116 | ```shell 117 | ❯ docker build .\src\ --tag sello-orderservice -f .\src\Sello.OrderService\Dockerfile --no-cache 118 | ``` 119 | 120 | You can easily run the service locally: 121 | 122 | ```shell 123 | ❯ docker run -d -p 5000:80 -e "ShipmentService=" -e "StockService=" sello-orderservice 124 | ``` 125 | 126 | ##### Create an order 127 | 128 | Order Example 129 | ```json 130 | { 131 | "OrderNr":"ord_001", 132 | "OrderDate":"2020-08-20", 133 | "Customer":{ 134 | "Email":"customer@codit.eu", 135 | "Name":"Codit" 136 | }, 137 | "OrderItems":[ 138 | { 139 | "OrderLineNr":1, 140 | "ItemId":1, 141 | "Qty":2 142 | } 143 | ] 144 | } 145 | ``` 146 | 147 | ```shell 148 | ❯ curl --location --request POST --data 'http://localhost:5000/api/v1/order' --header "Content-Type: application/json" --header "X-API_KEY=" 149 | ``` 150 | -------------------------------------------------------------------------------- /media/sello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codit/logic-apps-anywhere/750cbdeb6f75eb69eef839dc46cc47f605a91436/media/sello.png -------------------------------------------------------------------------------- /media/sello.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codit/logic-apps-anywhere/750cbdeb6f75eb69eef839dc46cc47f605a91436/media/sello.vsdx -------------------------------------------------------------------------------- /src/Sello.Model/Sello.Model.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Sello.Model/ShipmentItem.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.Model 2 | { 3 | public class ShipmentItem 4 | { 5 | public int ItemId { get; set; } 6 | public int Qty { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Sello.Model/ShipmentRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Sello.Model 4 | { 5 | public class ShipmentRequest 6 | { 7 | public string CustomerName { get; set; } 8 | public string CustomerEmail { get; set; } 9 | public string OrderId { get; set; } 10 | public IList ShipmentItems { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Sello.Model/StockRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.Model 2 | { 3 | public class StockRequest 4 | { 5 | public int ItemId { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/Sello.Model/StockResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.Model 2 | { 3 | public class StockResponse 4 | { 5 | public int ItemId { get; set; } 6 | public int Stock { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Sello.Model/StockUpdateRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.Model 2 | { 3 | public class StockUpdateRequest 4 | { 5 | public int ItemId { get; set; } 6 | public int Qty { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Sello.OrderService/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Sello.OrderService.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Sello.OrderService.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Sello.OrderService.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Sello.OrderService.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/Controllers/HealthController.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.Extensions.Diagnostics.HealthChecks; 5 | using GuardNet; 6 | using Swashbuckle.AspNetCore.Filters; 7 | 8 | namespace Sello.OrderService.Controllers 9 | { 10 | /// 11 | /// API endpoint to check the health of the application. 12 | /// 13 | [ApiController] 14 | [Route("api/v1/health")] 15 | public class HealthController : ControllerBase 16 | { 17 | private readonly HealthCheckService _healthCheckService; 18 | 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The service to provide the health of the API application. 23 | public HealthController(HealthCheckService healthCheckService) 24 | { 25 | Guard.NotNull(healthCheckService, nameof(healthCheckService)); 26 | 27 | _healthCheckService = healthCheckService; 28 | } 29 | 30 | /// 31 | /// Get Health 32 | /// 33 | /// Provides an indication about the health of the API. 34 | /// API is healthy 35 | /// API is unhealthy or in degraded state 36 | [HttpGet(Name = "Health_Get")] 37 | [ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)] 38 | [ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)] 39 | [SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] 40 | [SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] 41 | public async Task Get() 42 | { 43 | HealthReport healthReport = await _healthCheckService.CheckHealthAsync(); 44 | 45 | if (healthReport?.Status == HealthStatus.Healthy) 46 | { 47 | return Ok(healthReport); 48 | } 49 | else 50 | { 51 | return StatusCode(StatusCodes.Status503ServiceUnavailable, healthReport); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Controllers/OrderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net.Http; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Newtonsoft.Json; 9 | using Sello.Model; 10 | using Sello.OrderService.Model; 11 | using Swashbuckle.AspNetCore.Filters; 12 | using Microsoft.Extensions.Configuration; 13 | 14 | namespace Sello.OrderService.Controllers 15 | { 16 | [ApiController] 17 | [Route("api/v1/order")] 18 | public class OrderController : ControllerBase 19 | { 20 | private readonly IConfiguration _configuration; 21 | 22 | public OrderController(IConfiguration configuration) 23 | { 24 | _configuration = configuration; 25 | } 26 | 27 | /// 28 | /// 29 | /// 30 | /// 31 | /// 32 | [HttpPost(Name = "Order_Post")] 33 | [ProducesResponseType(typeof(Boolean), StatusCodes.Status200OK)] 34 | [ProducesResponseType(typeof(Boolean), StatusCodes.Status400BadRequest)] 35 | [ProducesResponseType(typeof(Boolean), StatusCodes.Status503ServiceUnavailable)] 36 | [SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] 37 | [SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] 38 | public async Task Create(Order order) 39 | { 40 | bool isValidOrder = true; 41 | foreach (var orderItem in order.OrderItems) 42 | { 43 | using (HttpClient client = new HttpClient()) 44 | { 45 | var stockRequest = new StockRequest { ItemId = orderItem.ItemId }; 46 | 47 | var content = new StringContent(JsonConvert.SerializeObject(stockRequest), Encoding.UTF8, "application/json"); 48 | var response = client.PostAsync(_configuration["StockService"], content).Result; 49 | 50 | var stockResponse = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); 51 | 52 | if (orderItem.Qty > stockResponse.Stock) 53 | { 54 | isValidOrder = false; 55 | break; 56 | } 57 | } 58 | 59 | } 60 | 61 | if (isValidOrder) 62 | { 63 | 64 | //Send shipment 65 | using (HttpClient client = new HttpClient()) 66 | { 67 | var shipmentRequest = new ShipmentRequest 68 | { 69 | CustomerEmail = order.Customer.Email, 70 | CustomerName = order.Customer.Name, 71 | OrderId = order.OrderNr, 72 | ShipmentItems = order.OrderItems.Select(o => new ShipmentItem { ItemId = o.ItemId, Qty = o.Qty }).ToList() 73 | }; 74 | 75 | var content = new StringContent(JsonConvert.SerializeObject(shipmentRequest), Encoding.UTF8, "application/json"); 76 | var result = await client.PostAsync(_configuration["ShipmentService"], content); 77 | } 78 | 79 | 80 | return Ok(); 81 | } 82 | else 83 | return BadRequest("No stock available"); 84 | 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.4-alpine3.10 AS base 2 | WORKDIR /app 3 | EXPOSE 80 4 | 5 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build 6 | WORKDIR /src 7 | COPY . ./ 8 | WORKDIR "/src/." 9 | RUN dotnet build Sello.OrderService -c Release -o /app 10 | 11 | FROM build AS publish 12 | RUN dotnet publish Sello.OrderService -c Release -o /app 13 | 14 | FROM base AS final 15 | WORKDIR /app 16 | COPY --from=publish /app . 17 | ENTRYPOINT ["dotnet", "Sello.OrderService.dll"] 18 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Model/Customer.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.OrderService.Model 2 | { 3 | public class Customer 4 | { 5 | public string CustomerNr { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Email { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/Model/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Sello.OrderService.Model 5 | { 6 | public class Order 7 | { 8 | public string OrderNr { get; set; } 9 | public DateTime OrderDate { get; set; } 10 | 11 | public Customer Customer { get; set; } 12 | 13 | public IList OrderItems { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Model/OrderItem.cs: -------------------------------------------------------------------------------- 1 | namespace Sello.OrderService.Model 2 | { 3 | public class OrderItem 4 | { 5 | public int OrderLineNr { get; set; } 6 | 7 | public int ItemId { get; set; } 8 | 9 | public int Qty { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace Sello.OrderService 7 | { 8 | public class Program 9 | { 10 | public static int Main(string[] args) 11 | { 12 | CreateHostBuilder(args) 13 | .Build() 14 | .Run(); 15 | 16 | return 0; 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) 20 | { 21 | IConfiguration configuration = CreateConfiguration(args); 22 | IHostBuilder webHostBuilder = CreateHostBuilder(args, configuration); 23 | 24 | return webHostBuilder; 25 | } 26 | 27 | private static IConfiguration CreateConfiguration(string[] args) 28 | { 29 | IConfigurationRoot configuration = 30 | new ConfigurationBuilder() 31 | .AddCommandLine(args) 32 | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) 33 | .AddEnvironmentVariables() 34 | .Build(); 35 | 36 | return configuration; 37 | } 38 | 39 | private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration configuration) 40 | { 41 | string httpEndpointUrl = "http://+:" + configuration["ARCUS_HTTP_PORT"]; 42 | IHostBuilder webHostBuilder = 43 | Host.CreateDefaultBuilder(args) 44 | .ConfigureAppConfiguration(configBuilder => configBuilder.AddConfiguration(configuration)) 45 | .ConfigureSecretStore((config, stores) => 46 | { 47 | #if DEBUG 48 | stores.AddConfiguration(configuration); 49 | #endif 50 | stores.AddEnvironmentVariables(); 51 | }) 52 | .ConfigureWebHostDefaults(webBuilder => 53 | { 54 | webBuilder.ConfigureKestrel(kestrelServerOptions => kestrelServerOptions.AddServerHeader = false) 55 | .UseUrls(httpEndpointUrl) 56 | .ConfigureLogging(logging => logging.AddConsole()) 57 | .UseStartup(); 58 | }); 59 | 60 | return webHostBuilder; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:25233/", 7 | "sslPort": 44341 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Sello.OrderService": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 30 | "publishAllPorts": true, 31 | "useSSL": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Sello.OrderService/Sello.OrderService.Open-Api.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sello.OrderService 5 | 6 | 7 | 8 | 9 | API endpoint to check the health of the application. 10 | 11 | 12 | 13 | 14 | Initializes a new instance of the class. 15 | 16 | The service to provide the health of the API application. 17 | 18 | 19 | 20 | Get Health 21 | 22 | Provides an indication about the health of the API. 23 | API is healthy 24 | API is unhealthy or in degraded state 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Initializes a new instance of the class. 36 | 37 | 38 | 39 | 40 | Gets the configuration of key/value application properties. 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Sello.OrderService.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | true 6 | Sello.OrderService.Open-Api.xml 7 | Linux 8 | 9 | 10 | 11 | 12 | 13 | Always 14 | PreserveNewest 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Sello.OrderService/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text.Json.Serialization; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.AspNetCore.Mvc.Formatters; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.OpenApi.Models; 13 | using Swashbuckle.AspNetCore.Filters; 14 | 15 | namespace Sello.OrderService 16 | { 17 | public class Startup 18 | { 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | public Startup(IConfiguration configuration) 23 | { 24 | Configuration = configuration; 25 | } 26 | 27 | /// 28 | /// Gets the configuration of key/value application properties. 29 | /// 30 | public IConfiguration Configuration { get; } 31 | 32 | // This method gets called by the runtime. Use this method to add services to the container. 33 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 34 | public void ConfigureServices(IServiceCollection services) 35 | { 36 | services.AddRouting(options => 37 | { 38 | options.LowercaseUrls = true; 39 | options.LowercaseQueryStrings = true; 40 | }); 41 | services.AddControllers(options => 42 | { 43 | options.ReturnHttpNotAcceptable = true; 44 | options.RespectBrowserAcceptHeader = true; 45 | 46 | RestrictToJsonContentType(options); 47 | AddEnumAsStringRepresentation(options); 48 | }); 49 | 50 | services.AddHealthChecks(); 51 | services.AddHttpCorrelation(); 52 | 53 | var openApiInformation = new OpenApiInfo 54 | { 55 | Title = "Sello - Order API", 56 | Version = "v1" 57 | }; 58 | 59 | services.AddSwaggerGen(swaggerGenerationOptions => 60 | { 61 | swaggerGenerationOptions.SwaggerDoc("v1", openApiInformation); 62 | swaggerGenerationOptions.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Sello.OrderService.Open-Api.xml")); 63 | 64 | swaggerGenerationOptions.OperationFilter("X-Transaction-Id", "Transaction ID is used to correlate multiple operation calls. A new transaction ID will be generated if not specified.", false); 65 | swaggerGenerationOptions.OperationFilter(); 66 | }); 67 | } 68 | 69 | private static void RestrictToJsonContentType(MvcOptions options) 70 | { 71 | var allButJsonInputFormatters = options.InputFormatters.Where(formatter => !(formatter is SystemTextJsonInputFormatter)); 72 | foreach (IInputFormatter inputFormatter in allButJsonInputFormatters) 73 | { 74 | options.InputFormatters.Remove(inputFormatter); 75 | } 76 | 77 | // Removing for text/plain, see https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-3.0#special-case-formatters 78 | options.OutputFormatters.RemoveType(); 79 | } 80 | 81 | private static void AddEnumAsStringRepresentation(MvcOptions options) 82 | { 83 | var onlyJsonInputFormatters = options.InputFormatters.OfType(); 84 | foreach (SystemTextJsonInputFormatter inputFormatter in onlyJsonInputFormatters) 85 | { 86 | inputFormatter.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); 87 | } 88 | 89 | var onlyJsonOutputFormatters = options.OutputFormatters.OfType(); 90 | foreach (SystemTextJsonOutputFormatter outputFormatter in onlyJsonOutputFormatters) 91 | { 92 | outputFormatter.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); 93 | } 94 | } 95 | 96 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 97 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 98 | { 99 | app.UseExceptionHandling(); 100 | app.UseHttpCorrelation(); 101 | app.UseRouting(); 102 | app.UseRequestTracking(); 103 | 104 | app.UseSwagger(swaggerOptions => 105 | { 106 | swaggerOptions.RouteTemplate = "api/{documentName}/docs.json"; 107 | }); 108 | app.UseSwaggerUI(swaggerUiOptions => 109 | { 110 | swaggerUiOptions.SwaggerEndpoint("/api/v1/docs.json", "Sello - Order API"); 111 | swaggerUiOptions.RoutePrefix = "api/docs"; 112 | swaggerUiOptions.DocumentTitle = "Sello - Order API"; 113 | }); 114 | app.UseEndpoints(endpoints => endpoints.MapControllers()); 115 | 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Sello.OrderService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MyConfigKey": "supersecretkey", 3 | "ShipmentService": "http://localhost:5001/api/ShipmentQueue/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=x-0HU1ugWPNc3ZQ_rwk6eS2ZAcMv27wmhnvtY6ZQTaw", 4 | "StockService": "http://localhost:5002/api/GetStock/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=m41j1CKBoEcoGkcv2YnyqaPiSYsNOpEymLker-NwUww" 5 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.funcignore: -------------------------------------------------------------------------------- 1 | workflow-designtime/ -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # Azure Functions localsettings file 5 | local.settings.json 6 | 7 | # User-specific files 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # MSTest test Results 34 | [Tt]est[Rr]esult*/ 35 | [Bb]uild[Ll]og.* 36 | 37 | # NUNIT 38 | *.VisualState.xml 39 | TestResult.xml 40 | 41 | # Build Results of an ATL Project 42 | [Dd]ebugPS/ 43 | [Rr]eleasePS/ 44 | dlldata.c 45 | 46 | # DNX 47 | project.lock.json 48 | project.fragment.lock.json 49 | artifacts/ 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # NCrunch 117 | _NCrunch_* 118 | .*crunch*.local.xml 119 | nCrunchTemp_* 120 | 121 | # MightyMoose 122 | *.mm.* 123 | AutoTest.Net/ 124 | 125 | # Web workbench (sass) 126 | .sass-cache/ 127 | 128 | # Installshield output folder 129 | [Ee]xpress/ 130 | 131 | # DocProject is a documentation generator add-in 132 | DocProject/buildhelp/ 133 | DocProject/Help/*.HxT 134 | DocProject/Help/*.HxC 135 | DocProject/Help/*.hhc 136 | DocProject/Help/*.hhk 137 | DocProject/Help/*.hhp 138 | DocProject/Help/Html2 139 | DocProject/Help/html 140 | 141 | # Click-Once directory 142 | publish/ 143 | 144 | # Publish Web Output 145 | *.[Pp]ublish.xml 146 | *.azurePubxml 147 | # TODO: Comment the next line if you want to checkin your web deploy settings 148 | # but database connection strings (with potential passwords) will be unencrypted 149 | #*.pubxml 150 | *.publishproj 151 | 152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 153 | # checkin your Azure Web App publish settings, but sensitive information contained 154 | # in these scripts will be unencrypted 155 | PublishScripts/ 156 | 157 | # NuGet Packages 158 | *.nupkg 159 | # The packages folder can be ignored because of Package Restore 160 | **/packages/* 161 | # except build/, which is used as an MSBuild target. 162 | !**/packages/build/ 163 | # Uncomment if necessary however generally it will be regenerated when needed 164 | #!**/packages/repositories.config 165 | # NuGet v3's project.json files produces more ignoreable files 166 | *.nuget.props 167 | *.nuget.targets 168 | 169 | # Microsoft Azure Build Output 170 | csx/ 171 | *.build.csdef 172 | 173 | # Microsoft Azure Emulator 174 | ecf/ 175 | rcf/ 176 | 177 | # Windows Store app package directories and files 178 | AppPackages/ 179 | BundleArtifacts/ 180 | Package.StoreAssociation.xml 181 | _pkginfo.txt 182 | 183 | # Visual Studio cache files 184 | # files ending in .cache can be ignored 185 | *.[Cc]ache 186 | # but keep track of directories ending in .cache 187 | !*.[Cc]ache/ 188 | 189 | # Others 190 | ClientBin/ 191 | ~$* 192 | *~ 193 | *.dbmdl 194 | *.dbproj.schemaview 195 | *.jfm 196 | *.pfx 197 | *.publishsettings 198 | node_modules/ 199 | orleans.codegen.cs 200 | 201 | # Since there are multiple workflows, uncomment next line to ignore bower_components 202 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 203 | #bower_components/ 204 | 205 | # RIA/Silverlight projects 206 | Generated_Code/ 207 | 208 | # Backup & report files from converting an old project file 209 | # to a newer Visual Studio version. Backup files are not needed, 210 | # because we have git ;-) 211 | _UpgradeReport_Files/ 212 | Backup*/ 213 | UpgradeLog*.XML 214 | UpgradeLog*.htm 215 | 216 | # SQL Server files 217 | *.mdf 218 | *.ldf 219 | 220 | # Business Intelligence projects 221 | *.rdl.data 222 | *.bim.layout 223 | *.bim_*.settings 224 | 225 | # Microsoft Fakes 226 | FakesAssemblies/ 227 | 228 | # GhostDoc plugin setting file 229 | *.GhostDoc.xml 230 | 231 | # Node.js Tools for Visual Studio 232 | .ntvs_analysis.dat 233 | 234 | # Visual Studio 6 build log 235 | *.plg 236 | 237 | # Visual Studio 6 workspace options file 238 | *.opt 239 | 240 | # Visual Studio LightSwitch build output 241 | **/*.HTMLClient/GeneratedArtifacts 242 | **/*.DesktopClient/GeneratedArtifacts 243 | **/*.DesktopClient/ModelManifest.xml 244 | **/*.Server/GeneratedArtifacts 245 | **/*.Server/ModelManifest.xml 246 | _Pvt_Extensions 247 | 248 | # Paket dependency manager 249 | .paket/paket.exe 250 | paket-files/ 251 | 252 | # FAKE - F# Make 253 | .fake/ 254 | 255 | # JetBrains Rider 256 | .idea/ 257 | *.sln.iml 258 | 259 | # CodeRush 260 | .cr/ 261 | 262 | # Python Tools for Visual Studio (PTVS) 263 | __pycache__/ 264 | *.pyc -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions", 4 | "ms-dotnettools.csharp" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | 5 | { 6 | "name": "Attach to .NET Functions", 7 | "type": "coreclr", 8 | "request": "attach", 9 | "processId": "${command:azureFunctions.pickProcess}" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish", 3 | "azureFunctions.projectLanguage": "C#", 4 | "azureFunctions.projectRuntime": "~3", 5 | "debug.internalConsoleOptions": "neverOpen", 6 | "azureFunctions.preDeployTask": "publish" 7 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "clean", 6 | "command": "dotnet", 7 | "args": [ 8 | "clean", 9 | "/property:GenerateFullPaths=true", 10 | "/consoleloggerparameters:NoSummary" 11 | ], 12 | "type": "process", 13 | "problemMatcher": "$msCompile" 14 | }, 15 | { 16 | "label": "build", 17 | "command": "dotnet", 18 | "args": [ 19 | "build", 20 | "/property:GenerateFullPaths=true", 21 | "/consoleloggerparameters:NoSummary" 22 | ], 23 | "type": "process", 24 | "dependsOn": "clean", 25 | "group": { 26 | "kind": "build", 27 | "isDefault": true 28 | }, 29 | "problemMatcher": "$msCompile" 30 | }, 31 | { 32 | "label": "clean release", 33 | "command": "dotnet", 34 | "args": [ 35 | "clean", 36 | "--configuration", 37 | "Release", 38 | "/property:GenerateFullPaths=true", 39 | "/consoleloggerparameters:NoSummary" 40 | ], 41 | "type": "process", 42 | "problemMatcher": "$msCompile" 43 | }, 44 | { 45 | "label": "publish", 46 | "command": "dotnet", 47 | "args": [ 48 | "publish", 49 | "--configuration", 50 | "Release", 51 | "/property:GenerateFullPaths=true", 52 | "/consoleloggerparameters:NoSummary" 53 | ], 54 | "type": "process", 55 | "dependsOn": "clean release", 56 | "problemMatcher": "$msCompile" 57 | }, 58 | { 59 | "type": "func", 60 | "dependsOn": "build", 61 | "options": { 62 | "cwd": "${workspaceFolder}/bin/Debug/netcoreapp3.1" 63 | }, 64 | "command": "host start", 65 | "isBackground": true, 66 | "problemMatcher": "$func-watch" 67 | } 68 | ] 69 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/DockerFile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1.300 AS build 2 | WORKDIR /src 3 | COPY . ./ 4 | RUN dotnet publish Sello.ShipmentService --configuration release --output app 5 | 6 | FROM mcr.microsoft.com/azure-functions/dotnet:3.0.13614-appservice as runtime 7 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true 8 | # Set required environment variables, see https://github.com/Azure/logicapps/issues/129 9 | ENV WEBSITE_HOSTNAME localhost 10 | ENV WEBSITE_SITE_NAME Sello.ShipmentService 11 | ENV AZURE_FUNCTIONS_ENVIRONMENT Development 12 | 13 | COPY --from=build /src/app /home/site/wwwroot -------------------------------------------------------------------------------- /src/Sello.ShipmentService/ProcessShipmentQueue/workflow.json: -------------------------------------------------------------------------------- 1 | { 2 | "definition": { 3 | "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", 4 | "actions": { 5 | "For_each": { 6 | "type": "Foreach", 7 | "foreach": "@triggerOutputs()?['body']", 8 | "actions": { 9 | "Invoke_a_function_in_this_function_app": { 10 | "type": "InvokeFunction", 11 | "inputs": { 12 | "functionName": "SelloShipmentFunction", 13 | "parameters": "@json(item()?['contentData'])" 14 | }, 15 | "runAfter": {} 16 | } 17 | }, 18 | "runAfter": {} 19 | } 20 | }, 21 | "triggers": { 22 | "When_messages_are_available_in_Service_Bus_queue": { 23 | "type": "ServiceProvider", 24 | "inputs": { 25 | "parameters": { 26 | "queueName": "selloshipmentqueue" 27 | }, 28 | "serviceProviderConfiguration": { 29 | "connectionName": "serviceBus", 30 | "operationId": "receiveQueueMessages", 31 | "serviceProviderId": "/serviceProviders/serviceBus" 32 | } 33 | } 34 | } 35 | }, 36 | "contentVersion": "1.0.0.0", 37 | "outputs": {} 38 | }, 39 | "kind": "Stateful" 40 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/Sello.ShipmentService.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "..\\Sello.Model" 8 | } 9 | ], 10 | "settings": { 11 | "debug.internalConsoleOptions": "neverOpen" 12 | } 13 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/Sello.ShipmentService.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | v3 6 | 7 | 8 | 9 | 10 | 11 | 12 | PreserveNewest 13 | 14 | 15 | PreserveNewest 16 | Never 17 | 18 | 19 | 20 | 21 | PreserveNewest 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | 36 | 37 | PreserveNewest 38 | 39 | 40 | 41 | 42 | PreserveNewest 43 | 44 | 45 | 46 | 47 | PreserveNewest 48 | 49 | 50 | 51 | 52 | PreserveNewest 53 | 54 | 55 | 56 | 57 | PreserveNewest 58 | 59 | 60 | 61 | 62 | PreserveNewest 63 | 64 | 65 | 66 | 67 | PreserveNewest 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/Sello.ShipmentService/SelloShipmentFunction.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Azure.WebJobs; 2 | using Microsoft.Extensions.Logging; 3 | using Newtonsoft.Json; 4 | using Microsoft.Azure.Workflows.WebJobs.Extensions.Trigger; 5 | using Newtonsoft.Json.Linq; 6 | using Sello.Model; 7 | using System.Net.Http; 8 | using System.Text; 9 | 10 | namespace Company.Function 11 | { 12 | public static class SelloShipmentFunction 13 | { 14 | [FunctionName("SelloShipmentFunction")] 15 | public static JToken Run( 16 | [WorkflowActionTrigger] JToken parameters, 17 | ILogger log) 18 | { 19 | var shipmentRequest = parameters.Root.ToObject(); 20 | 21 | //Update Stock 22 | foreach (var item in shipmentRequest.ShipmentItems) 23 | { 24 | using (var httpClient = new HttpClient()) 25 | { 26 | var stockUpdateRequest = new StockUpdateRequest 27 | { 28 | ItemId = item.ItemId, 29 | Qty = item.Qty * -1 30 | }; 31 | var content = new StringContent(JsonConvert.SerializeObject(stockUpdateRequest), Encoding.UTF8, "application/json"); 32 | 33 | var response = httpClient.PostAsync(System.Environment.GetEnvironmentVariable("warehouse_setstockurl"), content).Result; 34 | } 35 | } 36 | 37 | 38 | return new JObject { { "Message", $"Shipment for order: {shipmentRequest.OrderId} succeeded" } }; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Sello.ShipmentService/ShipmentQueue/workflow.json: -------------------------------------------------------------------------------- 1 | { 2 | "definition": { 3 | "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", 4 | "actions": { 5 | "Send_Message": { 6 | "type": "ServiceProvider", 7 | "inputs": { 8 | "parameters": { 9 | "entityName": "selloshipmentqueue", 10 | "message": { 11 | "contentData": "@string(triggerBody())" 12 | } 13 | }, 14 | "serviceProviderConfiguration": { 15 | "connectionName": "serviceBus", 16 | "operationId": "sendMessage", 17 | "serviceProviderId": "/serviceProviders/serviceBus" 18 | } 19 | }, 20 | "runAfter": {} 21 | } 22 | }, 23 | "triggers": { 24 | "manual": { 25 | "type": "Request", 26 | "kind": "Http", 27 | "inputs": { 28 | "schema": { 29 | "type": "object", 30 | "properties": { 31 | "customerName": { 32 | "type": "string" 33 | }, 34 | "customerEmail": { 35 | "type": "string" 36 | }, 37 | "shipmentItems": { 38 | "type": "array", 39 | "items": { 40 | "type": "object", 41 | "properties": { 42 | "itemId": { 43 | "type": "integer" 44 | }, 45 | "Qty": { 46 | "type": "integer" 47 | } 48 | }, 49 | "required": [ 50 | "itemId", 51 | "Qty" 52 | ] 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | }, 60 | "contentVersion": "1.0.0.0", 61 | "outputs": {} 62 | }, 63 | "kind": "Stateful" 64 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/connections.json: -------------------------------------------------------------------------------- 1 | { 2 | "serviceProviderConnections": { 3 | "serviceBus": { 4 | "displayName": "SelloSB", 5 | "parameterValues": { 6 | "connectionString": "@appsetting('serviceBus-connectionString')" 7 | }, 8 | "serviceProvider": { 9 | "id": "/serviceProviders/serviceBus" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Sello.ShipmentService/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingExcludedTypes": "Request", 6 | "samplingSettings": { 7 | "isEnabled": true 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Sello.ShipmentService/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Sello.ShipmentService/workflow-designtime/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "extensionBundle": { 4 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows", 5 | "version": "[1.*, 2.0.0)" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.funcignore: -------------------------------------------------------------------------------- 1 | workflow-designtime/ -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # Azure Functions localsettings file 5 | local.settings.json 6 | 7 | # User-specific files 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # MSTest test Results 34 | [Tt]est[Rr]esult*/ 35 | [Bb]uild[Ll]og.* 36 | 37 | # NUNIT 38 | *.VisualState.xml 39 | TestResult.xml 40 | 41 | # Build Results of an ATL Project 42 | [Dd]ebugPS/ 43 | [Rr]eleasePS/ 44 | dlldata.c 45 | 46 | # DNX 47 | project.lock.json 48 | project.fragment.lock.json 49 | artifacts/ 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # NCrunch 117 | _NCrunch_* 118 | .*crunch*.local.xml 119 | nCrunchTemp_* 120 | 121 | # MightyMoose 122 | *.mm.* 123 | AutoTest.Net/ 124 | 125 | # Web workbench (sass) 126 | .sass-cache/ 127 | 128 | # Installshield output folder 129 | [Ee]xpress/ 130 | 131 | # DocProject is a documentation generator add-in 132 | DocProject/buildhelp/ 133 | DocProject/Help/*.HxT 134 | DocProject/Help/*.HxC 135 | DocProject/Help/*.hhc 136 | DocProject/Help/*.hhk 137 | DocProject/Help/*.hhp 138 | DocProject/Help/Html2 139 | DocProject/Help/html 140 | 141 | # Click-Once directory 142 | publish/ 143 | 144 | # Publish Web Output 145 | *.[Pp]ublish.xml 146 | *.azurePubxml 147 | # TODO: Comment the next line if you want to checkin your web deploy settings 148 | # but database connection strings (with potential passwords) will be unencrypted 149 | #*.pubxml 150 | *.publishproj 151 | 152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 153 | # checkin your Azure Web App publish settings, but sensitive information contained 154 | # in these scripts will be unencrypted 155 | PublishScripts/ 156 | 157 | # NuGet Packages 158 | *.nupkg 159 | # The packages folder can be ignored because of Package Restore 160 | **/packages/* 161 | # except build/, which is used as an MSBuild target. 162 | !**/packages/build/ 163 | # Uncomment if necessary however generally it will be regenerated when needed 164 | #!**/packages/repositories.config 165 | # NuGet v3's project.json files produces more ignoreable files 166 | *.nuget.props 167 | *.nuget.targets 168 | 169 | # Microsoft Azure Build Output 170 | csx/ 171 | *.build.csdef 172 | 173 | # Microsoft Azure Emulator 174 | ecf/ 175 | rcf/ 176 | 177 | # Windows Store app package directories and files 178 | AppPackages/ 179 | BundleArtifacts/ 180 | Package.StoreAssociation.xml 181 | _pkginfo.txt 182 | 183 | # Visual Studio cache files 184 | # files ending in .cache can be ignored 185 | *.[Cc]ache 186 | # but keep track of directories ending in .cache 187 | !*.[Cc]ache/ 188 | 189 | # Others 190 | ClientBin/ 191 | ~$* 192 | *~ 193 | *.dbmdl 194 | *.dbproj.schemaview 195 | *.jfm 196 | *.pfx 197 | *.publishsettings 198 | node_modules/ 199 | orleans.codegen.cs 200 | 201 | # Since there are multiple workflows, uncomment next line to ignore bower_components 202 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 203 | #bower_components/ 204 | 205 | # RIA/Silverlight projects 206 | Generated_Code/ 207 | 208 | # Backup & report files from converting an old project file 209 | # to a newer Visual Studio version. Backup files are not needed, 210 | # because we have git ;-) 211 | _UpgradeReport_Files/ 212 | Backup*/ 213 | UpgradeLog*.XML 214 | UpgradeLog*.htm 215 | 216 | # SQL Server files 217 | *.mdf 218 | *.ldf 219 | 220 | # Business Intelligence projects 221 | *.rdl.data 222 | *.bim.layout 223 | *.bim_*.settings 224 | 225 | # Microsoft Fakes 226 | FakesAssemblies/ 227 | 228 | # GhostDoc plugin setting file 229 | *.GhostDoc.xml 230 | 231 | # Node.js Tools for Visual Studio 232 | .ntvs_analysis.dat 233 | 234 | # Visual Studio 6 build log 235 | *.plg 236 | 237 | # Visual Studio 6 workspace options file 238 | *.opt 239 | 240 | # Visual Studio LightSwitch build output 241 | **/*.HTMLClient/GeneratedArtifacts 242 | **/*.DesktopClient/GeneratedArtifacts 243 | **/*.DesktopClient/ModelManifest.xml 244 | **/*.Server/GeneratedArtifacts 245 | **/*.Server/ModelManifest.xml 246 | _Pvt_Extensions 247 | 248 | # Paket dependency manager 249 | .paket/paket.exe 250 | paket-files/ 251 | 252 | # FAKE - F# Make 253 | .fake/ 254 | 255 | # JetBrains Rider 256 | .idea/ 257 | *.sln.iml 258 | 259 | # CodeRush 260 | .cr/ 261 | 262 | # Python Tools for Visual Studio (PTVS) 263 | __pycache__/ 264 | *.pyc -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions", 4 | "ms-dotnettools.csharp" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | 5 | { 6 | "name": "Attach to .NET Functions", 7 | "type": "coreclr", 8 | "request": "attach", 9 | "processId": "${command:azureFunctions.pickProcess}" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish", 3 | "azureFunctions.projectLanguage": "C#", 4 | "azureFunctions.projectRuntime": "~3", 5 | "debug.internalConsoleOptions": "neverOpen", 6 | "azureFunctions.preDeployTask": "publish" 7 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "clean", 6 | "command": "dotnet", 7 | "args": [ 8 | "clean", 9 | "/property:GenerateFullPaths=true", 10 | "/consoleloggerparameters:NoSummary" 11 | ], 12 | "type": "process", 13 | "problemMatcher": "$msCompile" 14 | }, 15 | { 16 | "label": "build", 17 | "command": "dotnet", 18 | "args": [ 19 | "build", 20 | "/property:GenerateFullPaths=true", 21 | "/consoleloggerparameters:NoSummary" 22 | ], 23 | "type": "process", 24 | "dependsOn": "clean", 25 | "group": { 26 | "kind": "build", 27 | "isDefault": true 28 | }, 29 | "problemMatcher": "$msCompile" 30 | }, 31 | { 32 | "label": "clean release", 33 | "command": "dotnet", 34 | "args": [ 35 | "clean", 36 | "--configuration", 37 | "Release", 38 | "/property:GenerateFullPaths=true", 39 | "/consoleloggerparameters:NoSummary" 40 | ], 41 | "type": "process", 42 | "problemMatcher": "$msCompile" 43 | }, 44 | { 45 | "label": "publish", 46 | "command": "dotnet", 47 | "args": [ 48 | "publish", 49 | "--configuration", 50 | "Release", 51 | "/property:GenerateFullPaths=true", 52 | "/consoleloggerparameters:NoSummary" 53 | ], 54 | "type": "process", 55 | "dependsOn": "clean release", 56 | "problemMatcher": "$msCompile" 57 | }, 58 | { 59 | "type": "func", 60 | "dependsOn": "build", 61 | "options": { 62 | "cwd": "${workspaceFolder}/bin/Debug/netcoreapp3.1" 63 | }, 64 | "command": "host start", 65 | "isBackground": true, 66 | "problemMatcher": "$func-watch" 67 | } 68 | ] 69 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/DockerFile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1.300 AS build 2 | WORKDIR /src 3 | COPY . ./ 4 | RUN dotnet publish Sello.WarehouseService --configuration release --output app 5 | 6 | FROM mcr.microsoft.com/azure-functions/dotnet:3.0.13614-appservice as runtime 7 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true 8 | # Set required environment variables, see https://github.com/Azure/logicapps/issues/129 9 | ENV WEBSITE_HOSTNAME localhost 10 | ENV WEBSITE_SITE_NAME Sello.WarehouseService 11 | ENV AZURE_FUNCTIONS_ENVIRONMENT Development 12 | 13 | COPY --from=build /src/app /home/site/wwwroot -------------------------------------------------------------------------------- /src/Sello.WarehouseService/GetStock/workflow.json: -------------------------------------------------------------------------------- 1 | { 2 | "definition": { 3 | "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", 4 | "actions": { 5 | "Execute_Query": { 6 | "type": "ServiceProvider", 7 | "inputs": { 8 | "parameters": { 9 | "query": "SELECT Stock FROM PRODUCT WHERE Id = @{triggerBody()?['itemId']}" 10 | }, 11 | "serviceProviderConfiguration": { 12 | "connectionName": "sql", 13 | "operationId": "executeQuery", 14 | "serviceProviderId": "/serviceProviders/sql" 15 | } 16 | }, 17 | "runAfter": {} 18 | }, 19 | "Compose": { 20 | "type": "Compose", 21 | "inputs": { 22 | "itemId": "@triggerBody()?['itemId']", 23 | "stock": "@outputs('Execute_Query')?['body'][0][0]['Stock']" 24 | }, 25 | "runAfter": { 26 | "Execute_Query": [ 27 | "Succeeded" 28 | ] 29 | } 30 | }, 31 | "Response": { 32 | "type": "Response", 33 | "kind": "http", 34 | "inputs": { 35 | "statusCode": 200, 36 | "body": "@outputs('Compose')" 37 | }, 38 | "runAfter": { 39 | "Compose": [ 40 | "Succeeded" 41 | ] 42 | } 43 | } 44 | }, 45 | "triggers": { 46 | "manual": { 47 | "type": "Request", 48 | "kind": "Http", 49 | "inputs": { 50 | "schema": { 51 | "type": "object", 52 | "properties": { 53 | "itemId": { 54 | "type": "integer" 55 | } 56 | } 57 | } 58 | } 59 | } 60 | }, 61 | "contentVersion": "1.0.0.0", 62 | "outputs": {} 63 | }, 64 | "kind": "Stateful" 65 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/Sello.WarehouseService.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "..\\Sello.Model" 8 | } 9 | ], 10 | "settings": { 11 | "debug.internalConsoleOptions": "neverOpen" 12 | } 13 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/Sello.WarehouseService.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | v3 6 | 7 | 8 | 9 | 10 | 11 | 12 | PreserveNewest 13 | 14 | 15 | PreserveNewest 16 | Never 17 | 18 | 19 | 20 | 21 | PreserveNewest 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | 33 | 34 | PreserveNewest 35 | 36 | 37 | 38 | 39 | PreserveNewest 40 | 41 | 42 | 43 | 44 | PreserveNewest 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/Sello.WarehouseService/UpdateStock/workflow.json: -------------------------------------------------------------------------------- 1 | { 2 | "definition": { 3 | "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", 4 | "actions": { 5 | "Execute_Query": { 6 | "type": "ServiceProvider", 7 | "inputs": { 8 | "parameters": { 9 | "query": "UPDATE PRODUCT SET Stock = Stock + @{triggerBody()?['qty']} WHERE Id = @{triggerBody()?['itemId']} ;" 10 | }, 11 | "serviceProviderConfiguration": { 12 | "connectionName": "sql", 13 | "operationId": "executeQuery", 14 | "serviceProviderId": "/serviceProviders/sql" 15 | } 16 | }, 17 | "runAfter": {} 18 | } 19 | }, 20 | "triggers": { 21 | "manual": { 22 | "type": "Request", 23 | "kind": "Http", 24 | "inputs": { 25 | "schema": { 26 | "type": "object", 27 | "properties": { 28 | "itemId": { 29 | "type": "integer" 30 | }, 31 | "qty": { 32 | "type": "integer" 33 | } 34 | } 35 | } 36 | } 37 | } 38 | }, 39 | "contentVersion": "1.0.0.0", 40 | "outputs": {} 41 | }, 42 | "kind": "Stateful" 43 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/connections.json: -------------------------------------------------------------------------------- 1 | { 2 | "serviceProviderConnections": { 3 | "sql": { 4 | "displayName": "localhost", 5 | "parameterValues": { 6 | "connectionString": "@appsetting('sql-connectionString')" 7 | }, 8 | "serviceProvider": { 9 | "id": "/serviceProviders/sql" 10 | } 11 | }, 12 | "serviceBus": { 13 | "displayName": "sb-test", 14 | "parameterValues": { 15 | "connectionString": "@appsetting('serviceBus-connectionString')" 16 | }, 17 | "serviceProvider": { 18 | "id": "/serviceProviders/serviceBus" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Sello.WarehouseService/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingExcludedTypes": "Request", 6 | "samplingSettings": { 7 | "isEnabled": true 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Sello.WarehouseService/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Sello.WarehouseService/workflow-designtime/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "extensionBundle": { 4 | "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows", 5 | "version": "[1.*, 2.0.0)" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/Sello.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "Sello.ShipmentService" 5 | }, 6 | { 7 | "path": "Sello.WarehouseService" 8 | }, 9 | { 10 | "path": "Sello.Model" 11 | } 12 | ], 13 | "settings": { 14 | "debug.internalConsoleOptions": "neverOpen" 15 | }, 16 | "launch": { 17 | "version": "0.2.0", 18 | "configurations": [] 19 | } 20 | } -------------------------------------------------------------------------------- /src/Sello.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sello.Model", "Sello.Model\Sello.Model.csproj", "{63D2DDE7-5C2A-445B-8311-1660FFB56408}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sello.OrderService", "Sello.OrderService\Sello.OrderService.csproj", "{F2923535-0243-4979-96A1-AF1B4FB5D740}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sello.ShipmentService", "Sello.ShipmentService\Sello.ShipmentService.csproj", "{E4A2809A-E2A5-4EE1-AF7C-294D172F5544}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sello.WarehouseService", "Sello.WarehouseService\Sello.WarehouseService.csproj", "{8FAE1F55-4718-4394-880D-0030FE89A699}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {63D2DDE7-5C2A-445B-8311-1660FFB56408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {63D2DDE7-5C2A-445B-8311-1660FFB56408}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {63D2DDE7-5C2A-445B-8311-1660FFB56408}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {63D2DDE7-5C2A-445B-8311-1660FFB56408}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {F2923535-0243-4979-96A1-AF1B4FB5D740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {F2923535-0243-4979-96A1-AF1B4FB5D740}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {F2923535-0243-4979-96A1-AF1B4FB5D740}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {F2923535-0243-4979-96A1-AF1B4FB5D740}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {E4A2809A-E2A5-4EE1-AF7C-294D172F5544}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {E4A2809A-E2A5-4EE1-AF7C-294D172F5544}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {E4A2809A-E2A5-4EE1-AF7C-294D172F5544}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {E4A2809A-E2A5-4EE1-AF7C-294D172F5544}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {8FAE1F55-4718-4394-880D-0030FE89A699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {8FAE1F55-4718-4394-880D-0030FE89A699}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {8FAE1F55-4718-4394-880D-0030FE89A699}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {8FAE1F55-4718-4394-880D-0030FE89A699}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {096F23BF-5562-4F14-9ECD-ABF8989C8AE5} 42 | EndGlobalSection 43 | EndGlobal 44 | --------------------------------------------------------------------------------