From 87375c38c460b59a7fc56e55ab511101bf528406 Mon Sep 17 00:00:00 2001 From: Bogdan Vizureanu Date: Thu, 27 Feb 2020 12:09:15 +0200 Subject: [PATCH 01/53] remove api --- .../MonitorizareVot.Ong.sln | 46 -- api/MonitorizareVot.Ong/NuGet.Config | 7 - .../Commands/ObserverAllCommand.cs | 16 - .../Commands/ObserverGenerateCommand.cs | 31 -- .../MonitorizareVot.Api/Common/Constants.cs | 11 - .../Common/JwtIssuerOptions.cs | 103 ----- .../Common/StatisticiQueryBuilder.cs | 75 ---- .../Controllers/Formulare.cs | 34 -- .../Controllers/JwtController.cs | 175 -------- .../MonitorizareVot.Api/Controllers/Note.cs | 37 -- .../Controllers/ObserverController.cs | 109 ----- .../Controllers/Raspunsuri.cs | 82 ---- .../Controllers/Statistici.cs | 330 -------------- .../Extensions/ControllerExtensions.cs | 45 -- .../Extensions/ListExtensions.cs | 16 - .../Extensions/TemplateRaspunsuri.cs | 16 - .../Filters/ValidateModelStateAttribute.cs | 23 - .../MonitorizareVot.Api/Models/HashOptions.cs | 18 - .../MonitorizareVot.Api/Models/UserInfo.cs | 25 -- .../MonitorizareVot.Api.csproj | 57 --- .../src/MonitorizareVot.Api/Program.cs | 21 - .../Properties/launchSettings.json | 28 -- .../Queries/AdminQueryHandler.cs | 39 -- .../Queries/FormulareQueryHandler.cs | 46 -- .../Queries/MiniStatisticsQueryHandler.cs | 82 ---- .../Queries/NoteQueryHandler.cs | 41 -- .../Queries/ObserverAllHandler.cs | 43 -- .../Queries/ObserverGenerateHandler.cs | 68 --- .../Queries/ObserverRequestsHandler.cs | 101 ----- .../Queries/RaspunsuriQueryHandler.cs | 99 ---- .../Queries/StatisticiQueryHandler.cs | 203 --------- .../ConnectedService.json | 7 - .../Services/CacheService.cs | 92 ---- .../Services/ClearTextService.cs | 23 - .../Services/HashService.cs | 29 -- .../Services/ICacheService.cs | 13 - .../Services/IHashService.cs | 8 - .../Services/NoCacheService.cs | 20 - .../src/MonitorizareVot.Api/Startup.cs | 425 ------------------ .../ViewModels/ApplicationRole.cs | 6 - .../ViewModels/ApplicationUser.cs | 19 - .../ViewModels/FiltruFormulareModel.cs | 7 - .../ViewModels/FiltruNoteModel.cs | 8 - .../FiltruRaspunsuriCompletateModel.cs | 8 - .../ViewModels/FiltruRaspunsuriModel.cs | 10 - .../ViewModels/FiltruStatisticiSimple.cs | 24 - .../ViewModels/ImportObserversRequest.cs | 11 - .../ViewModels/IntrebareModel.cs | 23 - .../ViewModels/MiniStatisticsRequests.cs | 24 - .../ViewModels/NewObserverRequest.cs | 17 - .../ViewModels/NotaDetaliiModel.cs | 12 - .../ViewModels/NotaModel.cs | 20 - .../ViewModels/ObserverModel.cs | 16 - .../ViewModels/OptiuniFiltruModel.cs | 34 -- .../ViewModels/OptiuniModel.cs | 17 - .../ViewModels/PagingModel.cs | 39 -- .../ViewModels/RaspunsCompletatModel.cs | 37 -- .../ViewModels/RaspunsDisponibilModel.cs | 33 -- .../ViewModels/RaspunsFormularModel.cs | 37 -- .../ViewModels/RaspunsModel.cs | 26 -- .../ViewModels/ResetDeviceIdRequest.cs | 13 - .../ViewModels/SectiuneModel.cs | 22 - .../ViewModels/SimpleStatisticsModel.cs | 27 -- .../src/MonitorizareVot.Api/appsettings.json | 39 -- .../src/MonitorizareVot.Api/web.config | 14 - .../Builders/ObserverBuilder.cs | 107 ----- .../Models/Answer.cs | 21 - .../Models/County.cs | 20 - .../Models/FormSection.cs | 19 - .../Models/FormVersion.cs | 8 - .../MonitorizareVot.Domain.Ong/Models/Ngo.cs | 21 - .../Models/NgoAdmin.cs | 15 - .../MonitorizareVot.Domain.Ong/Models/Note.cs | 20 - .../Models/Observer.cs | 29 -- .../Models/Option.cs | 20 - .../Models/OptionToQuestion.cs | 22 - .../Models/PollingStation.cs | 27 -- .../Models/PollingStationInfo.cs | 18 - .../Models/Question.cs | 26 -- .../Models/RaspunsSectie.cs | 17 - .../Models/Statistici.cs | 24 - .../Models/VoteMonitorContext.cs | 380 ---------------- .../Models/VoteMonitorContextConfiguration.cs | 27 -- .../Models/VoteMonitorContextExtension.cs | 13 - .../Models/VoteMonitorContextExtensions.cs | 232 ---------- .../MonitorizareVot.Domain.Ong.csproj | 42 -- .../ObserverAggregate/GeneratedObserver.cs | 25 -- .../ObserverAggregate/ResetDeviceCommand.cs | 20 - .../ObserverAggregate/ResetDeviceHandler.cs | 50 --- .../ObserverAggregate/ResetPasswordCommand.cs | 19 - .../ObserverAggregate/ResetPasswordHandler.cs | 50 --- .../src/MonitorizareVot.Domain.Ong/Program.cs | 49 -- .../Properties/AssemblyInfo.cs | 19 - .../Properties/launchSettings.json | 22 - .../src/MonitorizareVot.Domain.Ong/Startup.cs | 18 - .../ValueObjects/TipIntrebareEnum.cs | 29 -- .../appsettings.json | 13 - .../Controllers/ControllerFixture.cs | 70 --- .../Controllers/RaspunsuriFixture.cs | 182 -------- .../Controllers/RaspunsuriTests.cs | 185 -------- .../DatabaseFixture.cs | 22 - .../MonitorizareVot.Ong.Api.Tests.csproj | 34 -- .../Properties/AssemblyInfo.cs | 19 - .../appsettings.json | 5 - 104 files changed, 5126 deletions(-) delete mode 100644 api/MonitorizareVot.Ong/MonitorizareVot.Ong.sln delete mode 100644 api/MonitorizareVot.Ong/NuGet.Config delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverAllCommand.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverGenerateCommand.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/Constants.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/JwtIssuerOptions.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/StatisticiQueryBuilder.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Formulare.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/JwtController.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Note.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/ObserverController.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Raspunsuri.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Statistici.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ControllerExtensions.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ListExtensions.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/TemplateRaspunsuri.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Filters/ValidateModelStateAttribute.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/HashOptions.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/UserInfo.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/MonitorizareVot.Api.csproj delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Program.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Properties/launchSettings.json delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/AdminQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/FormulareQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/MiniStatisticsQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/NoteQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverAllHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverGenerateHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverRequestsHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/RaspunsuriQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/StatisticiQueryHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Service References/Application Insights/ConnectedService.json delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/CacheService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ClearTextService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/HashService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ICacheService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/IHashService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/NoCacheService.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Startup.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationRole.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationUser.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruFormulareModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruNoteModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriCompletateModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruStatisticiSimple.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ImportObserversRequest.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/IntrebareModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/MiniStatisticsRequests.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NewObserverRequest.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaDetaliiModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ObserverModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniFiltruModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/PagingModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsCompletatModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsDisponibilModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsFormularModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ResetDeviceIdRequest.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SectiuneModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SimpleStatisticsModel.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/appsettings.json delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Api/web.config delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Builders/ObserverBuilder.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Answer.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/County.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormSection.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormVersion.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Ngo.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/NgoAdmin.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Note.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Observer.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Option.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/OptionToQuestion.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStation.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStationInfo.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Question.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/RaspunsSectie.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Statistici.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContext.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContextConfiguration.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContextExtension.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContextExtensions.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/MonitorizareVot.Domain.Ong.csproj delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ObserverAggregate/GeneratedObserver.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ObserverAggregate/ResetDeviceCommand.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ObserverAggregate/ResetDeviceHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ObserverAggregate/ResetPasswordCommand.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ObserverAggregate/ResetPasswordHandler.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Program.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Properties/AssemblyInfo.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Properties/launchSettings.json delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Startup.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/ValueObjects/TipIntrebareEnum.cs delete mode 100644 api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/appsettings.json delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/Controllers/ControllerFixture.cs delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/Controllers/RaspunsuriFixture.cs delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/Controllers/RaspunsuriTests.cs delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/DatabaseFixture.cs delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/MonitorizareVot.Ong.Api.Tests.csproj delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/Properties/AssemblyInfo.cs delete mode 100644 api/MonitorizareVot.Ong/test/MonitorizareVot.Ong.Api.Tests/appsettings.json diff --git a/api/MonitorizareVot.Ong/MonitorizareVot.Ong.sln b/api/MonitorizareVot.Ong/MonitorizareVot.Ong.sln deleted file mode 100644 index 98ae38b2..00000000 --- a/api/MonitorizareVot.Ong/MonitorizareVot.Ong.sln +++ /dev/null @@ -1,46 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.6 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5A77D74C-3CB5-4C26-943E-51DEEB0ACB2C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{84C42A14-6C8A-41D6-BF9B-87627681A7E9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonitorizareVot.Api", "src\MonitorizareVot.Api\MonitorizareVot.Api.csproj", "{18837128-04C4-4671-9DB8-F79342959FB8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonitorizareVot.Domain.Ong", "src\MonitorizareVot.Domain.Ong\MonitorizareVot.Domain.Ong.csproj", "{FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonitorizareVot.Ong.Api.Tests", "test\MonitorizareVot.Ong.Api.Tests\MonitorizareVot.Ong.Api.Tests.csproj", "{4AA73F60-D780-4007-B304-9305AD8E096E}" - ProjectSection(ProjectDependencies) = postProject - {18837128-04C4-4671-9DB8-F79342959FB8} = {18837128-04C4-4671-9DB8-F79342959FB8} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {18837128-04C4-4671-9DB8-F79342959FB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18837128-04C4-4671-9DB8-F79342959FB8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18837128-04C4-4671-9DB8-F79342959FB8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18837128-04C4-4671-9DB8-F79342959FB8}.Release|Any CPU.Build.0 = Release|Any CPU - {FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF}.Release|Any CPU.Build.0 = Release|Any CPU - {4AA73F60-D780-4007-B304-9305AD8E096E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4AA73F60-D780-4007-B304-9305AD8E096E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4AA73F60-D780-4007-B304-9305AD8E096E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4AA73F60-D780-4007-B304-9305AD8E096E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {18837128-04C4-4671-9DB8-F79342959FB8} = {5A77D74C-3CB5-4C26-943E-51DEEB0ACB2C} - {FBA151EE-CAB0-4ED1-9D61-53AD2CBD17DF} = {5A77D74C-3CB5-4C26-943E-51DEEB0ACB2C} - {4AA73F60-D780-4007-B304-9305AD8E096E} = {84C42A14-6C8A-41D6-BF9B-87627681A7E9} - EndGlobalSection -EndGlobal diff --git a/api/MonitorizareVot.Ong/NuGet.Config b/api/MonitorizareVot.Ong/NuGet.Config deleted file mode 100644 index ae8aea9e..00000000 --- a/api/MonitorizareVot.Ong/NuGet.Config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverAllCommand.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverAllCommand.cs deleted file mode 100644 index 913e6cdf..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverAllCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Domain.Ong.ObserverAggregate -{ - public class ObserverAllCommand : IRequest> - { - public ObserverAllCommand() - { - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverGenerateCommand.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverGenerateCommand.cs deleted file mode 100644 index c4529ed8..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Commands/ObserverGenerateCommand.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MediatR; - -namespace MonitorizareVot.Domain.Ong.ObserverAggregate -{ - public class ObserverGenerateCommand : IRequest> - { - public ObserverGenerateCommand(int NrObs, int Id) - { - NrObservers = NrObs; - IdNgo = Id; - } - - public int NrObservers { get; set; } - public int IdNgo { get; set; } - } - - public class ObserverGenerateProperties : IRequest - { - public ObserverGenerateProperties(int number) - { - NrObservers = number; - } - - public int NrObservers { get; set; } - public int IdNgo { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/Constants.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/Constants.cs deleted file mode 100644 index 74dfc5a9..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/Constants.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MonitorizareVot.Ong.Api.Common -{ - /// - /// Series of constant values that will be used within the application - /// - public static class Constants - { - public const int DEFAULT_PAGE_SIZE = 20; - public const int DEFAULT_PAGE = 1; - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/JwtIssuerOptions.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/JwtIssuerOptions.cs deleted file mode 100644 index 7883cac7..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/JwtIssuerOptions.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Microsoft.IdentityModel.Tokens; -using System; -using System.Threading.Tasks; - -namespace MonitorizareVot.Ong.Api.Common -{ - public class JwtIssuerOptions - { - /// - /// "iss" (Issuer) Claim - /// - /// The "iss" (issuer) claim identifies the principal that issued the - /// JWT. The processing of this claim is generally application specific. - /// The "iss" value is a case-sensitive string containing a StringOrURI - /// value. Use of this claim is OPTIONAL. - public string Issuer { get; set; } - - /// - /// "sub" (Subject) Claim - /// - /// The "sub" (subject) claim identifies the principal that is the - /// subject of the JWT. The claims in a JWT are normally statements - /// about the subject. The subject value MUST either be scoped to be - /// locally unique in the context of the issuer or be globally unique. - /// The processing of this claim is generally application specific. The - /// "sub" value is a case-sensitive string containing a StringOrURI - /// value. Use of this claim is OPTIONAL. - public string Subject { get; set; } - - /// - /// "aud" (Audience) Claim - /// - /// The "aud" (audience) claim identifies the recipients that the JWT is - /// intended for. Each principal intended to process the JWT MUST - /// identify itself with a value in the audience claim. If the principal - /// processing the claim does not identify itself with a value in the - /// "aud" claim when this claim is present, then the JWT MUST be - /// rejected. In the general case, the "aud" value is an array of case- - /// sensitive strings, each containing a StringOrURI value. In the - /// special case when the JWT has one audience, the "aud" value MAY be a - /// single case-sensitive string containing a StringOrURI value. The - /// interpretation of audience values is generally application specific. - /// Use of this claim is OPTIONAL. - public string Audience { get; set; } - - /// - /// "nbf" (Not Before) Claim (default is UTC NOW) - /// - /// The "nbf" (not before) claim identifies the time before which the JWT - /// MUST NOT be accepted for processing. The processing of the "nbf" - /// claim requires that the current date/time MUST be after or equal to - /// the not-before date/time listed in the "nbf" claim. Implementers MAY - /// provide for some small leeway, usually no more than a few minutes, to - /// account for clock skew. Its value MUST be a number containing a - /// NumericDate value. Use of this claim is OPTIONAL. - public DateTime NotBefore { get; set; } = DateTime.UtcNow; - - /// - /// "iat" (Issued At) Claim (default is UTC NOW) - /// - /// The "iat" (issued at) claim identifies the time at which the JWT was - /// issued. This claim can be used to determine the age of the JWT. Its - /// value MUST be a number containing a NumericDate value. Use of this - /// claim is OPTIONAL. - public DateTime IssuedAt { get; set; } = DateTime.UtcNow; - - /// - /// Set the timespan the token will be valid for (default is 5 min/300 seconds) - /// - public TimeSpan ValidFor { get; set; } = TimeSpan.FromDays(1); - - /// - /// "exp" (Expiration Time) Claim (returns IssuedAt + ValidFor) - /// - /// The "exp" (expiration time) claim identifies the expiration time on - /// or after which the JWT MUST NOT be accepted for processing. The - /// processing of the "exp" claim requires that the current date/time - /// MUST be before the expiration date/time listed in the "exp" claim. - /// Implementers MAY provide for some small leeway, usually no more than - /// a few minutes, to account for clock skew. Its value MUST be a number - /// containing a NumericDate value. Use of this claim is OPTIONAL. - public DateTime Expiration => IssuedAt.Add(ValidFor); - - /// - /// "jti" (JWT ID) Claim (default ID is a GUID) - /// - /// The "jti" (JWT ID) claim provides a unique identifier for the JWT. - /// The identifier value MUST be assigned in a manner that ensures that - /// there is a negligible probability that the same value will be - /// accidentally assigned to a different data object; if the application - /// uses multiple issuers, collisions MUST be prevented among values - /// produced by different issuers as well. The "jti" claim can be used - /// to prevent the JWT from being replayed. The "jti" value is a case- - /// sensitive string. Use of this claim is OPTIONAL. - public Func> JtiGenerator => - () => Task.FromResult(Guid.NewGuid().ToString()); - - /// - /// The signing key to use when generating tokens. - /// - public SigningCredentials SigningCredentials { get; set; } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/StatisticiQueryBuilder.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/StatisticiQueryBuilder.cs deleted file mode 100644 index 2f41a158..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Common/StatisticiQueryBuilder.cs +++ /dev/null @@ -1,75 +0,0 @@ -namespace MonitorizareVot.Ong.Api.Common -{ - public class StatisticiQueryBuilder - { - /// - /// The SQL query string that is executed in the db - /// - public string Query { get; set; } - - /// - /// The cache key for the query - /// - public string CacheKey { get; set; } - - /// - /// Appends a statement to the sql query string - /// - /// - public void Append(string statement) - { - Query = $"{Query} {statement}"; - } - - /// - /// Adds an AND condition to the WHERE clause - /// Filters statistics by FormCode - /// - public void AndFormularFilter(string formular) - { - if(!string.IsNullOrEmpty(formular)) - { - Query = $"{Query} AND I.FormCode = '{formular}'"; - CacheKey = $"{CacheKey}-{formular}"; - } - } - - /// - /// Adds an AND condition to the WHERE clause - /// Filters statistics by IdNgo if the ong is admin - /// - public void AndOngFilter(bool organizator, int idONG) - { - if(!organizator) - { - Query = $"{Query} AND O.IdNgo = {idONG}"; - CacheKey = $"{CacheKey}-{idONG}"; - } - else - CacheKey = $"{CacheKey}-Organizer"; - } - - /// - /// Adds a WHERE clause - /// Filters statistics by IdNgo if the ong is admin - /// - public void WhereOngFilter(bool organizator, int idONG) - { - if (!organizator) - { - Query = $"{Query} WHERE O.IdNgo = {idONG}"; - CacheKey = $"{CacheKey}-{idONG}"; - } - else - CacheKey = $"{CacheKey}-Organizer"; - } - - /// - /// Returns a query with ORDER BY, OFFSET and FETCH clauses - /// - public string GetPaginatedQuery(int page, int pageSize) - { - return $"{Query} ORDER BY Value DESC OFFSET {(page - 1) * pageSize} ROWS FETCH NEXT {pageSize} ROWS ONLY"; - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Formulare.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Formulare.cs deleted file mode 100644 index 3e9a93e6..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Formulare.cs +++ /dev/null @@ -1,34 +0,0 @@ -using MediatR; -using Microsoft.AspNetCore.Mvc; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace MonitorizareVot.Ong.Api.Controllers -{ - [Route("api/v1/formulare")] - public class Formulare : Controller - { - private readonly IMediator _mediator; - - public Formulare(IMediator mediator) - { - _mediator = mediator; - } - - /// - /// Se interogheaza ultima versiunea a formularului pentru observatori si se primeste definitia lui. - /// In definitia unui formular nu intra intrebarile standard (ora sosirii, etc). - /// Acestea se considera implicite pe fiecare formular. - /// - /// - /// "idFormular" Id-ul formularului pentru care trebuie preluata definitia - /// - /// - [HttpGet] - public async Task> Get(FiltruFormulareModel model) - { - return await _mediator.Send(new IntrebariQuery { CodFormular = model.IdFormular }); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/JwtController.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/JwtController.cs deleted file mode 100644 index 49147c94..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/JwtController.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.Linq; -using System.Security.Claims; -using System.Security.Principal; -using System.Threading.Tasks; -using Jwt; -using MediatR; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using MonitorizareVot.Api.ViewModels; -using MonitorizareVot.Ong.Api.Common; -using MonitorizareVot.Ong.Api.ViewModels; -using MonitorizareVot.Ong.Api.Extensions; - -namespace MonitorizareVot.Api.Controllers -{ - [Route("api/v1/auth")] - public class JwtController : Controller - { - private readonly IMediator _mediator; - private readonly JwtIssuerOptions _jwtOptions; - - private readonly ILogger _logger; - - public JwtController(IOptions jwtOptions, ILoggerFactory loggerFactory, IMediator mediator) - { - _mediator = mediator; - _jwtOptions = jwtOptions.Value; - ThrowIfInvalidOptions(_jwtOptions); - - _logger = loggerFactory.CreateLogger(); - } - - [HttpGet] - [AllowAnonymous] - // this method will only be called the token is expired - public async Task RefreshLogin() - { - string token = Request.Headers[ControllerExtensions.AUTH_HEADER_VALUE]; - if (string.IsNullOrEmpty(token)) - return Forbid(); - if (token.StartsWith(ControllerExtensions.BEARER_VALUE, StringComparison.OrdinalIgnoreCase)) - token = token.Substring(ControllerExtensions.BEARER_VALUE.Length).Trim(); - if (string.IsNullOrEmpty(token)) - return Forbid(); - - var decoded = JsonWebToken.DecodeToObject>(token, - _jwtOptions.SigningCredentials.Kid, false); - var idOng = int.Parse(decoded[ControllerExtensions.ID_NGO_VALUE]); - var organizator = bool.Parse(decoded[ControllerExtensions.ORGANIZER_VALUE]); - var userName = decoded[JwtRegisteredClaimNames.Sub]; - - var json = await GenerateToken(userName, idOng, organizator); - - return new OkObjectResult(json); - } - - [HttpPost] - [AllowAnonymous] - public async Task Login([FromBody] ApplicationUser applicationUser) - { - if (!ModelState.IsValid) - return BadRequest(ModelState); - - //await _mediator.Send(new ImportObserversRequest {FilePath = "d:\\mv-name-rest.11.15.txt", IdNgo = 3, NameIndexInFile = 2}); // mv - //await _mediator.Send(new ImportObserversRequest { FilePath = "d:\\dv-rest7.txt", IdNgo = 2, NameIndexInFile = 0 }); // usr - - var identity = await GetClaimsIdentity(applicationUser); - if (identity == null) - { - _logger.LogInformation( - $"Invalid username ({applicationUser.UserName}) or password ({applicationUser.Password})"); - return BadRequest("Invalid credentials"); - } - var json = await GenerateToken(applicationUser.UserName, - int.Parse(identity.Claims.FirstOrDefault(c => c.Type == ControllerExtensions.ID_NGO_VALUE)?.Value), - bool.Parse(identity.Claims.FirstOrDefault(c => c.Type == ControllerExtensions.ORGANIZER_VALUE)?.Value)); - - return new OkObjectResult(json); - } - - [Authorize] - [HttpPost("test")] - public async Task Test() - { - var claims = User.Claims.Select(c => new - { - c.Type, - c.Value - }); - - return await Task.FromResult(claims); - } - - private async Task GenerateToken(string userName, int idOng = 0, bool organizator = false) - { - var claims = new[] - { - new Claim(JwtRegisteredClaimNames.Sub, userName), - new Claim(JwtRegisteredClaimNames.Jti, await _jwtOptions.JtiGenerator()), - new Claim(JwtRegisteredClaimNames.Iat, - ToUnixEpochDate(_jwtOptions.IssuedAt).ToString(), - ClaimValueTypes.Integer64), - new Claim(ControllerExtensions.ID_NGO_VALUE, idOng.ToString()), - new Claim(ControllerExtensions.ORGANIZER_VALUE, organizator.ToString()) - }; - - // Create the JWT security token and encode it. - var jwt = new JwtSecurityToken( - issuer: _jwtOptions.Issuer, - audience: _jwtOptions.Audience, - claims: claims, - notBefore: _jwtOptions.NotBefore, - expires: _jwtOptions.Expiration, - signingCredentials: _jwtOptions.SigningCredentials); - - var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); - - // Serialize and return the response - //var response = new - //{ - // token = encodedJwt, - // expires_in = (int)_jwtOptions.ValidFor.TotalSeconds - //}; - - //var json = JsonConvert.SerializeObject(response, _serializerSettings); - return encodedJwt; - } - - private static void ThrowIfInvalidOptions(JwtIssuerOptions options) - { - if (options == null) throw new ArgumentNullException(nameof(options)); - - if (options.ValidFor <= TimeSpan.Zero) - { - throw new ArgumentException("Must be a non-zero TimeSpan.", nameof(JwtIssuerOptions.ValidFor)); - } - - if (options.SigningCredentials == null) - { - throw new ArgumentNullException(nameof(JwtIssuerOptions.SigningCredentials)); - } - - if (options.JtiGenerator == null) - { - throw new ArgumentNullException(nameof(JwtIssuerOptions.JtiGenerator)); - } - } - - /// Date converted to seconds since Unix epoch (Jan 1, 1970, midnight UTC). - private static long ToUnixEpochDate(DateTime date) - => (long)Math.Round((date.ToUniversalTime() - - new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero)) - .TotalSeconds); - - private async Task GetClaimsIdentity(ApplicationUser user) - { - var userInfo = await _mediator.Send(user); - - if (userInfo == null) - return await Task.FromResult(null); - - return await Task.FromResult(new ClaimsIdentity( - new GenericIdentity(user.UserName, ControllerExtensions.TOKEN_VALUE), new[] - { - new Claim(ControllerExtensions.ID_NGO_VALUE, userInfo.IdNgo.ToString()), - new Claim(ControllerExtensions.ORGANIZER_VALUE, userInfo.Organizer.ToString()) - })); - } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Note.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Note.cs deleted file mode 100644 index 986f7647..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Note.cs +++ /dev/null @@ -1,37 +0,0 @@ -using MediatR; -using Microsoft.AspNetCore.Mvc; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace MonitorizareVot.Ong.Api.Controllers -{ - [Route("api/v1/note")] - public class Note : Controller - { - private readonly IMediator _mediator; - - public Note(IMediator mediator) - { - _mediator = mediator; - } - - /// - /// Returneaza notele atasate unui formular - /// - /// {SectionId:int, ObserverId:int} - /// "SectionId" - Id-ul sectiei unde s-a completat formularul - /// "ObserverId" - Id-ul observatorului care a completat formularul - /// - /// - [HttpGet] - public async Task> Get(FiltruNoteModel model) - { - return await _mediator.Send(new NotaQuery - { - IdObservator = model.ObserverId, - IdSectieDeVotare = model.SectionId - }); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/ObserverController.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/ObserverController.cs deleted file mode 100644 index 58eb16c1..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/ObserverController.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Threading.Tasks; -using System.Linq; -using System; -using System.Net; -using AutoMapper; -using MediatR; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using MonitorizareVot.Api.ViewModels; -using MonitorizareVot.Domain.Ong.ObserverAggregate; -using MonitorizareVot.Ong.Api.Extensions; - - -namespace MonitorizareVot.Api.Controllers -{ - [Route("api/v1/observer")] - public class ObserverController : Controller - { - private readonly IMediator _mediator; - private readonly ILogger _logger; - private readonly IMapper _mapper; - - public ObserverController(IMediator mediator, ILogger logger, IMapper mapper) - { - _mediator = mediator; - _logger = logger; - _mapper = mapper; - } - - [HttpPost] - [Route("import")] - public void Import(IFormFile file, [FromForm] object a) - { } - - [Authorize] - [HttpPost] - [Route("")] - public async Task NewObserver(ObserverModel model) - { - if (!ModelState.IsValid) - return BadRequest(ModelState); - - await _mediator.Send(_mapper.Map(model)); - - return Task.FromResult(new { }); - } - - [Authorize] - [HttpPost] - [Route("reset")] - public async Task Reset([FromForm] string action, [FromForm] string phoneNumber) - { - if(String.IsNullOrEmpty(action) || String.IsNullOrEmpty(phoneNumber)) - return Task.FromResult(BadRequest()); - - if (String.Equals(action, ControllerExtensions.DEVICE_RESET)) - { - var result = await _mediator.Send(new ResetDeviceCommand(ControllerExtensions.GetIdOngOrDefault(this, 0), phoneNumber)); - if (result == -1) - return Task.FromResult(NotFound(ControllerExtensions.RESET_ERROR_MESSAGE + phoneNumber)); - else - return Task.FromResult(Ok(result)); - } - - if(String.Equals(action, ControllerExtensions.PASSWORD_RESET)) - { - var result = await _mediator.Send(new ResetPasswordCommand(ControllerExtensions.GetIdOngOrDefault(this, 0), phoneNumber)); - if (String.IsNullOrEmpty(result)) - return Task.FromResult(NotFound(ControllerExtensions.RESET_ERROR_MESSAGE + phoneNumber)); - else - return Task.FromResult(Ok(result)); - } - - return Task.FromResult(UnprocessableEntity()); - } - - [Authorize] - [HttpPost] - [Route("generate")] - public async Task GenerateObservers([FromForm] int count) - { - if (!ControllerExtensions.ValidateGenerateObserversNumber(count)) - return Task.FromResult(new BadRequestObjectResult("Incorrect parameter supplied, please check that paramter is between boundaries: " - + ControllerExtensions.LOWER_OBS_VALUE + " - " + ControllerExtensions.UPPER_OBS_VALUE)); - - ObserverGenerateCommand command = new ObserverGenerateCommand(count, - ControllerExtensions.GetIdOngOrDefault(this, 0)); - - var result = _mediator.Send(command); - - return Task.FromResult(new OkObjectResult(result.Result)); - } - [HttpGet] - [Route("all")] - public async Task All() - { - var result = await _mediator.Send(new ObserverAllCommand()); - if (String.IsNullOrEmpty(result.ToString())) - return Task.FromResult(NotFound("ERROR")); - else - return Task.FromResult(Ok(result)); - - } - - - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Raspunsuri.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Raspunsuri.cs deleted file mode 100644 index 35740f36..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Raspunsuri.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Threading.Tasks; -using MediatR; -using Microsoft.AspNetCore.Mvc; -using MonitorizareVot.Ong.Api.Extensions; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Collections.Generic; -using Microsoft.Extensions.Configuration; - -namespace MonitorizareVot.Ong.Api.Controllers -{ - [Route("api/v1/raspunsuri")] - public class Raspunsuri : Controller - { - private readonly IMediator _mediator; - private readonly IConfigurationRoot _configuration; - - public Raspunsuri(IMediator mediator, IConfigurationRoot configuration) - { - _mediator = mediator; - _configuration = configuration; - } - - /// - /// Returneaza lista sectiilor de votare unde au raspuns observatorii care apartion ONG-ului cu id-ul primit - /// la intrebarile din formulare marcate cu RaspunsFlag == Urgent ordonate desc dupa DataModificare - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// Urgent (valoarea campului RaspunsFlag) - /// - [HttpGet] - public async Task> Get(FiltruRaspunsuriSectiiModel model) - { - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - var idOng = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - - return await _mediator.Send(new RaspunsuriQuery - { - IdONG = idOng, - Organizator = organizator, - Page = model.Page, - PageSize = model.PageSize, - Urgent = model.Urgent, - County = model.County, - PollingStationNumber = model.PollingStationNumber, - ObserverId = model.ObserverId - }); - } - - /// - /// Returneaza raspunsurile date de un observator pentru o anumita sectie de votare - /// - /// - /// "IdSectieDeVotare" - Id-ul sectiei unde s-au completat raspunsurile - /// "IdObservator" - Id-ul observatorului care a dat raspunsurile - /// - [HttpGet("RaspunsuriCompletate")] - public async Task>> Get(FiltruRaspunsuriModel model) - { - return await _mediator.Send(new RaspunsuriCompletateQuery - { - IdObservator = model.IdObservator, - IdSectieDeVotare = model.IdSectieDeVotare - }); - } - - /// - /// Returneaza raspunsurile formular date de un observator pentru o anumita sectie de votare - /// - /// "IdSectieDeVotare" - Id-ul sectiei unde s-au completat raspunsurile - /// "IdObservator" - Id-ul observatorului care a dat raspunsurile - /// - [HttpGet("RaspunsuriFormular")] - public async Task GetRaspunsuriFormular(FiltruRaspunsuriModel model) - { - return await _mediator.Send(new RaspunsuriFormularQuery - { - IdObservator = model.IdObservator, - IdSectieDeVotare = model.IdSectieDeVotare - }); - } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Statistici.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Statistici.cs deleted file mode 100644 index 38602873..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Controllers/Statistici.cs +++ /dev/null @@ -1,330 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using MediatR; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using MonitorizareVot.Ong.Api.Extensions; -using MonitorizareVot.Ong.Api.ViewModels; -using Microsoft.Extensions.Configuration; -using MonitorizareVot.Api.ViewModels; - -namespace MonitorizareVot.Ong.Api.Controllers -{ - [Route("api/v1/statistici")] - public class Statistici : Controller - { - private readonly IConfigurationRoot _configuration; - private readonly IMediator _mediator; - private int _cacheHours; - private int _cacheMinutes; - private int _cacheSeconds; - - public Statistici(IMediator mediator, IConfigurationRoot configuration) - { - _mediator = mediator; - _configuration = configuration; - _cacheHours = _configuration.GetValue("DefaultCacheHours"); - _cacheMinutes = _configuration.GetValue("DefaultCacheMinutes"); - _cacheSeconds = _configuration.GetValue("DefaultCacheSeconds"); - } - - /// - /// Returneaza topul judetelor in functie de numarul de observatori - /// - /// Detaliile de paginare - /// - [HttpGet] - [Route("NumarObservatori")] - public async Task> NumarObservatori(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - return await _mediator.Send(new StatisticiNumarObservatoriQuery - { - IdONG = idONG, - Organizator = organizator, - PageSize = model.PageSize, - Page = model.Page, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul judetelor sau sectiilor in functie de numarul de sesizari - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// Grupare (0 - County | 1 - Sectie) - /// Formular (codul formularulu care va fi luat in calcul pentru statistci - "" (string.Empty) inseamna toate) - /// - /// - [HttpGet] - [Route("Sesizari")] - public async Task> Sesizari(FiltruStatisticiSimple model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - if (model.Grupare == TipGrupareStatistici.Sectie) model.PageSize = Common.Constants.DEFAULT_PAGE_SIZE; - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = model.Grupare, - Formular = model.Formular, - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul judetelor in functie de numarul de sesizari - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariJudete")] - public async Task> SesizariJudete(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Judet, - Formular = null, - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul Sectiilor in functie de numarul de sesizari - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariSectii")] - public async Task> SesizariSectii(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - model.PageSize = Common.Constants.DEFAULT_PAGE_SIZE; - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Sectie, - Formular = null, - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul judetelor in functie de numarul de sesizari la deschiderea sectiilor - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariDeschidereJudete")] - public async Task> SesizariDeschidereJudete(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Judet, - Formular = "A", - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul Sectiilor in functie de numarul de sesizari la deschiderea sectiilor - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariDeschidereSectii")] - public async Task> SesizariDeschidereSectii(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - model.PageSize = Common.Constants.DEFAULT_PAGE_SIZE; - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Sectie, - Formular = "A", - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul judetelor in functie de numarul de sesizari la numararea voturilor - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariNumarareJudete")] - public async Task> SesizariNumarareJudete(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Judet, - Formular = "C", - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza topul Sectiilor in functie de numarul de sesizari la numararea voturilor - /// - /// Detaliile de paginare (default Page=1, PageSize=20) - /// - [HttpGet] - [Route("SesizariNumarareSectii")] - public async Task> SesizariNumarareSectii(PagingModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - model.PageSize = Common.Constants.DEFAULT_PAGE_SIZE; - - return await _mediator.Send(new StatisticiTopSesizariQuery - { - IdONG = idONG, - Organizator = organizator, - Grupare = TipGrupareStatistici.Sectie, - Formular = "C", - Page = model.Page, - PageSize = model.PageSize, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - /// - /// Returneaza numarul raspunsurilor date de observatorii unui anumit ONG - /// grupate pe optiuni pentru o anumita intrebare - /// - /// Id - id-ul intrebarei pentru care sa se returneze statisticile - /// - [HttpGet] - [Route("RaspunsuriNumarareOptiuni")] - public async Task RaspunsuriNumarareOptiuni(OptiuniFiltruModel model) - { - var idONG = this.GetIdOngOrDefault(_configuration.GetValue("DefaultIdOng")); - var organizator = this.GetOrganizatorOrDefault(_configuration.GetValue("DefaultOrganizator")); - - return await _mediator.Send(new StatisticiOptiuniQuery - { - IdIntrebare = model.IdIntrebare, - Organizator = organizator, - IdONG = idONG, - CacheHours = _cacheHours, - CacheMinutes = _cacheMinutes, - CacheSeconds = _cacheSeconds - }); - } - - [HttpGet] - [AllowAnonymous] - [Route("mini/answers")] - public async Task Answers() - { - return await _mediator.Send(new AnswersRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/stations")] - public async Task StationsVisited() - { - return await _mediator.Send(new StationsVisitedRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/counties")] - public async Task Counties() - { - return await _mediator.Send(new CountiesVisitedRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/notes")] - public async Task Notes() - { - return await _mediator.Send(new NotesUploadedRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/loggedinobservers")] - public async Task LoggedInObservers() - { - return await _mediator.Send(new LoggedInObserversRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/flaggedanswers")] - public async Task FlaggedAnswers() - { - return await _mediator.Send(new FlaggedAnswersRequest()); - } - [HttpGet] - [AllowAnonymous] - [Route("mini/all")] - public async Task> All() - { - var list = new List - { - await _mediator.Send(new AnswersRequest()), - await _mediator.Send(new StationsVisitedRequest()), - await _mediator.Send(new CountiesVisitedRequest()), - await _mediator.Send(new NotesUploadedRequest()), - await _mediator.Send(new LoggedInObserversRequest()), - await _mediator.Send(new FlaggedAnswersRequest()) - }; - - return list; - } - - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ControllerExtensions.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ControllerExtensions.cs deleted file mode 100644 index 5faa7066..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ControllerExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace MonitorizareVot.Ong.Api.Extensions -{ - public static class ControllerExtensions - { - public static readonly string ID_NGO_VALUE = "IdNgo"; - public static readonly string ORGANIZER_VALUE = "Organizer"; - public static readonly string TOKEN_VALUE = "Token"; - public static readonly string AUTH_HEADER_VALUE = "Authorization"; - public static readonly string BEARER_VALUE = "Bearer "; - public static readonly int LOWER_OBS_VALUE = 1; - public static readonly int UPPER_OBS_VALUE = 300; - public static readonly string RESET_ERROR_MESSAGE = "Internal server error, please verify that provided id is correct "; - public static readonly string DEVICE_RESET = "device"; - public static readonly string PASSWORD_RESET = "password"; - - public static int GetIdOngOrDefault(this Controller controller, int defaultIdOng) - { - int result; - return int.TryParse(controller.User.Claims.FirstOrDefault(a => a.Type == ID_NGO_VALUE)?.Value, out result) - ? result - : defaultIdOng; - } - - public static bool GetOrganizatorOrDefault(this Controller controller, bool defaultOrganizator) - { - bool result; - return bool.TryParse(controller.User.Claims.FirstOrDefault(a => a.Type == ORGANIZER_VALUE)?.Value, out result) - ? result - : defaultOrganizator; - } - - public static bool ValidateGenerateObserversNumber(int number) - { - return ((number > LOWER_OBS_VALUE) && (number < UPPER_OBS_VALUE)); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ListExtensions.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ListExtensions.cs deleted file mode 100644 index be534c56..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/ListExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace MonitorizareVot.Ong.Api.Extensions -{ - public static class ListExtensions - { - public static List Paginate(this List unPagedList, int page, int pageSize) - { - return unPagedList - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/TemplateRaspunsuri.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/TemplateRaspunsuri.cs deleted file mode 100644 index c88046b5..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Extensions/TemplateRaspunsuri.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using MonitorizareVot.Ong.Api.ViewModels; - -namespace MonitorizareVot.Ong.Api.Extensions -{ - public class ApiResponse - where T: class - { - public T Data { get; set; } - } - - public class ApiListResponse : PagingResponseModel - { - public List Data { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Filters/ValidateModelStateAttribute.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Filters/ValidateModelStateAttribute.cs deleted file mode 100644 index f72ed98e..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Filters/ValidateModelStateAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; - -namespace MonitorizareVot.Ong.Api.Filters -{ - /// - /// A filter which checks if the model state is valid - /// and returns Bad Request if it is not valid along with the model state attached - /// - public class ValidateModelStateAttribute : ActionFilterAttribute - { - public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) - { - if (!context.ModelState.IsValid) - { - context.Result = new BadRequestObjectResult(context.ModelState); - } - - return base.OnActionExecutionAsync(context, next); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/HashOptions.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/HashOptions.cs deleted file mode 100644 index 35520482..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/HashOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace MonitorizareVot.Ong.Api.Models -{ - public class HashOptions - { - public string Salt { get; set; } - /// - /// Can be set to `Hash` or `ClearText` - /// `Hash` will use the HashService (that needs the Salt setting) to generate hashes for the password - /// :warning: `ClearText` will allow your development environment to create and store clear text passwords in the database. Please only use this in development to speed up things. - /// - public string ServiceType { get; set; } - } - public enum HashServiceType - { - Hash, - ClearText - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/UserInfo.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/UserInfo.cs deleted file mode 100644 index 77dec4d1..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Models/UserInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Ong.Api.Models -{ - public class UserInfo - { - public int IdNgo { get; set; } - public bool Organizer { get; set; } - } - - public class UserInfoProfile : Profile - { - public UserInfoProfile() - { - CreateMap() - .ForMember(u => u.IdNgo, opt => opt.MapFrom(a => a.IdNgo)) - .ForMember(u => u.Organizer, opt => opt.MapFrom(a => a.Ngo.Organizer)); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/MonitorizareVot.Api.csproj b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/MonitorizareVot.Api.csproj deleted file mode 100644 index 62e7ba80..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/MonitorizareVot.Api.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - netcoreapp2.1 - true - true - MonitorizareVot.Api - Exe - MonitorizareVot.Api - TBR - 2.1.4 - $(AssetTargetFallback); - {18837128-04C4-4671-9DB8-F79342959FB8} - - - - 1701;1702;1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Program.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Program.cs deleted file mode 100644 index 47123cb1..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.IO; -using Microsoft.AspNetCore.Hosting; - -namespace MonitorizareVot.Api -{ - public class Program - { - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseApplicationInsights() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Properties/launchSettings.json b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Properties/launchSettings.json deleted file mode 100644 index 030aaf1d..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Properties/launchSettings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:5000/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "pol" - } - }, - "MonitorizareVot.Api": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "http://localhost:5000/swagger/", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/AdminQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/AdminQueryHandler.cs deleted file mode 100644 index e0bfec58..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/AdminQueryHandler.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using AutoMapper; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.Models; -using MonitorizareVot.Ong.Api.Services; -using MonitorizareVot.Ong.Api.ViewModels; -using Microsoft.EntityFrameworkCore; - -namespace MonitorizareVot.Ong.Api.Queries -{ - public class AdminQueryHandler : IRequestHandler - { - private readonly VoteMonitorContext _context; - private readonly IHashService _hash; - - public AdminQueryHandler(VoteMonitorContext context, IHashService hash) - { - _context = context; - _hash = hash; - } - - public async Task Handle(ApplicationUser message, CancellationToken token) - { - var hashValue = _hash.GetHash(message.Password); - - var userinfo = _context.NgoAdmins - .Include(a => a.Ngo) - .Where(a => a.Password == hashValue && - a.Account == message.UserName) - .Select(Mapper.Map) - .FirstOrDefault(); - - return await Task.FromResult(userinfo); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/FormulareQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/FormulareQueryHandler.cs deleted file mode 100644 index 29f2699a..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/FormulareQueryHandler.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Threading.Tasks; -using AutoMapper; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -using Microsoft.EntityFrameworkCore; - -namespace MonitorizareVot.Ong.Api.Queries -{ - public class FormulareQueryHandler : - IRequestHandler> - { - private readonly VoteMonitorContext _context; - private readonly IMapper _mapper; - - public FormulareQueryHandler(VoteMonitorContext context, IMapper mapper) - { - _context = context; - _mapper = mapper; - } - - public async Task> Handle(IntrebariQuery message, CancellationToken cancellationToken) - { - var intrebari = await _context.Questions - .Include(i => i.FormSection) - .Include(i => i.OptionsToQuestions) - .ThenInclude(i => i.Option) - .Where(i => i.FormCode == message.CodFormular) - .ToListAsync(); - - var sectiuni = intrebari.Select(a => new { IdSectiune = a.IdSection, CodSectiune = a.FormSection.Code, Descriere = a.FormSection.Description }).Distinct(); - - return sectiuni.Select(i => new SectiuneModel - { - CodSectiune = i.CodSectiune, - Descriere = i.Descriere, - Intrebari = intrebari.Where(a => a.IdSection == i.IdSectiune) - .OrderBy(intrebare=>intrebare.Code) - .Select(a => _mapper.Map>(a)).ToList() - }).ToList(); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/MiniStatisticsQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/MiniStatisticsQueryHandler.cs deleted file mode 100644 index 017fc065..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/MiniStatisticsQueryHandler.cs +++ /dev/null @@ -1,82 +0,0 @@ -using MediatR; -using Microsoft.EntityFrameworkCore; -using MonitorizareVot.Api.ViewModels; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MonitorizareVot.Api.Queries -{ - public class MiniStatisticsQueryHandler : - IRequestHandler, - IRequestHandler, - IRequestHandler, - IRequestHandler, - IRequestHandler, - IRequestHandler - { - private readonly VoteMonitorContext _context; - - public MiniStatisticsQueryHandler(VoteMonitorContext context) - { - _context = context; - } - - public async Task Handle(AnswersRequest message, CancellationToken token) - { - var number = await _context.Answers.CountAsync(); - return new SimpleStatisticsModel - { - Label = "Number of answers submitted", - Value = number.ToString() - }; - } - public async Task Handle(StationsVisitedRequest message, CancellationToken token) - { - var number = await _context.Answers.Select(r => r.IdPollingStation).Distinct().CountAsync(); - return new SimpleStatisticsModel - { - Label = "Number of Polling Stations visited", - Value = number.ToString() - }; - } - public async Task Handle(CountiesVisitedRequest message, CancellationToken token) - { - var number = await _context.Answers.Select(r => r.CountyCode).Distinct().CountAsync(); - return new SimpleStatisticsModel - { - Label = "Number of Counties visited", - Value = number.ToString() - }; - } - public async Task Handle(NotesUploadedRequest message, CancellationToken token) - { - var number = await _context.Notes.CountAsync(); - return new SimpleStatisticsModel - { - Label = "Number of notes submitted", - Value = number.ToString() - }; - } - public async Task Handle(LoggedInObserversRequest message, CancellationToken token) - { - var number = await _context.PollingStationInfos.Select(pi => pi.IdObserver).Distinct().CountAsync(token); - return new SimpleStatisticsModel - { - Label = "Number of logged in Observers", - Value = number.ToString() - }; - } - public async Task Handle(FlaggedAnswersRequest message, CancellationToken token) - { - var number = await _context.Answers.Include(r => r.OptionAnswered).CountAsync(r => r.OptionAnswered.Flagged); - return new SimpleStatisticsModel - { - Label = "Number of flagged answers submitted", - Value = number.ToString() - }; - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/NoteQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/NoteQueryHandler.cs deleted file mode 100644 index 31ad95e0..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/NoteQueryHandler.cs +++ /dev/null @@ -1,41 +0,0 @@ -using MediatR; -using MonitorizareVot.Ong.Api.ViewModels; -using System.Collections.Generic; -using System.Threading.Tasks; -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; -using System.Linq; -using System.Threading; -using Microsoft.EntityFrameworkCore; - -namespace MonitorizareVot.Ong.Api.Queries -{ - public class NoteQueryHandler : - IRequestHandler> - { - - private readonly VoteMonitorContext _context; - private readonly IMapper _mapper; - - public NoteQueryHandler(VoteMonitorContext context, IMapper mapper) - { - _context = context; - _mapper = mapper; - } - public async Task> Handle(NotaQuery message, CancellationToken token) - { - return await _context.Notes - .Where(n => n.IdObserver == message.IdObservator && n.IdPollingStation == message.IdSectieDeVotare) - .OrderBy(n => n.LastModified) - .Select(n => new NotaModel - { - IdNota = n.Id, - CaleFisierAtasat = n.AttachementPath, - TextNota = n.Text, - CodFormular = n.Question.FormCode, - CodIntrebare = n.Question.Id - }) - .ToListAsync(); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverAllHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverAllHandler.cs deleted file mode 100644 index 599f4b0d..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverAllHandler.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MediatR; -using Microsoft.Extensions.Logging; -using MonitorizareVot.Domain.Ong.Builders; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Domain.Ong.ObserverAggregate -{ - public class ObserverAllHandler : AsyncRequestHandler> - { - public VoteMonitorContext _voteMonitorContext; - public ILogger _logger; - - public ObserverAllHandler(VoteMonitorContext context, ILogger logger) - { - _voteMonitorContext = context; - _logger = logger; - } - - protected override Task> HandleCore(ObserverAllCommand request) - { - try - { - List observers = _voteMonitorContext.Observers.ToList(); - - if (observers == null){ - return Task.FromResult(new List()); - } - - return Task.FromResult(observers); - } - catch (Exception exception) - { - _logger.LogError("Exception caught during resetting of Observer password for id " + request, exception); - } - - return Task.FromResult(new List()); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverGenerateHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverGenerateHandler.cs deleted file mode 100644 index ffadd0c5..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverGenerateHandler.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using AutoMapper; -using System.Threading.Tasks; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; -using Microsoft.Extensions.Logging; -using MonitorizareVot.Domain.Ong.Builders; - -namespace MonitorizareVot.Domain.Ong.ObserverAggregate -{ - public class ObserverGenerateHandler : AsyncRequestHandler> - { - private readonly VoteMonitorContext _voteMonitorContext; - private readonly ILogger _logger; - private readonly IMapper _mapper; - - public ObserverGenerateHandler(VoteMonitorContext context, ILogger logger, IMapper mapper) - { - _voteMonitorContext = context; - _logger = logger; - _mapper = mapper; - } - - protected async override Task> HandleCore(ObserverGenerateCommand command) - { - List dbObservers = new List(); - List generatedObservers = new List(); - - - for(int i = 0; i < command.NrObservers; ++i) - { - RandomObserverBuilder builder = new RandomObserverBuilder(); - dbObservers.Add(builder.build(command.IdNgo)); - } - - try - { - using(var tran = await _voteMonitorContext.Database.BeginTransactionAsync()) - { - int latestId = _voteMonitorContext.Observers - .OrderByDescending(o => o.Id) - .FirstOrDefault() - .Id; - - dbObservers = dbObservers - .Select(o => { o.Id = ++latestId; return o; }) - .ToList(); - - _voteMonitorContext.Observers.AddRange(dbObservers.ToArray()); - var result = await _voteMonitorContext.SaveChangesAsync(); - tran.Commit(); - - return dbObservers - .Select(o => _mapper.Map(o)) - .ToList(); - } - } - catch(Exception ex) - { - _logger.LogError("Error during generation of random observers", ex, ex.Message); - } - - return await Task.FromResult(generatedObservers); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverRequestsHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverRequestsHandler.cs deleted file mode 100644 index aa9f493d..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/ObserverRequestsHandler.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediatR; -using Microsoft.Extensions.Logging; -using MonitorizareVot.Api.ViewModels; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.Services; - -namespace MonitorizareVot.Api.Queries -{ - public class ObserverRequestsHandler : - IRequestHandler, - IRequestHandler, - IRequestHandler - { - private readonly VoteMonitorContext _context; - private readonly ILogger _logger; - private IHashService _hashService; - - public ObserverRequestsHandler(VoteMonitorContext context, ILogger logger, IHashService hashService) - { - _context = context; - _logger = logger; - _hashService = hashService; - } - - private int GetMaxIdObserver() - { - return _context.Observers.Max(o => o.Id) + 1; - } - - public Task Handle(ImportObserversRequest message, CancellationToken token) - { - var pathToFile = message.FilePath; - var counter = 0; - var startId = GetMaxIdObserver(); - - using (var reader = File.OpenText(pathToFile)) - { - while (reader.Peek() >= 0) - { - var fileContent = reader.ReadLine(); - - var data = fileContent.Split('\t'); - var hashed = _hashService.GetHash(data[1]); - - var observer = new Observer - { - Id = startId + counter, - IdNgo = message.IdOng, - Phone = data[0], - Name = data[message.NameIndexInFile], - Pin = hashed - }; - _context.Observers.Add(observer); - counter++; - } - _context.SaveChanges(); - } - - return Task.FromResult(counter); - } - - - public Task Handle(NewObserverRequest message, CancellationToken token) - { - var id = GetMaxIdObserver(); - var observer = new Observer - { - Id = id, - IdNgo = message.IdOng, - Phone = message.NumarTelefon, - Name = message.Nume, - Pin = _hashService.GetHash(message.PIN) - }; - _context.Observers.Add(observer); - return _context.SaveChangesAsync(); - } - - - public Task Handle(ResetDeviceIdRequest message, CancellationToken token) - { - // find observer - var observers = _context.Observers.Where(o => o.Phone == message.PhoneNumber); - if (observers.Count() != 1) - { - return Task.FromResult(0); - } - - // make sure the number is unique - // clear device id - observers.First().MobileDeviceId = null; - - return _context.SaveChangesAsync(); - // save - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/RaspunsuriQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/RaspunsuriQueryHandler.cs deleted file mode 100644 index 5934a7d4..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/RaspunsuriQueryHandler.cs +++ /dev/null @@ -1,99 +0,0 @@ -using AutoMapper; -using MediatR; -using Microsoft.EntityFrameworkCore; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.Extensions; -using MonitorizareVot.Ong.Api.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MonitorizareVot.Ong.Api.Queries -{ - public class RaspunsuriQueryHandler : - IRequestHandler>, - IRequestHandler>>, - IRequestHandler - { - private readonly VoteMonitorContext _context; - private readonly IMapper _mapper; - - public RaspunsuriQueryHandler(VoteMonitorContext context, IMapper mapper) - { - _context = context; - _mapper = mapper; - } - - public async Task> Handle(RaspunsuriQuery message, CancellationToken cancellationToken) - { - var queryUnPaged = $@"SELECT IdPollingStation AS IdSectie, A.IdObserver AS IdObservator, O.Name AS Observator, CONCAT(CountyCode, ' ', PollingStationNumber) AS Sectie, MAX(LastModified) AS DataUltimeiModificari - FROM Answers A - INNER JOIN Observers O ON O.Id = A.IdObserver - INNER JOIN OptionsToQuestions OQ ON OQ.Id = A.IdOptionToQuestion - WHERE OQ.Flagged = {Convert.ToInt32(message.Urgent)}"; - - // Filter by the organizer flag if specified - if (!message.Organizator) - queryUnPaged = $"{queryUnPaged} AND O.IdNgo = {message.IdONG}"; - - // Filter by county if specified - if (!string.IsNullOrEmpty(message.County)) - queryUnPaged = $"{queryUnPaged} AND A.CountyCode = '{message.County}'"; - - // Filter by polling station if specified - if (message.PollingStationNumber > 0) - queryUnPaged = $"{queryUnPaged} AND A.PollingStationNumber = {message.PollingStationNumber}"; - - // Filter by polling station if specified - if (message.ObserverId > 0) - queryUnPaged = $"{queryUnPaged} AND A.IdObserver = {message.ObserverId}"; - - queryUnPaged = $"{queryUnPaged} GROUP BY IdPollingStation, CountyCode, PollingStationNumber, A.IdObserver, O.Name, CountyCode"; - - var queryPaged = $@"{queryUnPaged} ORDER BY MAX(LastModified) DESC OFFSET {(message.Page - 1) * message.PageSize} ROWS FETCH NEXT {message.PageSize} ROWS ONLY"; - - var sectiiCuObservatoriPaginat = await _context.RaspunsSectie - .FromSql(queryPaged) - .ToListAsync(cancellationToken: cancellationToken); - - var count = await _context.RaspunsSectie - .FromSql(queryUnPaged) - .CountAsync(cancellationToken: cancellationToken); - - return new ApiListResponse - { - Data = sectiiCuObservatoriPaginat.Select(x => _mapper.Map(x)).ToList(), - Page = message.Page, - PageSize = message.PageSize, - TotalItems = count - }; - } - - public async Task>> Handle(RaspunsuriCompletateQuery message, CancellationToken cancellationToken) - { - var raspunsuri = await _context.Answers - .Include(r => r.OptionAnswered) - .ThenInclude(rd => rd.Question) - .Include(r => r.OptionAnswered) - .ThenInclude(rd => rd.Option) - .Where(r => r.IdObserver == message.IdObservator && r.IdPollingStation == message.IdSectieDeVotare) - .ToListAsync(); - - var intrebari = raspunsuri - .Select(r => r.OptionAnswered.Question) - .ToList(); - - return intrebari.Select(i => _mapper.Map>(i)).ToList(); - } - - public async Task Handle(RaspunsuriFormularQuery message, CancellationToken cancellationToken) - { - var raspunsuriFormular = await _context.PollingStationInfos - .FirstOrDefaultAsync(rd => rd.IdObserver == message.IdObservator && rd.IdPollingStation == message.IdSectieDeVotare); - - return _mapper.Map(raspunsuriFormular); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/StatisticiQueryHandler.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/StatisticiQueryHandler.cs deleted file mode 100644 index e53a2ac7..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Queries/StatisticiQueryHandler.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using AutoMapper; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.Extensions; -using MonitorizareVot.Ong.Api.ViewModels; -using Microsoft.EntityFrameworkCore; -using MonitorizareVot.Ong.Api.Services; -using System; -using System.Threading; -using Microsoft.Extensions.Caching.Distributed; -using MonitorizareVot.Ong.Api.Common; - -namespace MonitorizareVot.Ong.Api.Queries -{ - public class StatisticiQueryHandler : - IRequestHandler>, - IRequestHandler>, - IRequestHandler - { - private readonly VoteMonitorContext _context; - private readonly ICacheService _cacheService; - private readonly IMapper _mapper; - - public StatisticiQueryHandler(VoteMonitorContext context, IMapper mapper, ICacheService cacheService) - { - _context = context; - _mapper = mapper; - _cacheService = cacheService; - } - - public async Task Handle(StatisticiOptiuniQuery message, CancellationToken token) - { - var queryBuilder = new StatisticiQueryBuilder - { - Query = $@"SELECT OB.Text AS Label, OB.Id AS Cod, RD.Flagged AS RaspunsCuFlag, COUNT(*) as Value - FROM Answers AS R - INNER JOIN OptionsToQuestions AS RD ON RD.Id = R.IdOptionToQuestion - INNER JOIN Options AS OB ON OB.Id = RD.Id - INNER JOIN Observers O ON O.Id = R.IdObserver - WHERE RD.Id = {message.IdIntrebare}", - CacheKey = $"StatisticiOptiuni-{message.IdIntrebare}" - }; - - queryBuilder.AndOngFilter(message.Organizator, message.IdONG); - queryBuilder.Append("GROUP BY OB.Text, OB.Id, RD.Flagged"); - - return await _cacheService.GetOrSaveDataInCacheAsync(queryBuilder.CacheKey, - async () => - { - var records = await _context.StatisticiOptiuni - .FromSql(queryBuilder.Query) - .ToListAsync(cancellationToken: token); - - return new OptiuniModel - { - IdIntrebare = message.IdIntrebare, - Optiuni = records.Select(s => new OptiuniStatisticsModel - { - IdOptiune = s.Cod, - Label = s.Label, - Value = s.Value.ToString(), - RaspunsCuFlag = s.RaspunsCuFlag - }) - .ToList(), - Total = records.Sum(s => s.Value) - }; - }, - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = new TimeSpan(message.CacheHours, message.CacheMinutes, message.CacheMinutes) - } - ); - } - - public async Task> Handle(StatisticiNumarObservatoriQuery message, CancellationToken token) - { - var queryBuilder = new StatisticiQueryBuilder - { - Query = @"select count(distinct a.IdObserver) as [Value], CountyCode as Label - from Answers a (nolock) inner join Observers o on a.IdObserver = o.Id ", - CacheKey = "StatisticiObservatori" - }; - - queryBuilder.WhereOngFilter(message.Organizator, message.IdONG); - //queryBuilder.Append("GROUP BY J.Name ORDER BY Value DESC"); - queryBuilder.Append("group by CountyCode order by [Value] desc"); - - // get or save all records in cache - var records = await _cacheService.GetOrSaveDataInCacheAsync(queryBuilder.CacheKey, - async () => - { - return await _context.StatisticiSimple - .FromSql(queryBuilder.Query) - .ToListAsync(); - }, - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = new TimeSpan(message.CacheHours, message.CacheMinutes, message.CacheMinutes) - } - ); - - // perform count and pagination on the records retrieved from the cache - var pagedList = records.Paginate(message.Page, message.PageSize); - - return new ApiListResponse - { - Data = pagedList.Select(x => _mapper.Map(x)).ToList(), - Page = message.Page, - PageSize = message.PageSize, - TotalItems = records.Count() - }; - } - - public async Task> Handle(StatisticiTopSesizariQuery message, CancellationToken token) - { - return message.Grupare == TipGrupareStatistici.Judet - ? await GetSesizariJudete(message, token) - : await GetSesizariSectii(message, token); - } - - private async Task> GetSesizariJudete(StatisticiTopSesizariQuery message, CancellationToken token) - { - var queryBuilder = new StatisticiQueryBuilder - { - Query = @"SELECT R.CountyCode AS Label, COUNT(*) as Value - FROM Answers AS R - INNER JOIN OptionsToQuestions AS RD ON RD.Id = R.IdOptionToQuestion - INNER JOIN Observers O ON O.Id = R.IdObserver - INNER JOIN Questions I ON I.Id = RD.IdQuestion - WHERE RD.Flagged = 1", - CacheKey = "StatisticiJudete" - }; - - queryBuilder.AndOngFilter(message.Organizator, message.IdONG); - queryBuilder.AndFormularFilter(message.Formular); - queryBuilder.Append("GROUP BY R.CountyCode ORDER BY Value DESC"); - - // get or save all records in cache - var records = await _cacheService.GetOrSaveDataInCacheAsync(queryBuilder.CacheKey, - async () => await _context.StatisticiSimple - .FromSql(queryBuilder.Query) - .ToListAsync(), - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = new TimeSpan(message.CacheHours, message.CacheMinutes, message.CacheMinutes) - } - ); - - // perform count and pagination on the records retrieved from the cache - var pagedList = records.Paginate(message.Page, message.PageSize); - - return new ApiListResponse - { - Data = pagedList.Select(x => _mapper.Map(x)).ToList(), - Page = message.Page, - PageSize = message.PageSize, - TotalItems = records.Count() - }; - } - - private async Task> GetSesizariSectii(StatisticiTopSesizariQuery message, CancellationToken token) - { - var queryBuilder = new StatisticiQueryBuilder - { - Query = @"SELECT R.CountyCode AS Label, R.PollingStationNumber AS Cod, COUNT(*) as Value - FROM Answers AS R - INNER JOIN OptionsToQuestions AS RD ON RD.Id = R.IdOptionToQuestion - INNER JOIN Observers O ON O.Id = R.IdObserver - INNER JOIN Questions I ON I.Id = RD.IdQuestion - WHERE RD.Flagged = 1", - CacheKey = "StatisticiSectii" - }; - - queryBuilder.AndOngFilter(message.Organizator, message.IdONG); - queryBuilder.AndFormularFilter(message.Formular); - queryBuilder.Append("GROUP BY R.CountyCode, R.PollingStationNumber"); - - // get or save paginated response in cache - return await _cacheService.GetOrSaveDataInCacheAsync($"{queryBuilder.CacheKey}-{message.Page}", - async () => - { - var records = await _context.StatisticiCompuse - .FromSql(queryBuilder.GetPaginatedQuery(message.Page, message.PageSize)) - .ToListAsync(); - - return new ApiListResponse - { - Data = records.Select(x => _mapper.Map(x)).ToList(), - Page = message.Page, - PageSize = message.PageSize, - TotalItems = await _context.StatisticiCompuse.FromSql(queryBuilder.Query).CountAsync() - }; - }, - new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = new TimeSpan(message.CacheHours, message.CacheMinutes, message.CacheMinutes) - } - ); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Service References/Application Insights/ConnectedService.json b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Service References/Application Insights/ConnectedService.json deleted file mode 100644 index d15936a8..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Service References/Application Insights/ConnectedService.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", - "Version": "8.13.10627.1", - "GettingStartedDocument": { - "Uri": "https://go.microsoft.com/fwlink/?LinkID=798432" - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/CacheService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/CacheService.cs deleted file mode 100644 index 88ff680d..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/CacheService.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Distributed; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; - -namespace MonitorizareVot.Ong.Api.Services -{ - public class CacheService : ICacheService - { - private readonly IDistributedCache _cache; - private readonly ILogger _logger; - - public CacheService(IDistributedCache cache, ILogger logger) - { - _cache = cache; - _logger = logger; - } - - public async Task GetOrSaveDataInCacheAsync(string key, Func> source, DistributedCacheEntryOptions options = null) - { - var obj = await GetObjectSafeAsync(key); - - if (obj != null) - return obj; - - var result = await source(); - - await SaveObjectSafeAsync(key, result, options); - - return result; - } - - public async Task GetObjectSafeAsync(string key) - { - var result = default(T); - - try - { - var cache = await _cache.GetAsync(key); - - if (cache == null) - { - _logger.LogInformation($"Cache missed for {key}"); - return default(T); - } - - var obj = JsonConvert.DeserializeObject(GetString(cache)); - - return obj; - - } - catch (Exception exception) - { - _logger.LogError(GetHashCode(),exception,exception.Message); - } - - return result; - } - - public async Task SaveObjectSafeAsync(string key, object value, DistributedCacheEntryOptions options = null) - { - try - { - var obj = JsonConvert.SerializeObject(value); - - if (options != null) - await _cache.SetAsync(key, GetBytes(obj), options); - else - await _cache.SetAsync(key, GetBytes(obj)); - - } - catch (Exception exception) - { - _logger.LogError(GetHashCode(), exception, exception.Message); - } - } - - private static byte[] GetBytes(string str) - { - byte[] bytes = new byte[str.Length * sizeof(char)]; - System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); - return bytes; - } - private static string GetString(byte[] bytes) - { - char[] chars = new char[bytes.Length / sizeof(char)]; - System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length); - return new string(chars); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ClearTextService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ClearTextService.cs deleted file mode 100644 index edff8f33..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ClearTextService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; -using MonitorizareVot.Ong.Api.Models; -using MonitorizareVot.Ong.Api.Services; - -namespace MonitorizareVot.Api.Services -{ - public class ClearTextService : IHashService - { - public ClearTextService(IOptions options) - { - Salt = options.Value.Salt; - } - public string Salt { get; set; } - public string GetHash(string clearString) - { - return clearString; - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/HashService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/HashService.cs deleted file mode 100644 index 81e63b1b..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/HashService.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Security.Cryptography; -using System.Text; -using Microsoft.Extensions.Options; -using MonitorizareVot.Ong.Api.Models; - -namespace MonitorizareVot.Ong.Api.Services -{ - public class HashService : IHashService - { - public HashService(IOptions options) - { - Salt = options.Value.Salt; - } - - public string Salt { get; set; } - public string GetHash(string clearString) - { - // SHA512 is disposable by inheritance. - using (var sha256 = SHA256.Create()) - { - // Send a sample text to hash. - var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(clearString + Salt)); - // Get the hashed string. - return BitConverter.ToString(hashedBytes).Replace("-", "").ToLower(); - } - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ICacheService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ICacheService.cs deleted file mode 100644 index 138ac4a9..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/ICacheService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Distributed; - -namespace MonitorizareVot.Ong.Api.Services -{ - public interface ICacheService - { - Task GetOrSaveDataInCacheAsync(string key, Func> source, DistributedCacheEntryOptions options = null); - Task GetObjectSafeAsync(string key); - Task SaveObjectSafeAsync(string key, object value, DistributedCacheEntryOptions options = null); - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/IHashService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/IHashService.cs deleted file mode 100644 index a014ca77..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/IHashService.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MonitorizareVot.Ong.Api.Services -{ - public interface IHashService - { - string Salt { get; set; } - string GetHash(string clearString); - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/NoCacheService.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/NoCacheService.cs deleted file mode 100644 index 6c61f0b2..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Services/NoCacheService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Distributed; - -namespace MonitorizareVot.Ong.Api.Services -{ - public class NoCacheService : ICacheService - { - public async Task GetOrSaveDataInCacheAsync(string key, Func> source, - DistributedCacheEntryOptions options = null) - { - return await source(); - } - - public Task GetObjectSafeAsync(string key) => throw new NotImplementedException(); - - public Task SaveObjectSafeAsync(string key, object value, - DistributedCacheEntryOptions options = null) => throw new NotImplementedException(); - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Startup.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Startup.cs deleted file mode 100644 index 79c1a8b0..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/Startup.cs +++ /dev/null @@ -1,425 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using AutoMapper; -using MediatR; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc.Authorization; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.AspNetCore.Mvc.ViewComponents; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Caching.Distributed; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.PlatformAbstractions; -using Microsoft.IdentityModel.Tokens; -using MonitorizareVot.Api.Services; -using MonitorizareVot.Domain.Ong.Models; -using MonitorizareVot.Ong.Api.Common; -using MonitorizareVot.Ong.Api.Models; -using MonitorizareVot.Ong.Api.Services; -using Serilog; -using SimpleInjector; -using SimpleInjector.Integration.AspNetCore.Mvc; -using Swashbuckle.AspNetCore.Swagger; -using ILogger = Microsoft.Extensions.Logging.ILogger; - -namespace MonitorizareVot.Api -{ - public class Startup - { - private readonly Container _container = new Container(); - private SymmetricSecurityKey _key; - - public Startup(IHostingEnvironment env) - { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); - - if (env.EnvironmentName.EndsWith("Development", StringComparison.CurrentCultureIgnoreCase)) - { - // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); - - // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately. - builder.AddApplicationInsightsSettings(developerMode: true); - } - - builder.AddEnvironmentVariables(); - Configuration = builder.Build(); - } - - private IConfigurationRoot Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container - public void ConfigureServices(IServiceCollection services) - { - services.AddOptions(); - services.Configure(options => Configuration.GetSection("HashOptions").Bind(options)); - - ConfigureJwt(services); - - services.AddAuthorization(options => - { - options.AddPolicy("AppUser", - policy => policy.RequireClaim("Organizatie", "Ngo")); - }); - - // Add framework services. - services.AddApplicationInsightsTelemetry(Configuration); - - - services.AddMvc(config => - { - var policy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - config.Filters.Add(new AuthorizeFilter(policy)); - }); - services.AddSpaStaticFiles(config => config.RootPath = "wwwroot"); - - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new Info - { - Version = "v1", - Title = "Monitorizare Vot - API ONG", - Description = "API care ofera suport portalului folosit de ONG.", - TermsOfService = "TBD", - Contact = - new Contact - { - Email = "info@monitorizarevot.ro", - Name = "Code for Romania", - Url = "http://monitorizarevot.ro" - } - }); - options.AddSecurityDefinition("bearer", new ApiKeyScheme() { - Name = "Authorization", - In = "header", - Type = "apiKey" - }); - options.AddSecurityRequirement(new Dictionary>{ - { "bearer", new[] {"readAccess", "writeAccess" } } }); - var path = PlatformServices.Default.Application.ApplicationBasePath + - Path.DirectorySeparatorChar + "MonitorizareVot.Ong.Api.xml"; - - if (File.Exists(path)) - options.IncludeXmlComments(path); - }); - - ConfigureContainer(services); - ConfigureCache(services); - } - - private void ConfigureJwt(IServiceCollection services) - { - var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions)); - - _key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["SecretKey"])); - - // Configure JwtIssuerOptions - services.Configure(options => - { - options.Issuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)]; - options.Audience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)]; - options.SigningCredentials = new SigningCredentials(_key, SecurityAlgorithms.HmacSha256); - }); - - var tokenValidationParameters = new TokenValidationParameters - { - ValidateIssuer = true, - ValidIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)], - - ValidateAudience = true, - ValidAudience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)], - - ValidateIssuerSigningKey = true, - IssuerSigningKey = _key, - - RequireExpirationTime = true, - ValidateLifetime = true, - - ClockSkew = TimeSpan.Zero - }; - - //var events = new JwtBearerEvents - //{ - // OnAuthenticationFailed = (context) => - // { - // if (context.Exception is SecurityTokenExpiredException && - // context.Request.Path.ToString().ToLower() == "/api/v1/auth" && - // context.Request.Method.ToLower() == "put") - // { - // // skip authentification - // context.SkipToNextMiddleware(); - // } - - // return Task.FromResult(0); - // }, - // OnTokenValidated = (context) => - // { - // if (context.Request.Path.ToString().ToLower() == "/api/v1/auth" && - // context.Request.Method.ToLower() == "put") - // { - // context.HandleResponse(); - // throw new SecurityTokenSignatureKeyNotFoundException(); - // } - - // return Task.FromResult(0); - // } - //}; - - //var jwtoptions = new JwtBearerOptions - //{ - // AutomaticAuthenticate = true, - // AutomaticChallenge = true, - // TokenValidationParameters = tokenValidationParameters, - // Events = events - //}); - - services.AddAuthentication(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) - .AddJwtBearer(options => - { - options.TokenValidationParameters = tokenValidationParameters; - //options.Events = events; - options.Audience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)]; - options.RequireHttpsMetadata = false; - options.ClaimsIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)]; - }); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, - IApplicationLifetime appLifetime, IDistributedCache cache) - { - app.UseStaticFiles(); - app.UseSpaStaticFiles(); - - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - - loggerFactory.AddSerilog(); - Log.Logger = new LoggerConfiguration() - .WriteTo - .ApplicationInsightsTraces(Configuration["ApplicationInsights:InstrumentationKey"]) - .CreateLogger(); - - appLifetime.ApplicationStopped.Register(Log.CloseAndFlush); - - app.Use(async (context, next) => - { - await next(); - if (context.Response.StatusCode == 404 && !context.Request.Path.Value.StartsWith("/api") && !Path.HasExtension(context.Request.Path.Value)) - { - context.Request.Path = "/index.html"; - await next(); - } - }); - - - app.UseExceptionHandler( - builder => - { - builder.Run(context => - { - context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; - context.Response.ContentType = "application/json"; - return Task.FromResult(0); - } - ); - }); - - app.UseAuthentication(); - - ConfigureHash(app); - - RegisterServices(app); - - InitializeContainer(app); - - RegisterDbContext(Configuration.GetConnectionString("DefaultConnection")); - - RegisterAutomapper(); - - BuildMediator(); - - _container.Verify(); - - // Enable middleware to serve generated Swagger as a JSON endpoint - app.UseSwagger(); - - // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.) - app.UseSwaggerUI(o => o.SwaggerEndpoint("/swagger/v1/swagger.json", "MV API v1")); - - app.UseMvc(); - app.UseSpa(options => { options.Options.SourcePath = "../../frontend"; }); - } - - private void ConfigureCache(IServiceCollection services) - { - var enableCache = Configuration.GetValue("ApplicationCacheOptions:Enabled"); - - if (!enableCache) - { - _container.RegisterInstance(new NoCacheService()); - return; - } - - var cacheProvider = Configuration.GetValue("ApplicationCacheOptions:Implementation"); - - _container.RegisterSingleton(); - - switch (cacheProvider) - { - case "RedisCache": - { - services.AddDistributedRedisCache(options => - { - Configuration.GetSection("RedisCacheOptions").Bind(options); - }); - - //_container.RegisterInstance( - // new RedisCache( - // new OptionsManager(new List> - // { - // new ConfigureFromConfigurationOptions( - // Configuration.GetSection("RedisCacheOptions")) - // }) - // )); - break; - } - - default: - case "MemoryDistributedCache": - { - - services.AddDistributedMemoryCache(); - // _container.RegisterInstance(new MemoryDistributedCache(new MemoryCache(new MemoryCacheOptions()))); - break; - } - } - } - - private void ConfigureHash(IApplicationBuilder app) - { - _container.RegisterSingleton(() => app.ApplicationServices.GetService>()); - var hashOptions = new HashOptions(); - Configuration.GetSection(nameof(HashOptions)).Bind(hashOptions); - - if (hashOptions.ServiceType == nameof(HashServiceType.ClearText)) - _container.RegisterSingleton(); - else - _container.RegisterSingleton(); - } - - private void ConfigureContainer(IServiceCollection services) - { - services.UseSimpleInjectorAspNetRequestScoping(_container); - - _container.Options.DefaultScopedLifestyle = new SimpleInjector.Lifestyles.AsyncScopedLifestyle();// AspNetRequestLifestyle(); - - services.AddSingleton( - new SimpleInjectorControllerActivator(_container)); - services.AddSingleton( - new SimpleInjectorViewComponentActivator(_container)); - } - - private void RegisterServices(IApplicationBuilder app) - { - //exemplu de servicii custom - _container.Register(() => app.ApplicationServices.GetService>(), Lifestyle.Transient); - //container.Register(Lifestyle.Scoped); - } - - private void InitializeContainer(IApplicationBuilder app) - { - // Add application presentation components: - _container.RegisterMvcControllers(app); - _container.RegisterMvcViewComponents(app); - - // Add application services. For instance: - //container.Register(Lifestyle.Scoped); - - - // Cross-wire ASP.NET services (if any). For instance: - _container.RegisterInstance(app.ApplicationServices.GetService()); - _container.RegisterConditional( - typeof(ILogger), - c => typeof(Logger<>).MakeGenericType(c.Consumer.ImplementationType), - Lifestyle.Singleton, - c => true); - - _container.RegisterInstance(Configuration); - } - - private void RegisterDbContext(string connectionString = null) - where TDbContext : DbContext - { - if (!string.IsNullOrEmpty(connectionString)) - { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlServer(connectionString); - - _container.RegisterInstance(optionsBuilder.Options); - - _container.Register(Lifestyle.Scoped); - } - else - { - _container.Register(Lifestyle.Scoped); - } - } - - private IMediator BuildMediator() - { - var assemblies = GetAssemblies().ToArray(); - _container.RegisterSingleton(); - _container.Register(typeof(IRequestHandler<,>), assemblies); - _container.Register(typeof(AsyncRequestHandler<,>), assemblies); - _container.Collection.Register(typeof(INotificationHandler<>), assemblies); - _container.Collection.Register(typeof(AsyncNotificationHandler<>), assemblies); - _container.RegisterInstance(Console.Out); - _container.RegisterInstance(new SingleInstanceFactory(_container.GetInstance)); - _container.RegisterInstance(new MultiInstanceFactory(_container.GetAllInstances)); - - // had to add this registration as we were getting the same behavior as described here: https://github.com/jbogard/MediatR/issues/155 - _container.Collection.Register(typeof(IPipelineBehavior<,>), Enumerable.Empty()); - - var mediator = _container.GetInstance(); - - return mediator; - } - - private void RegisterAutomapper() - { - Mapper.Initialize(cfg => - { - cfg.AddProfiles(GetAssemblies()); - cfg.CreateMissingTypeMaps = true; - }); - - _container.RegisterInstance(Mapper.Configuration); - _container.Register(() => new Mapper(Mapper.Configuration), Lifestyle.Scoped); - } - - private static IEnumerable GetAssemblies() - { - yield return typeof(IMediator).GetTypeInfo().Assembly; - yield return typeof(Startup).GetTypeInfo().Assembly; - yield return typeof(VoteMonitorContext).GetTypeInfo().Assembly; - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationRole.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationRole.cs deleted file mode 100644 index 16e923e2..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationRole.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MonitorizareVot.Ong.Api -{ - internal class ApplicationRole - { - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationUser.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationUser.cs deleted file mode 100644 index 5fef9c23..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ApplicationUser.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using MediatR; -using MonitorizareVot.Ong.Api.Models; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class ApplicationUser : IRequest - { - [Required(AllowEmptyStrings = false)] - public string UserName { get; set; } - - [Required(AllowEmptyStrings = false)] - public string Password { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruFormulareModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruFormulareModel.cs deleted file mode 100644 index 99ce3dfb..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruFormulareModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class FiltruFormulareModel - { - public string IdFormular { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruNoteModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruNoteModel.cs deleted file mode 100644 index e43a5d1f..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruNoteModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class FiltruNoteModel - { - public int SectionId { get; set; } - public int ObserverId { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriCompletateModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriCompletateModel.cs deleted file mode 100644 index 2ebfa51a..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriCompletateModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class FiltruRaspunsuriModel - { - public int IdSectieDeVotare { get; set; } - public int IdObservator { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriModel.cs deleted file mode 100644 index f457d964..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruRaspunsuriModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class FiltruRaspunsuriSectiiModel : PagingModel - { - public bool Urgent { get; set; } - public string County { get; set; } - public int PollingStationNumber { get; set; } - public int ObserverId { get; set; } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruStatisticiSimple.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruStatisticiSimple.cs deleted file mode 100644 index 699f2f84..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/FiltruStatisticiSimple.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class FiltruStatisticiSimple : PagingModel - { - public string Formular { get; set; } - public TipGrupareStatistici Grupare { get; set; } - } - - public class StatisticsProfile : Profile - { - public StatisticsProfile() - { - CreateMap() - .ForMember(dest => dest.Label, c => c.MapFrom(src => $"Sectia {src.Cod} {src.Label}")) - .ForMember(dest => dest.Value, c => c.MapFrom(src => src.Value.ToString())); - - CreateMap() - .ForMember(dest => dest.Value, c => c.MapFrom(src => src.Value.ToString())); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ImportObserversRequest.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ImportObserversRequest.cs deleted file mode 100644 index 59a34b5f..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ImportObserversRequest.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediatR; - -namespace MonitorizareVot.Api.ViewModels -{ - public class ImportObserversRequest : IRequest - { - public int IdOng { get; set; } - public string FilePath { get; set; } - public int NameIndexInFile { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/IntrebareModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/IntrebareModel.cs deleted file mode 100644 index 0c2a90d8..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/IntrebareModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -using MediatR; -using System.Collections.Generic; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class IntrebareModel - where T : class - { - public int IdIntrebare { get; set; } - public string TextIntrebare { get; set; } - public int IdTipIntrebare { get; set; } - public string CodIntrebare { get; set; } - public string CodFormular { get; set; } - - public IList Raspunsuri { get; set; } - } - - public class RaspunsuriCompletateQuery : IRequest>> - { - public int IdSectieDeVotare { get; set; } - public int IdObservator { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/MiniStatisticsRequests.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/MiniStatisticsRequests.cs deleted file mode 100644 index ca36b0be..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/MiniStatisticsRequests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using MediatR; -using MonitorizareVot.Ong.Api.ViewModels; - -namespace MonitorizareVot.Api.ViewModels -{ - public class AnswersRequest : IRequest - { - } - public class StationsVisitedRequest : IRequest - { - } - public class FlaggedAnswersRequest : IRequest - { - } - public class CountiesVisitedRequest : IRequest - { - } - public class NotesUploadedRequest : IRequest - { - } - public class LoggedInObserversRequest : IRequest - { - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NewObserverRequest.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NewObserverRequest.cs deleted file mode 100644 index f48d633c..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NewObserverRequest.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MediatR; - -namespace MonitorizareVot.Api.ViewModels -{ - public class NewObserverRequest : IRequest - { - public int IdOng { get; set; } - public string NumarTelefon { get; set; } - public string PIN { get; set; } - public string Nume { get; set; } - public bool SendSMS { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaDetaliiModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaDetaliiModel.cs deleted file mode 100644 index 12e306e1..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaDetaliiModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class NotaDetaliiModel - { - public int IdNota { get; set; } - public string CaleFisierAtasat { get; set; } - public string TextNota { get; set; } - public string CodFormular { get; set; } - public int CodIntrebare { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaModel.cs deleted file mode 100644 index 4825b3ad..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/NotaModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using MediatR; -using System.Collections.Generic; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class NotaModel - { - public int IdNota { get; set; } - public string CaleFisierAtasat { get; set; } - public string TextNota { get; set; } - public string CodFormular { get; set; } - public int? CodIntrebare { get; set; } - } - - public class NotaQuery : IRequest> - { - public int IdSectieDeVotare { get; set; } - public int IdObservator { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ObserverModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ObserverModel.cs deleted file mode 100644 index 55f656cd..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ObserverModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace MonitorizareVot.Api.ViewModels -{ - public class ObserverModel - { - public int IdOng { get; set; } - public string NumarTelefon { get; set; } - public string PIN { get; set; } - public string Nume { get; set; } - public bool SendSMS { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniFiltruModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniFiltruModel.cs deleted file mode 100644 index 913cf881..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniFiltruModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using MediatR; -using System.ComponentModel.DataAnnotations; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class OptiuniFiltruModel - { - [Required] - public int IdIntrebare { get; set; } - } - - public class StatisticiOptiuniQuery : StatisticiQuery, IRequest - { - public int IdIntrebare { get; set; } - } - - public class StatisticiQuery - { - public int IdONG { get; set; } - public bool Organizator { get; set; } - public int CacheHours { get; set; } - public int CacheMinutes { get; set; } - public int CacheSeconds { get; set; } - } - - public class StatisticiPaginatedQuery : PagingModel - { - public int IdONG { get; set; } - public bool Organizator { get; set; } - public int CacheHours { get; set; } - public int CacheMinutes { get; set; } - public int CacheSeconds { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniModel.cs deleted file mode 100644 index b17c10bd..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/OptiuniModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class OptiuniModel - { - public int IdIntrebare { get; set; } - public IList Optiuni { get; set; } - public int Total { get; set; } - } - - public class OptiuniStatisticsModel : SimpleStatisticsModel - { - public int IdOptiune { get; set; } - public bool RaspunsCuFlag { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/PagingModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/PagingModel.cs deleted file mode 100644 index 92ba6983..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/PagingModel.cs +++ /dev/null @@ -1,39 +0,0 @@ -using MonitorizareVot.Ong.Api.Common; -using System; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class PagingModel - { - protected int _page; - protected int _pageSize; - - public int Page - { - get { return _page; } - set { _page = value < 1 ? Constants.DEFAULT_PAGE : value; } - } - - public int PageSize - { - get { return _pageSize; } - set { _pageSize = value < 1 ? Constants.DEFAULT_PAGE_SIZE : value; } - } - } - - public class PagingResponseModel : PagingModel - { - protected int _totalItems; - - public int TotalItems - { - get { return _totalItems; } - set { _totalItems = value; } - } - - public int TotalPages - { - get { return 1 + (_totalItems - 1) / _pageSize; } - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsCompletatModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsCompletatModel.cs deleted file mode 100644 index 72a92dda..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsCompletatModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Linq; -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class RaspunsCompletatModel - { - public int IdOptiune { get; set; } - public string TextOptiune { get; set; } - public bool SeIntroduceText { get; set; } - public string Value { get; set; } - public bool RaspunsCuFlag { get; set; } - } - - public class RaspunsProfile : Profile - { - public RaspunsProfile() - { - CreateMap>() - .ForMember(dest => dest.Raspunsuri, c => c.MapFrom(src => src.OptionsToQuestions)) - .ForMember(dest => dest.IdIntrebare, c => c.MapFrom(src => src.Id)) - .ForMember(dest => dest.TextIntrebare, c => c.MapFrom(src => src.Text)) - .ForMember(dest => dest.IdTipIntrebare, c => c.MapFrom(src => src.QuestionType)) - .ForMember(dest => dest.CodIntrebare, c => c.MapFrom(src => src.Code)) - .ForMember(dest => dest.CodFormular, c => c.MapFrom(src => src.FormCode)) - ; - - CreateMap() - .ForMember(dest => dest.TextOptiune, c => c.MapFrom(src => src.Option.Text)) - .ForMember(dest => dest.SeIntroduceText, c => c.MapFrom(src => src.Option.IsFreeText)) - .ForMember(dest => dest.IdOptiune, c => c.MapFrom(src => src.Id)) - .ForMember(dest => dest.RaspunsCuFlag, c => c.MapFrom(src => src.Flagged)) - .ForMember(dest => dest.Value, c => c.MapFrom(src => src.Answers.First().Value)); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsDisponibilModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsDisponibilModel.cs deleted file mode 100644 index 797fb3d3..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsDisponibilModel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; -using System.Linq; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class RaspunsDisponibilModel - { - public int IdOptiune { get; set; } - public string TextOptiune { get; set; } - public bool SeIntroduceText { get; set; } - } - - public class FormularProfile : Profile - { - public FormularProfile() - { - CreateMap>() - .ForMember(dest => dest.Raspunsuri, c => c.MapFrom(src => src.OptionsToQuestions)) - .ForMember(dest => dest.IdIntrebare, c => c.MapFrom(src => src.Id)) - .ForMember(dest => dest.TextIntrebare, c => c.MapFrom(src => src.Text)) - .ForMember(dest => dest.IdTipIntrebare, c => c.MapFrom(src => src.QuestionType)) - .ForMember(dest => dest.CodIntrebare, c => c.MapFrom(src => src.Code)) - .ForMember(dest => dest.CodFormular, c => c.MapFrom(src => src.FormCode)) - ; - - CreateMap() - .ForMember(dest => dest.TextOptiune, c => c.MapFrom(src => src.Option.Text)) - .ForMember(dest => dest.SeIntroduceText, c => c.MapFrom(src => src.Option.IsFreeText)) - .ForMember(dest => dest.IdOptiune, c => c.MapFrom(src => src.Id)); - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsFormularModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsFormularModel.cs deleted file mode 100644 index 072cc719..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsFormularModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using MediatR; -using System; -using System.Collections.Generic; -using AutoMapper; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class RaspunsFormularModel - { - public DateTime DataUltimeiModificari { get; set; } - public bool? EsteZonaUrbana { get; set; } - public DateTime? OraPlecarii { get; set; } - public DateTime? OraSosirii { get; set; } - public bool? PresedinteBesvesteFemeie { get; set; } - } - - public class RaspunsFomularProfile : Profile - { - public RaspunsFomularProfile() - { - CreateMap() - .ForMember(dest => dest.DataUltimeiModificari, o => o.MapFrom(src => src.LastModified)) - .ForMember(dest => dest.EsteZonaUrbana, o => o.MapFrom(src => src.UrbanArea)) - .ForMember(dest => dest.OraPlecarii, o => o.MapFrom(src => src.ObserverLeaveTime)) - .ForMember(dest => dest.OraSosirii, o => o.MapFrom(src => src.ObserverArrivalTime)) - .ForMember(dest => dest.PresedinteBesvesteFemeie, o => o.MapFrom(src => src.IsPollingStationPresidentFemale)) - ; - } - } - - public class RaspunsuriFormularQuery : IRequest - { - public int IdSectieDeVotare { get; set; } - public int IdObservator { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsModel.cs deleted file mode 100644 index d42424bd..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/RaspunsModel.cs +++ /dev/null @@ -1,26 +0,0 @@ -using MediatR; -using MonitorizareVot.Ong.Api.Extensions; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class RaspunsModel - { - public string Sectie { get; set; } - - public string Observator { get; set; } - - public int IdSectie { get; set; } - - public int IdObservator { get; set; } - } - - public class RaspunsuriQuery : PagingModel, IRequest> - { - public int IdONG { get; set; } - public bool Urgent { get; set; } - public bool Organizator { get; set; } - public string County { get; set; } - public int PollingStationNumber { get; set; } - public int ObserverId { get; set; } - } -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ResetDeviceIdRequest.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ResetDeviceIdRequest.cs deleted file mode 100644 index d69c6032..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/ResetDeviceIdRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MediatR; - -namespace MonitorizareVot.Api.ViewModels -{ - public class ResetDeviceIdRequest : IRequest - { - public string PhoneNumber { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SectiuneModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SectiuneModel.cs deleted file mode 100644 index c96efcae..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SectiuneModel.cs +++ /dev/null @@ -1,22 +0,0 @@ -using AutoMapper; -using MediatR; -using MonitorizareVot.Domain.Ong.Models; -using System.Collections.Generic; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class SectiuneModel - { - public string CodSectiune { get; set; } - public string Descriere { get; set; } - - public List> Intrebari { get; set; } - } - - public class IntrebariQuery : IRequest> - { - public string CodFormular { get; set; } - } - - -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SimpleStatisticsModel.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SimpleStatisticsModel.cs deleted file mode 100644 index ce1e5ac9..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/ViewModels/SimpleStatisticsModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using MediatR; -using MonitorizareVot.Ong.Api.Extensions; - -namespace MonitorizareVot.Ong.Api.ViewModels -{ - public class SimpleStatisticsModel - { - public string Label { get; set; } - public string Value { get; set; } - } - - public class StatisticiNumarObservatoriQuery : StatisticiPaginatedQuery, IRequest> - { - } - - public enum TipGrupareStatistici - { - Judet, - Sectie - } - - public class StatisticiTopSesizariQuery : StatisticiPaginatedQuery, IRequest> - { - public string Formular { get; set; } - public TipGrupareStatistici Grupare { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/appsettings.json b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/appsettings.json deleted file mode 100644 index a0351dc0..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/appsettings.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "SecretKey": "SuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBRSuperSecretKetyTBR", - "ApplicationInsights": { - "InstrumentationKey": "8a651020-680a-4eed-8ec3-547056862744" - }, - "JwtIssuerOptions": { - "Issuer": "SuperAwesomeTokenServer", - "Audience": "http://localhost:1783/" - }, - "ConnectionStrings": { - "DefaultConnection": "Server=192.168.0.116;Database=monvotong;User Id=code4;Password=code4;" - }, - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - }, - "ApplicationCacheOptions": { - "Enabled": false, - "Implementation": "MemoryDistributedCache" // MemoryDistributedCache or RedisCache - }, - "RedisCacheOptions": { - "Configuration": "TBR", - "InstanceName": "TBR" - }, - // "HashOptions": { - // "Salt": "TBR" - // }, - "DefaultIdOng": 2, - "DefaultOrganizator": false, - - // CACHE KEY VALABILITY - "DefaultCacheHours": 0, - "DefaultCacheMinutes": 30, - "DefaultCacheSeconds": 0 -} \ No newline at end of file diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/web.config b/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/web.config deleted file mode 100644 index dc0514fc..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Api/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Builders/ObserverBuilder.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Builders/ObserverBuilder.cs deleted file mode 100644 index 037660e3..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Builders/ObserverBuilder.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MonitorizareVot.Domain.Ong.Models; - -namespace MonitorizareVot.Domain.Ong.Builders -{ - public interface IBuilder - { - T build(int IdNgo); - } - - public interface IObserverBuilder : IBuilder - { - void SetFromTeam(bool fromTeam); - void SetIdNgo(int idNgo); - void SetName(string Name); - void SetPhone(string phone); - void SetPin(string pin); - void SetMobileDeviceId(string mobileDeviceId); - void SetDeviceRegisterDate(DateTime? dateTime); - } - - public class RandomObserverBuilder : IObserverBuilder - { - Observer _observer; - - public RandomObserverBuilder() - { - _observer = new Observer(); - } - - public Observer build(int IdNgo) - { - this.SetFromTeam(false); - this.SetIdNgo(IdNgo); - this.SetPhone(RandomNumberGenerator.GenerateWithPadding(10, "07")); - this.SetPin(RandomNumberGenerator.Generate(6)); - this.SetMobileDeviceId(null); - this.SetDeviceRegisterDate(null); - this.SetName(String.Empty); - - return _observer; - } - - public void SetDeviceRegisterDate(DateTime? dateTime) - { - _observer.DeviceRegisterDate = dateTime; - } - - public void SetFromTeam(bool fromTeam) - { - _observer.FromTeam = fromTeam; - } - - public void SetIdNgo(int idNgo) - { - _observer.IdNgo = idNgo; - } - - public void SetMobileDeviceId(string mobileDeviceId) - { - _observer.MobileDeviceId = mobileDeviceId; - } - - public void SetPhone(string phone) - { - _observer.Phone = phone; - } - - public void SetPin(string pin) - { - _observer.Pin = pin; - } - - public void SetName(string Name) - { - _observer.Name = Name; - } - } - - public class RandomNumberGenerator - { - public static string Generate(int digits) - { - Random random = new Random(); - string number = ""; - for(int i = 1; i < digits + 1; i++) - { - number += random.Next(0, 9).ToString(); - } - return number; - } - - public static string GenerateWithPadding(int digits, string prefix) - { - Random random = new Random(); - string number = prefix; - for(int i = 1 + prefix.Length; i < digits + 1; i++) - { - number += random.Next(0, 9).ToString(); - } - return number; - } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Answer.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Answer.cs deleted file mode 100644 index 4c4dd745..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Answer.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Answer - { - public int IdObserver { get; set; } - public int IdOptionToQuestion { get; set; } - public int IdPollingStation { get; set; } - public DateTime LastModified { get; set; } - public string Value { get; set; } - - public string CountyCode { get; set; } - - public int PollingStationNumber { get; set; } - - public virtual Observer Observer { get; set; } - public virtual OptionToQuestion OptionAnswered { get; set; } - public virtual PollingStation PollingStation { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/County.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/County.cs deleted file mode 100644 index 09a4c9fd..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/County.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class County - { - public County() - { - PollingStations = new HashSet(); - } - - public int Id { get; set; } - public string Code { get; set; } - public string Name { get; set; } - public int NumberOfPollingStations { get; set; } - - public virtual ICollection PollingStations { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormSection.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormSection.cs deleted file mode 100644 index 87a47fc0..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormSection.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class FormSection - { - public FormSection() - { - Questions = new HashSet(); - } - - public int Id { get; set; } - public string Code { get; set; } - public string Description { get; set; } - - public virtual ICollection Questions { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormVersion.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormVersion.cs deleted file mode 100644 index 54b00092..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/FormVersion.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class FormVersion - { - public string Code { get; set; } - public int CurrentVersion { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Ngo.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Ngo.cs deleted file mode 100644 index 4f818950..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Ngo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Ngo - { - public Ngo() - { - NgoAdmins = new HashSet(); - Observers = new HashSet(); - } - - public int Id { get; set; } - public string ShortName { get; set; } - public string Name { get; set; } - public bool Organizer { get; set; } - - public virtual ICollection NgoAdmins { get; set; } - public virtual ICollection Observers { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/NgoAdmin.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/NgoAdmin.cs deleted file mode 100644 index 120a84ff..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/NgoAdmin.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class NgoAdmin - { - public int Id { get; set; } - public int IdNgo { get; set; } - public string Account { get; set; } - public string Password { get; set; } - - public virtual Ngo Ngo { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Note.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Note.cs deleted file mode 100644 index 4aac163d..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Note.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Note - { - public int Id { get; set; } - public string AttachementPath { get; set; } - public DateTime LastModified { get; set; } - public int? IdQuestion { get; set; } - public int IdObserver { get; set; } - public int IdPollingStation { get; set; } - public string Text { get; set; } - - public virtual Question Question { get; set; } - public virtual Observer Observer { get; set; } - public virtual PollingStation PollingStation { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Observer.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Observer.cs deleted file mode 100644 index b6c92f55..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Observer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Observer - { - public Observer() - { - Notes = new HashSet(); - Answers = new HashSet(); - PollingStationInfos = new HashSet(); - } - - public int Id { get; set; } - public bool FromTeam { get; set; } - public int IdNgo { get; set; } - public string Phone { get; set; } - public string Name { get; set; } - public string Pin { get; set; } - public string MobileDeviceId { get; set; } - public DateTime? DeviceRegisterDate { get; set; } - - public virtual ICollection Notes { get; set; } - public virtual ICollection Answers { get; set; } - public virtual ICollection PollingStationInfos { get; set; } - public virtual Ngo Ngo { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Option.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Option.cs deleted file mode 100644 index 619aebb6..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Option.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Option - { - public Option() - { - OptionsToQuestions = new HashSet(); - } - - public int Id { get; set; } - public bool IsFreeText { get; set; } - public string Text { get; set; } - public string Hint { get; set; } - - public virtual ICollection OptionsToQuestions { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/OptionToQuestion.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/OptionToQuestion.cs deleted file mode 100644 index 1ec2ffda..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/OptionToQuestion.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class OptionToQuestion - { - public OptionToQuestion() - { - Answers = new HashSet(); - } - - public int Id { get; set; } - public int IdQuestion { get; set; } - public int IdOption { get; set; } - public bool Flagged { get; set; } - - public virtual ICollection Answers { get; set; } - public virtual Question Question { get; set; } - public virtual Option Option { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStation.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStation.cs deleted file mode 100644 index 4e69565e..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStation.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class PollingStation - { - public PollingStation() - { - Notes = new HashSet(); - Answers = new HashSet(); - PollingStationInfos = new HashSet(); - } - - public int Id { get; set; } - public string Address { get; set; } - public string Coordinates { get; set; } - public string AdministrativeTerritoryCode { get; set; } - public int IdCounty { get; set; } - public string TerritoryCode { get; set; } - public int Number { get; set; } - - public virtual ICollection Notes { get; set; } - public virtual ICollection Answers { get; set; } - public virtual ICollection PollingStationInfos { get; set; } - public virtual County County { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStationInfo.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStationInfo.cs deleted file mode 100644 index 996e809b..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/PollingStationInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class PollingStationInfo - { - public int IdObserver { get; set; } - public int IdPollingStation { get; set; } - public DateTime LastModified { get; set; } - public bool? UrbanArea { get; set; } - public DateTime? ObserverLeaveTime { get; set; } - public DateTime? ObserverArrivalTime { get; set; } - public bool? IsPollingStationPresidentFemale { get; set; } - - public virtual Observer Observer { get; set; } - public virtual PollingStation PollingStation { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Question.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Question.cs deleted file mode 100644 index 5b22782a..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Question.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class Question - { - public Question() - { - Notes = new HashSet(); - OptionsToQuestions = new HashSet(); - } - - public int Id { get; set; } - public string FormCode { get; set; } - public string Code { get; set; } - public int IdSection { get; set; } - public int QuestionType { get; set; } - public string Text { get; set; } - public string Hint { get; set; } - - public virtual ICollection Notes { get; set; } - public virtual ICollection OptionsToQuestions { get; set; } - public virtual FormSection FormSection { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/RaspunsSectie.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/RaspunsSectie.cs deleted file mode 100644 index c773c4e8..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/RaspunsSectie.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public class RaspunsSectie - { - public string Sectie { get; set; } - - public string Observator { get; set; } - - public int IdSectie { get; set; } - - public int IdObservator { get; set; } - - public DateTime DataUltimeiModificari { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Statistici.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Statistici.cs deleted file mode 100644 index 2ece0bbf..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/Statistici.cs +++ /dev/null @@ -1,24 +0,0 @@ - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class StatisticiSimple - { - public string Label { get; set; } - public int Value { get; set; } - } - - public partial class StatisticiCompuse - { - public string Label { get; set; } - public int Cod { get; set; } - public int Value { get; set; } - } - - public partial class StatisticiOptiuni - { - public string Label { get; set; } - public int Value { get; set; } - public int Cod { get; set; } - public bool RaspunsCuFlag { get; set; } - } -} diff --git a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContext.cs b/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContext.cs deleted file mode 100644 index b9fbf17b..00000000 --- a/api/MonitorizareVot.Ong/src/MonitorizareVot.Domain.Ong/Models/VoteMonitorContext.cs +++ /dev/null @@ -1,380 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace MonitorizareVot.Domain.Ong.Models -{ - public partial class VoteMonitorContext : DbContext - { - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_NgoAdminId"); - - entity.ToTable("NgoAdmin"); - - entity.Property(e => e.Id) - .ValueGeneratedNever(); - - entity.Property(e => e.Account) - .IsRequired() - .HasMaxLength(50); - - entity.Property(e => e.Password) - .IsRequired() - .HasMaxLength(100); - - entity.HasOne(d => d.Ngo) - .WithMany(p => p.NgoAdmins) - .HasForeignKey(d => d.IdNgo) - .OnDelete(DeleteBehavior.Restrict) - .HasConstraintName("FK_NgoAdmin_Ngo"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_Question"); - - entity.HasIndex(e => e.IdSection) - .HasName("IX_Question_IdSection"); - - entity.Property(e => e.Id).ValueGeneratedNever(); - - entity.Property(e => e.FormCode) - .IsRequired() - .HasMaxLength(2); - - entity.Property(e => e.Text) - .IsRequired() - .HasMaxLength(200); - - entity.HasOne(d => d.FormSection) - .WithMany(p => p.Questions) - .HasForeignKey(d => d.IdSection) - .OnDelete(DeleteBehavior.Restrict); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_County"); - - entity.Property(e => e.Id).ValueGeneratedNever(); - - entity.Property(e => e.Code) - .IsRequired() - .HasMaxLength(20); - - entity.Property(e => e.Name) - .IsRequired() - .HasMaxLength(100); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_Note"); - - entity.HasIndex(e => e.IdQuestion) - .HasName("IX_Note_IdQuestion"); - - entity.HasIndex(e => e.IdObserver) - .HasName("IX_Note_IdObserver"); - - entity.HasIndex(e => e.IdPollingStation) - .HasName("IX_Note_IdPollingStation"); - - entity.Property(e => e.AttachementPath).HasMaxLength(1000); - - entity.Property(e => e.LastModified).HasColumnType("datetime"); - - entity.HasOne(d => d.Question) - .WithMany(p => p.Notes) - .HasForeignKey(d => d.IdQuestion) - .HasConstraintName("FK_Note_Question"); - - entity.HasOne(d => d.Observer) - .WithMany(p => p.Notes) - .HasForeignKey(d => d.IdObserver) - .OnDelete(DeleteBehavior.Restrict); - - entity.HasOne(d => d.PollingStation) - .WithMany(p => p.Notes) - .HasForeignKey(d => d.IdPollingStation) - .OnDelete(DeleteBehavior.Restrict); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_Observer"); - - entity.HasIndex(e => e.IdNgo) - .HasName("IX_Observer_IdNgo"); - - entity.Property(e => e.Id).ValueGeneratedNever(); - - entity.Property(e => e.DeviceRegisterDate).HasColumnType("datetime"); - - entity.Property(e => e.FromTeam).HasDefaultValueSql("0"); - - entity.Property(e => e.MobileDeviceId).HasColumnType("varchar(500)"); - - entity.Property(e => e.Phone) - .IsRequired() - .HasMaxLength(20); - - entity.Property(e => e.Name) - .IsRequired() - .HasMaxLength(200); - - entity.Property(e => e.Pin) - .IsRequired() - .HasMaxLength(100); - - entity.HasOne(d => d.Ngo) - .WithMany(p => p.Observers) - .HasForeignKey(d => d.IdNgo) - .OnDelete(DeleteBehavior.Restrict); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id) - .HasName("PK_NGO"); - - entity.Property(e => e.Id).ValueGeneratedNever(); - - entity.Property(e => e.ShortName) - .IsRequired() - .HasMaxLength(10); - - entity.Property(e => e.Name) - .IsRequired() - .HasMaxLength(200); - - entity.Property(e => e.Organizer).HasDefaultValueSql("0"); - }); - - modelBuilder.Entity