├── .gitignore ├── EMS.Application ├── Common │ └── AppService.cs ├── EMS.Application.csproj ├── Hrm │ ├── Implementations │ │ └── EmployeeAppService.cs │ └── Interfaces │ │ └── IEmployeeAppService.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── EMS.Core ├── Application │ ├── IAppService.cs │ ├── IReadOnlyAppService.cs │ ├── ITransactionAppService.cs │ └── IWriteOnlyAppService.cs ├── Domain │ ├── Entities │ │ ├── BaseDto.cs │ │ ├── BaseEntity.cs │ │ ├── BaseValueObject.cs │ │ ├── IAggregateRoot.cs │ │ └── IEntity.cs │ ├── Event │ │ ├── DomainEvents.cs │ │ ├── Handle.cs │ │ └── IDomainEvent.cs │ ├── Repository │ │ ├── IReadOnlyRepository.cs │ │ ├── IRepository.cs │ │ └── IWriteOnlyRepository.cs │ ├── Service │ │ ├── IReadOnlyService.cs │ │ ├── IService.cs │ │ └── IWriteOnlyService.cs │ ├── Specification │ │ ├── And.cs │ │ ├── IExtensions.cs │ │ ├── ISpecification.cs │ │ ├── Negate.cs │ │ ├── Or.cs │ │ └── SpecificationBase.cs │ └── Validation │ │ ├── ISelfValidation.cs │ │ ├── IValidation.cs │ │ ├── IValidationRule.cs │ │ ├── Validation.cs │ │ ├── ValidationError.cs │ │ ├── ValidationResult.cs │ │ └── ValidationRule.cs ├── EMS.Core.csproj ├── ErpSetup │ └── VersionInfo.cs ├── Helpers │ ├── EntityState.cs │ ├── EnumDatabase.cs │ ├── EnumHelper.cs │ ├── EnumSchema.cs │ ├── ExtensionMethods.cs │ ├── JSONHelper.cs │ └── ServiceStatus.cs ├── Infra │ └── Data │ │ └── IUnitOfWork.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── EMS.Domain.Services ├── Common │ ├── ReadOnlyService.cs │ ├── Service.cs │ └── WriteOnlyService.cs ├── EMS.Domain.Services.csproj ├── Hrm │ ├── Implementations │ │ └── EmployeeService.cs │ └── Interfaces │ │ └── IEmployeeService.cs ├── Properties │ └── AssemblyInfo.cs └── app.config ├── EMS.Domain ├── EMS.Domain.csproj ├── Hrm │ ├── Dtos │ │ └── EmployeeDto.cs │ ├── Entities │ │ └── Employee.cs │ ├── Repository │ │ ├── IEmployeeRepository.cs │ │ └── ReadOnly │ │ │ └── IEmployeeReadOnlyRepository.cs │ ├── Resorces │ │ ├── ValidationMessages.Designer.cs │ │ └── ValidationMessages.resx │ ├── Specifications │ │ └── EmployeeSpecs │ │ │ └── EmployeeFirstNameIsRequiredSpec.cs │ └── Validations │ │ └── EmployeeIsValidValidation.cs ├── Properties │ └── AssemblyInfo.cs └── app.config ├── EMS.Infra.CrossCutting.Automapper ├── AutoMapperRegistry.cs ├── EMS.Infra.CrossCutting.Automapper.csproj ├── HRMappingProfile.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── EMS.Infra.CrossCutting.Config ├── EMS.Infra.CrossCutting.Config.csproj └── Properties │ └── AssemblyInfo.cs ├── EMS.Infra.CrossCutting.Ioc ├── DependencyResolution │ ├── DefaultRegistry.cs │ ├── IoC.cs │ ├── StructureMapDependencyScope.cs │ ├── StructureMapWebApiDependencyResolver.cs │ └── StructureMapWebApiDependencyScope.cs ├── EMS.Infra.CrossCutting.Ioc.csproj ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── EMS.Infra.Data.Test ├── EMS.Infra.Data.Test.csproj ├── Properties │ └── AssemblyInfo.cs ├── UnitOfWorkFixture.cs └── packages.config ├── EMS.Infra.Data ├── EMS.Infra.Data.csproj ├── Mapping │ └── EmployeeMap.cs ├── NH │ ├── NHSessionFactorySingleton.cs │ └── UnitOfWork.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── EMS.Infra.Repository ├── EMS.Infra.Repository.csproj ├── Hrm │ └── EmployeeRepository.cs ├── NH │ └── BaseRepository.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── EMS.Services.Tests ├── EMS.Services.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── UnitTest1.cs └── app.config ├── EMS.Services ├── App_Start │ ├── FilterConfig.cs │ └── WebApiConfig.cs ├── Controllers │ ├── Common │ │ └── BaseApiController.cs │ └── Hrm │ │ ├── EmployeeController.cs │ │ └── Interfaces │ │ └── IEmployeeApiController.cs ├── Core │ ├── ActionFilters │ │ ├── AntiForgeryTokenFilterProvider .cs │ │ ├── CompressResponseAttribute.cs │ │ └── ValidationActionFilter.cs │ ├── Config │ │ └── GlobalConfig.cs │ └── Cors │ │ └── CorsHandler.cs ├── EMS.Services.csproj ├── Global.asax ├── Global.asax.cs ├── Properties │ └── AssemblyInfo.cs ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── hibernate.cfg.xml └── packages.config ├── EMS.UI ├── EMS.UI.csproj ├── Properties │ └── AssemblyInfo.cs ├── Web.Debug.config ├── Web.Release.config └── Web.config ├── Education Management System.sln └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Build results 28 | 29 | [Dd]ebug/ 30 | [Rr]elease/ 31 | x64/ 32 | build/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | 36 | # NuGet Packages 37 | *.nupkg 38 | # The packages folder can be ignored because of Package Restore 39 | **/packages/* 40 | # except build/, which is used as an MSBuild target. 41 | !**/packages/build/ 42 | # Uncomment if necessary however generally it will be regenerated when needed 43 | #!**/packages/repositories.config 44 | 45 | 46 | # Visual Studio 2015 cache/options directory 47 | .vs/ 48 | # Uncomment if you have tasks that create the project's static files in wwwroot 49 | #wwwroot/ 50 | 51 | # MSTest test Results 52 | [Tt]est[Rr]esult*/ 53 | [Bb]uild[Ll]og.* 54 | 55 | # NUNIT 56 | *.VisualState.xml 57 | TestResult.xml 58 | 59 | # Build Results of an ATL Project 60 | [Dd]ebugPS/ 61 | [Rr]eleasePS/ 62 | dlldata.c 63 | 64 | # .NET Core 65 | project.lock.json 66 | project.fragment.lock.json 67 | artifacts/ 68 | **/Properties/launchSettings.json 69 | 70 | *_i.c 71 | *_p.c 72 | *_i.h 73 | *.ilk 74 | *.meta 75 | *.obj 76 | *.pch 77 | *.pdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *.log 88 | *.vspscc 89 | *.vssscc 90 | .builds 91 | *.pidb 92 | *.svclog 93 | *.scc 94 | 95 | # Chutzpah Test files 96 | _Chutzpah* 97 | 98 | # Visual C++ cache files 99 | ipch/ 100 | *.aps 101 | *.ncb 102 | *.opendb 103 | *.opensdf 104 | *.sdf 105 | *.cachefile 106 | *.VC.db 107 | *.VC.VC.opendb 108 | 109 | # Visual Studio profiler 110 | *.psess 111 | *.vsp 112 | *.vspx 113 | *.sap 114 | 115 | # TFS 2012 Local Workspace 116 | $tf/ 117 | 118 | # Guidance Automation Toolkit 119 | *.gpState 120 | 121 | # ReSharper is a .NET coding add-in 122 | _ReSharper*/ 123 | *.[Rr]e[Ss]harper 124 | *.DotSettings.user 125 | 126 | # JustCode is a .NET coding add-in 127 | .JustCode 128 | 129 | # TeamCity is a build add-in 130 | _TeamCity* 131 | 132 | # DotCover is a Code Coverage Tool 133 | *.dotCover 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # TODO: Comment the next line if you want to checkin your web deploy settings 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/packages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/packages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/packages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | 206 | # Visual Studio cache files 207 | # files ending in .cache can be ignored 208 | *.[Cc]ache 209 | # but keep track of directories ending in .cache 210 | !*.[Cc]ache/ 211 | 212 | # Others 213 | ClientBin/ 214 | ~$* 215 | *~ 216 | *.dbmdl 217 | *.dbproj.schemaview 218 | *.jfm 219 | *.pfx 220 | *.publishsettings 221 | orleans.codegen.cs 222 | 223 | # Since there are multiple workflows, uncomment next line to ignore bower_components 224 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 225 | #bower_components/ 226 | 227 | # RIA/Silverlight projects 228 | Generated_Code/ 229 | 230 | # Backup & report files from converting an old project file 231 | # to a newer Visual Studio version. Backup files are not needed, 232 | # because we have git ;-) 233 | _UpgradeReport_Files/ 234 | Backup*/ 235 | UpgradeLog*.XML 236 | UpgradeLog*.htm 237 | 238 | # SQL Server files 239 | *.mdf 240 | *.ldf 241 | *.ndf 242 | 243 | # Business Intelligence projects 244 | *.rdl.data 245 | *.bim.layout 246 | *.bim_*.settings 247 | 248 | # Microsoft Fakes 249 | FakesAssemblies/ 250 | 251 | # GhostDoc plugin setting file 252 | *.GhostDoc.xml 253 | 254 | # Node.js Tools for Visual Studio 255 | .ntvs_analysis.dat 256 | node_modules/ 257 | 258 | # Typescript v1 declaration files 259 | typings/ 260 | 261 | # Visual Studio 6 build log 262 | *.plg 263 | 264 | # Visual Studio 6 workspace options file 265 | *.opt 266 | 267 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 268 | *.vbw 269 | 270 | # Visual Studio LightSwitch build output 271 | **/*.HTMLClient/GeneratedArtifacts 272 | **/*.DesktopClient/GeneratedArtifacts 273 | **/*.DesktopClient/ModelManifest.xml 274 | **/*.Server/GeneratedArtifacts 275 | **/*.Server/ModelManifest.xml 276 | _Pvt_Extensions 277 | 278 | # Paket dependency manager 279 | .paket/paket.exe 280 | paket-files/ 281 | 282 | # FAKE - F# Make 283 | .fake/ 284 | 285 | # JetBrains Rider 286 | .idea/ 287 | *.sln.iml 288 | 289 | # CodeRush 290 | .cr/ 291 | 292 | # Python Tools for Visual Studio (PTVS) 293 | __pycache__/ 294 | *.pyc 295 | 296 | # Cake - Uncomment if you are using it 297 | # tools/** 298 | # !tools/packages.config 299 | 300 | # Telerik's JustMock configuration file 301 | *.jmconfig 302 | 303 | # BizTalk build output 304 | *.btp.cs 305 | *.btm.cs 306 | *.odx.cs 307 | *.xsd.cs -------------------------------------------------------------------------------- /EMS.Application/Common/AppService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Application; 2 | using EMS.Core.Domain.Entities; 3 | using EMS.Core.Domain.Validation; 4 | using EMS.Core.Infra.Data; 5 | 6 | namespace EMS.Application.Common 7 | { 8 | public class AppService : ITransactionAppService, IAggregateRoot 9 | { 10 | //private IUnitOfWork _uow; 11 | 12 | protected ValidationResult ValidationResult { get; private set; } 13 | 14 | public AppService() 15 | { 16 | ValidationResult = new ValidationResult(); 17 | //_uow = uow; 18 | } 19 | 20 | public void BeginTransaction() 21 | { 22 | //_uow = ServiceLocator.Current.GetInstance(); 23 | //_uow.BeginTransaction(); 24 | } 25 | 26 | public void Commit() 27 | { 28 | //_uow.Commit(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /EMS.Application/EMS.Application.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {40F1CD73-4668-4229-A13C-06476F276A26} 8 | Library 9 | Properties 10 | EMS.Application 11 | EMS.Application 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 55 | EMS.Core 56 | 57 | 58 | {b08951e0-93af-4918-9db3-7def78056c4b} 59 | EMS.Domain.Services 60 | 61 | 62 | {5b727fc1-09b7-48f0-93e2-5d592e4df071} 63 | EMS.Domain 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /EMS.Application/Hrm/Implementations/EmployeeAppService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Application.Common; 2 | using EMS.Application.Hrm.Interfaces; 3 | using System; 4 | using System.Collections.Generic; 5 | using EMS.Core.Domain.Specification; 6 | using EMS.Core.Domain.Validation; 7 | using EMS.Domain.Hrm.Entities; 8 | using EMS.Domain.Services.Hrm.Interfaces; 9 | using EMS.Domain.Hrm.Dto; 10 | using AutoMapper; 11 | 12 | namespace EMS.Application.Hrm.Implementations 13 | { 14 | public class EmployeeAppService : AppService, IEmployeeAppService 15 | { 16 | private readonly IEmployeeService _employeeService; 17 | private readonly IMapper _mapper; 18 | 19 | #region Constructor 20 | 21 | public EmployeeAppService(IEmployeeService employeeService, IMapper mapper) 22 | { 23 | if (employeeService == null) 24 | throw new ArgumentNullException("employeeService"); 25 | 26 | if (mapper == null) 27 | throw new ArgumentNullException("mapper"); 28 | 29 | _employeeService = employeeService; 30 | _mapper = mapper; 31 | } 32 | 33 | #endregion 34 | 35 | #region Read Methods 36 | 37 | public EmployeeDto GetById(object id, bool @readonly) 38 | { 39 | Employee employee = _employeeService.GetById(id); 40 | var employeeDtos = _mapper.Map(employee); 41 | return employeeDtos; 42 | } 43 | 44 | //public EmployeeDto FindBy(ISpecification spec, bool @readonly = false) 45 | //{ 46 | // throw new NotImplementedException(); 47 | // //return _employeeService.FindBy(spec, @readonly); 48 | //} 49 | 50 | //public IEnumerable FilterBy(ISpecification spec, bool @readonly = false) 51 | //{ 52 | // throw new NotImplementedException(); 53 | // //return _employeeService.FilterBy(spec, @readonly); 54 | //} 55 | 56 | //public IEnumerable GetAll(bool @readonly = false) 57 | //{ 58 | // throw new NotImplementedException(); 59 | // //return _employeeService.GetAll(@readonly); 60 | //} 61 | 62 | //public EmployeeDto GetById(object id, bool @readonly = false) 63 | //{ 64 | // throw new NotImplementedException(); 65 | // //return _employeeService.GetById(id, @readonly); 66 | //} 67 | 68 | #endregion 69 | 70 | #region Operations 71 | 72 | public ValidationResult Create(EmployeeDto entity) 73 | { 74 | //BeginTransaction(); 75 | //ValidationResult.Add(_service.Add(employee)); 76 | if (ValidationResult.IsValid) 77 | { 78 | //Commit(); 79 | } 80 | 81 | return ValidationResult; 82 | } 83 | 84 | public ValidationResult Create(IEnumerable entities) 85 | { 86 | throw new NotImplementedException(); 87 | } 88 | 89 | public ValidationResult Update(EmployeeDto entity) 90 | { 91 | throw new NotImplementedException(); 92 | } 93 | 94 | public ValidationResult Update(IEnumerable entities) 95 | { 96 | throw new NotImplementedException(); 97 | } 98 | 99 | public ValidationResult Remove(EmployeeDto employeeDto) 100 | { 101 | throw new NotImplementedException(); 102 | } 103 | 104 | public ValidationResult Remove(IEnumerable entities) 105 | { 106 | throw new NotImplementedException(); 107 | } 108 | 109 | #endregion 110 | 111 | #region Dispose 112 | 113 | public void Dispose() 114 | { 115 | Dispose(true); 116 | } 117 | 118 | ~EmployeeAppService() 119 | { 120 | Dispose(false); 121 | } 122 | 123 | protected virtual void Dispose(bool disposing) 124 | { 125 | if (disposing) 126 | { 127 | GC.SuppressFinalize(this); 128 | } 129 | } 130 | 131 | public Employee FindBy(ISpecification spec, bool @readonly = false) 132 | { 133 | throw new NotImplementedException(); 134 | } 135 | 136 | public IEnumerable FilterBy(ISpecification spec, bool @readonly = false) 137 | { 138 | throw new NotImplementedException(); 139 | } 140 | 141 | //IEnumerable IAppService.GetAll(bool @readonly) 142 | //{ 143 | // throw new NotImplementedException(); 144 | //} 145 | 146 | public ValidationResult Create(Employee entity) 147 | { 148 | throw new NotImplementedException(); 149 | } 150 | 151 | public ValidationResult Create(IEnumerable entities) 152 | { 153 | throw new NotImplementedException(); 154 | } 155 | 156 | public ValidationResult Update(Employee entity) 157 | { 158 | throw new NotImplementedException(); 159 | } 160 | 161 | public ValidationResult Update(IEnumerable entities) 162 | { 163 | throw new NotImplementedException(); 164 | } 165 | 166 | public ValidationResult Remove(object id) 167 | { 168 | throw new NotImplementedException(); 169 | } 170 | 171 | public ValidationResult Remove(IEnumerable entities) 172 | { 173 | throw new NotImplementedException(); 174 | } 175 | 176 | public EmployeeDto FindBy(ISpecification spec, bool @readonly = false) 177 | { 178 | throw new NotImplementedException(); 179 | } 180 | 181 | public IEnumerable FilterBy(ISpecification spec, bool @readonly = false) 182 | { 183 | throw new NotImplementedException(); 184 | } 185 | 186 | public IEnumerable GetAll(bool @readonly = false) 187 | { 188 | throw new NotImplementedException(); 189 | } 190 | 191 | #endregion 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /EMS.Application/Hrm/Interfaces/IEmployeeAppService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Application.Common; 2 | using EMS.Core.Application; 3 | using EMS.Domain.Hrm.Dto; 4 | using EMS.Domain.Hrm.Entities; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace EMS.Application.Hrm.Interfaces 12 | { 13 | public interface IEmployeeAppService : IAppService 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /EMS.Application/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Application")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("40f1cd73-4668-4229-a13c-06476f276a26")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Application/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Application/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /EMS.Core/Application/IAppService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using EMS.Core.Domain.Specification; 4 | 5 | namespace EMS.Core.Application 6 | { 7 | public interface IAppService : IWriteOnlyAppService, IDisposable where TEntity : class, new() 8 | { 9 | TEntity FindBy(ISpecification spec, bool @readonly = false); 10 | 11 | IEnumerable FilterBy(ISpecification spec, bool @readonly = false); 12 | 13 | IEnumerable GetAll(bool @readonly = false); 14 | 15 | TEntity GetById(object id, bool @readonly = false); 16 | } 17 | } -------------------------------------------------------------------------------- /EMS.Core/Application/IReadOnlyAppService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using EMS.Core.Domain.Specification; 3 | 4 | namespace EMS.Core.Application 5 | { 6 | public interface IReadOnlyAppService where TEntity : class, new() 7 | { 8 | TEntity FindBy(ISpecification spec); 9 | 10 | IEnumerable FilterBy(ISpecification spec); 11 | 12 | IEnumerable GetAll(); 13 | 14 | TEntity GetById(object id); 15 | } 16 | } -------------------------------------------------------------------------------- /EMS.Core/Application/ITransactionAppService.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Application 2 | { 3 | public interface ITransactionAppService 4 | { 5 | void BeginTransaction(); 6 | void Commit(); 7 | } 8 | } -------------------------------------------------------------------------------- /EMS.Core/Application/IWriteOnlyAppService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using EMS.Core.Domain.Validation; 3 | 4 | namespace EMS.Core.Application 5 | { 6 | public interface IWriteOnlyAppService where TEntity : class, new() 7 | { 8 | ValidationResult Create(TEntity entity); 9 | 10 | ValidationResult Create(IEnumerable entities); 11 | 12 | ValidationResult Update(TEntity entity); 13 | 14 | ValidationResult Update(IEnumerable entities); 15 | 16 | ValidationResult Remove(object id); 17 | 18 | ValidationResult Remove(IEnumerable entities); 19 | } 20 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Entities/BaseDto.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | 3 | namespace EMS.Core.Domain.Entities 4 | { 5 | public abstract class BaseDto 6 | { 7 | public TKey Id { get; set; } 8 | public byte LocationId { get; set; } 9 | public EntityState EntityState { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Entities/BaseValueObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace EMS.Core.Domain.Entities 5 | { 6 | /// 7 | /// Value Object base (Handles Equality) 8 | /// 9 | /// 10 | public class ValueObjectBase : IEquatable 11 | where TValueObject : ValueObjectBase 12 | { 13 | /// 14 | /// Indicates whether the current object 15 | /// is equal to another object of the same type. 16 | /// 17 | /// 18 | /// true if the current object is equal 19 | /// to the parameter; otherwise, false. 20 | /// 21 | /// An object to compare with this object. 22 | public bool Equals(TValueObject other) 23 | { 24 | if (other == null) 25 | return false; 26 | 27 | // Compare all public properties 28 | var publicProperties = GetType().GetProperties(); 29 | 30 | if (publicProperties != null && publicProperties.Any()) 31 | return publicProperties 32 | .All(item => item.GetValue(this, null) 33 | .Equals(item.GetValue(other, null))); 34 | 35 | return true; 36 | } 37 | 38 | /// 39 | /// Equality 40 | /// 41 | public override bool Equals(object obj) 42 | { 43 | // If both are null, or both are same instance, return true 44 | if (ReferenceEquals(obj, this)) 45 | return true; 46 | 47 | if (obj == null) 48 | return false; 49 | 50 | var item = obj as ValueObjectBase; 51 | 52 | if (item == null) 53 | return false; 54 | 55 | return Equals((TValueObject) item); 56 | } 57 | 58 | /// 59 | /// Get hash code 60 | /// 61 | public override int GetHashCode() 62 | { 63 | var hashCode = 31; 64 | var changeMultiplier = false; 65 | const int index = 1; 66 | 67 | // Compare all public properties 68 | var publicProperties = GetType().GetProperties(); 69 | 70 | if (publicProperties != null && publicProperties.Any()) 71 | { 72 | foreach (var value in publicProperties 73 | .Select(item => item.GetValue(this, null))) 74 | { 75 | if (value != null) 76 | { 77 | hashCode = hashCode*((changeMultiplier) ? 59 : 114) 78 | + value.GetHashCode(); 79 | changeMultiplier = !changeMultiplier; 80 | } 81 | else 82 | hashCode = hashCode ^ (index*13); // Support order 83 | } 84 | } 85 | 86 | return hashCode; 87 | } 88 | 89 | /// 90 | /// Equal operator 91 | /// 92 | public static bool operator ==(ValueObjectBase x, ValueObjectBase y) 93 | { 94 | return Equals(x, y); 95 | } 96 | 97 | /// 98 | /// Not equal operator 99 | /// 100 | public static bool operator !=(ValueObjectBase x, ValueObjectBase y) 101 | { 102 | return !(x == y); 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Entities/IAggregateRoot.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Entities 2 | { 3 | public interface IAggregateRoot 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Entities 2 | { 3 | public interface IEntity 4 | { 5 | TKey Id { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Event/DomainEvents.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Event 2 | { 3 | /// 4 | /// http://www.udidahan.com/2009/06/14/domain-events-salvation/ 5 | /// 6 | public static class DomainEvents 7 | { 8 | //[ThreadStatic] //so that each thread has its own callbacks 9 | //private static List actions; 10 | 11 | //private static IWindsorContainer Container { get; set; } 12 | 13 | ////Registers a callback for the given domain event, used for testing only 14 | //public static void Register(Action callback) where T : IDomainEvent 15 | //{ 16 | // if (actions == null) 17 | // actions = new List(); 18 | 19 | // actions.Add(callback); 20 | //} 21 | 22 | ////Clears callbacks passed to Register on the current thread 23 | //public static void ClearCallbacks() 24 | //{ 25 | // actions = null; 26 | //} 27 | 28 | ////Raises the given domain event 29 | //public static void Raise(T args) where T : IDomainEvent 30 | //{ 31 | // if (Container != null) 32 | // foreach (var handler in Container.ResolveAll>()) 33 | // handler.Handle(args); 34 | 35 | // if (actions != null) 36 | // foreach (var action in actions) 37 | // if (action is Action) 38 | // ((Action)action)(args); 39 | //} 40 | } 41 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Event/Handle.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using System.Threading.Tasks; 6 | 7 | //namespace EMS.Core.Domain.Event 8 | //{ 9 | // public interface Handles where T : IDomainEvent 10 | // { 11 | // void Handle(T args); 12 | // } 13 | //} 14 | 15 | -------------------------------------------------------------------------------- /EMS.Core/Domain/Event/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using System.Threading.Tasks; 6 | 7 | //namespace EMS.Core.Domain.Event 8 | //{ 9 | // public interface IDomainEvent 10 | // { 11 | // } 12 | //} 13 | 14 | -------------------------------------------------------------------------------- /EMS.Core/Domain/Repository/IReadOnlyRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using EMS.Core.Domain.Entities; 4 | using EMS.Core.Domain.Specification; 5 | 6 | namespace EMS.Core.Domain.Repository 7 | { 8 | public interface IReadOnlyRepository : IDisposable where TEntity : IAggregateRoot, new() 9 | { 10 | TEntity FindBy(ISpecification spec); 11 | 12 | IQueryable FilterBy(ISpecification spec); 13 | 14 | IQueryable GetAll(); 15 | 16 | TEntity GetById(object id); 17 | } 18 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Repository/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using EMS.Core.Domain.Entities; 3 | using EMS.Core.Domain.Specification; 4 | 5 | namespace EMS.Core.Domain.Repository 6 | { 7 | public interface IRepository : IWriteOnlyRepository where TEntity : IAggregateRoot, new() 8 | { 9 | TEntity FindBy(ISpecification spec, bool @readonly = false); 10 | 11 | IQueryable FilterBy(ISpecification spec, bool @readonly = false); 12 | 13 | IQueryable GetAll(bool @readonly = false); 14 | 15 | TEntity GetById(object id, bool @readonly = false); 16 | } 17 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Repository/IWriteOnlyRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using EMS.Core.Domain.Entities; 4 | 5 | namespace EMS.Core.Domain.Repository 6 | { 7 | /// 8 | /// Repository main interface 9 | /// 10 | /// entity type of the repository 11 | /// id of the entity 12 | public interface IWriteOnlyRepository : IDisposable where TEntity : IAggregateRoot, new() 13 | { 14 | /// 15 | /// Add an item to repository 16 | /// 17 | /// item to add 18 | void Add(TEntity entity); 19 | 20 | /// 21 | /// Add an multiple item to repository 22 | /// 23 | /// item to add 24 | void Add(IEnumerable entities); 25 | 26 | /// 27 | /// Update entity into the repository 28 | /// 29 | /// Item with changes 30 | void Update(TEntity entity); 31 | 32 | /// 33 | /// Update multiple entity into the repository 34 | /// 35 | /// Item with changes 36 | void Update(IEnumerable entities); 37 | 38 | /// 39 | /// Delete item 40 | /// 41 | /// Item to delete 42 | void Delete(TEntity entity); 43 | 44 | /// 45 | /// Delete multiple item 46 | /// 47 | /// Item to delete 48 | void Delete(IEnumerable entities); 49 | } 50 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Service/IReadOnlyService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using EMS.Core.Domain.Entities; 4 | using EMS.Core.Domain.Specification; 5 | 6 | namespace EMS.Core.Domain.Service 7 | { 8 | public interface IReadOnlyService : IDisposable where TEntity : IAggregateRoot, new() 9 | { 10 | TEntity FindBy(ISpecification spec); 11 | 12 | IQueryable FilterBy(ISpecification spec); 13 | 14 | IQueryable GetAll(); 15 | 16 | TEntity GetById(object id); 17 | } 18 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Service/IService.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using EMS.Core.Domain.Entities; 3 | using EMS.Core.Domain.Specification; 4 | 5 | namespace EMS.Core.Domain.Service 6 | { 7 | public interface IService : IWriteOnlyService where TEntity : IAggregateRoot, new() 8 | { 9 | TEntity FindBy(ISpecification spec, bool @readonly = false); 10 | 11 | IQueryable FilterBy(ISpecification spec, bool @readonly = false); 12 | 13 | IQueryable GetAll(bool @readonly = false); 14 | 15 | TEntity GetById(object id, bool @readonly = false); 16 | } 17 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Service/IWriteOnlyService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using EMS.Core.Domain.Entities; 4 | using EMS.Core.Domain.Validation; 5 | 6 | namespace EMS.Core.Domain.Service 7 | { 8 | public interface IWriteOnlyService : IDisposable where TEntity : IAggregateRoot, new() 9 | { 10 | ValidationResult Add(TEntity entity); 11 | 12 | ValidationResult Add(IEnumerable entities); 13 | 14 | ValidationResult Update(TEntity entity); 15 | 16 | ValidationResult Update(IEnumerable entities); 17 | 18 | ValidationResult Remove(TEntity entity); 19 | 20 | ValidationResult Remove(IEnumerable entities); 21 | } 22 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/And.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace EMS.Core.Domain.Specification 5 | { 6 | public class And : SpecificationBase 7 | { 8 | private ISpecification left; 9 | private ISpecification right; 10 | 11 | public And( 12 | ISpecification left, 13 | ISpecification right) 14 | { 15 | this.left = left; 16 | this.right = right; 17 | } 18 | 19 | // AndSpecification 20 | public override Expression> SpecExpression 21 | { 22 | get 23 | { 24 | var objParam = Expression.Parameter(typeof (T), "obj"); 25 | 26 | var newExpr = Expression.Lambda>( 27 | Expression.AndAlso( 28 | Expression.Invoke(left.SpecExpression, objParam), 29 | Expression.Invoke(right.SpecExpression, objParam) 30 | ), 31 | objParam 32 | ); 33 | 34 | return newExpr; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/IExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Specification 2 | { 3 | public static class IExtensions 4 | { 5 | public static ISpecification And( 6 | this ISpecification left, 7 | ISpecification right) 8 | { 9 | return new And(left, right); 10 | } 11 | 12 | public static ISpecification Or( 13 | this ISpecification left, 14 | ISpecification right) 15 | { 16 | return new Or(left, right); 17 | } 18 | 19 | public static ISpecification Negate(this ISpecification inner) 20 | { 21 | return new Negated(inner); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/ISpecification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace EMS.Core.Domain.Specification 5 | { 6 | public interface ISpecification 7 | { 8 | Expression> SpecExpression { get; } 9 | bool IsSatisfiedBy(T obj); 10 | } 11 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/Negate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace EMS.Core.Domain.Specification 5 | { 6 | public class Negated : SpecificationBase 7 | { 8 | private readonly ISpecification _inner; 9 | 10 | public Negated(ISpecification inner) 11 | { 12 | _inner = inner; 13 | } 14 | 15 | // NegatedSpecification 16 | public override Expression> SpecExpression 17 | { 18 | get 19 | { 20 | var objParam = Expression.Parameter(typeof (T), "obj"); 21 | 22 | var newExpr = Expression.Lambda>( 23 | Expression.Not( 24 | Expression.Invoke(_inner.SpecExpression, objParam) 25 | ), 26 | objParam 27 | ); 28 | 29 | return newExpr; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/Or.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace EMS.Core.Domain.Specification 5 | { 6 | public class Or : SpecificationBase 7 | { 8 | private ISpecification left; 9 | private ISpecification right; 10 | 11 | public Or( 12 | ISpecification left, 13 | ISpecification right) 14 | { 15 | this.left = left; 16 | this.right = right; 17 | } 18 | 19 | // OrSpecification 20 | public override Expression> SpecExpression 21 | { 22 | get 23 | { 24 | var objParam = Expression.Parameter(typeof (T), "obj"); 25 | 26 | var newExpr = Expression.Lambda>( 27 | Expression.OrElse( 28 | Expression.Invoke(left.SpecExpression, objParam), 29 | Expression.Invoke(right.SpecExpression, objParam) 30 | ), 31 | objParam 32 | ); 33 | 34 | return newExpr; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Specification/SpecificationBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace EMS.Core.Domain.Specification 5 | { 6 | public abstract class SpecificationBase : ISpecification 7 | { 8 | private Func _compiledExpression; 9 | 10 | private Func CompiledExpression 11 | { 12 | get { return _compiledExpression ?? (_compiledExpression = SpecExpression.Compile()); } 13 | } 14 | 15 | public virtual Expression> SpecExpression { get; } 16 | 17 | public virtual bool IsSatisfiedBy(T obj) 18 | { 19 | return CompiledExpression(obj); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/ISelfValidation.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Validation 2 | { 3 | public interface ISelfValidation 4 | { 5 | //ValidationResult ValidationResult { get; } 6 | bool IsValid { get; } 7 | } 8 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/IValidation.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Validation 2 | { 3 | public interface IValidation 4 | { 5 | ValidationResult Valid(TEntity entity); 6 | } 7 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/IValidationRule.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Validation 2 | { 3 | public interface IValidationRule 4 | { 5 | string ErrorMessage { get; } 6 | bool Valid(TEntity entity); 7 | } 8 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/Validation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace EMS.Core.Domain.Validation 5 | { 6 | public class Validation : IValidation 7 | where TEntity : class 8 | { 9 | private readonly Dictionary> _validationsRules; 10 | 11 | public Validation() 12 | { 13 | _validationsRules = new Dictionary>(); 14 | } 15 | 16 | protected virtual void AddRule(IValidationRule validationRule) 17 | { 18 | var ruleName = validationRule.GetType() + Guid.NewGuid().ToString("D"); 19 | _validationsRules.Add(ruleName, validationRule); 20 | } 21 | 22 | protected virtual void RemoveRule(string ruleName) 23 | { 24 | _validationsRules.Remove(ruleName); 25 | } 26 | 27 | public virtual ValidationResult Valid(TEntity entity) 28 | { 29 | var result = new ValidationResult(); 30 | foreach (var key in _validationsRules.Keys) 31 | { 32 | var rule = _validationsRules[key]; 33 | if (!rule.Valid(entity)) 34 | result.Add(new ValidationError(rule.ErrorMessage)); 35 | } 36 | return result; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/ValidationError.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Domain.Validation 2 | { 3 | public class ValidationError 4 | { 5 | public string Message { get; set; } 6 | 7 | public ValidationError(string message) 8 | { 9 | Message = message; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/ValidationResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace EMS.Core.Domain.Validation 5 | { 6 | public class ValidationResult 7 | { 8 | private readonly List _erros; 9 | private string Message { get; set; } 10 | 11 | public bool IsValid 12 | { 13 | get { return !_erros.Any(); } 14 | } 15 | 16 | public IEnumerable Errors 17 | { 18 | get { return _erros; } 19 | } 20 | 21 | public ValidationResult() 22 | { 23 | _erros = new List(); 24 | } 25 | 26 | public ValidationResult Add(string errorMessage) 27 | { 28 | _erros.Add(new ValidationError(errorMessage)); 29 | return this; 30 | } 31 | 32 | public ValidationResult Add(ValidationError error) 33 | { 34 | _erros.Add(error); 35 | return this; 36 | } 37 | 38 | public ValidationResult Add(params ValidationResult[] validationResults) 39 | { 40 | if (validationResults == null) return this; 41 | 42 | foreach (var result in validationResults.Where(r => r != null)) 43 | _erros.AddRange(result.Errors); 44 | 45 | return this; 46 | } 47 | 48 | public ValidationResult Remove(ValidationError error) 49 | { 50 | if (_erros.Contains(error)) 51 | _erros.Remove(error); 52 | return this; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /EMS.Core/Domain/Validation/ValidationRule.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Specification; 2 | 3 | namespace EMS.Core.Domain.Validation 4 | { 5 | public class ValidationRule : IValidationRule 6 | { 7 | private readonly ISpecification _specificationRule; 8 | 9 | public ValidationRule(ISpecification specificationRule, string errorMessage) 10 | { 11 | _specificationRule = specificationRule; 12 | ErrorMessage = errorMessage; 13 | } 14 | 15 | public string ErrorMessage { get; } 16 | 17 | public bool Valid(TEntity entity) 18 | { 19 | return _specificationRule.IsSatisfiedBy(entity); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /EMS.Core/EMS.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B0A5A4CF-BA80-40A4-9058-C248381612B7} 8 | Library 9 | Properties 10 | EMS.Core 11 | EMS.Core 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll 35 | True 36 | 37 | 38 | ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | -------------------------------------------------------------------------------- /EMS.Core/ErpSetup/VersionInfo.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.ErpSetup 2 | { 3 | // Shared Product Version Header 4 | // Automatically Generated: Sat, 2 May 2015 15:09:09 EDT 5 | // ReSharper disable CheckNamespace 6 | // ReSharper disable InconsistentNaming 7 | public struct VersionInfo 8 | { 9 | public const string Company = @"Track Founder Ltd"; 10 | public const string Copyright = @"Copyright (c) 2016 Track Founder Ltd. All rights reserved."; 11 | public const string ProductName = @"Education Mangement System"; 12 | public const string SpecialBuild = @""; 13 | public const string ProductConfiguration = @""; 14 | public const string ProductCode = @"MSS"; 15 | public const string ProductUrl = @"www.trackfounder.com"; 16 | public const string ProductEmail = @"support@trackfounder.com"; 17 | public const string ProductVendor = @"Track Founder Ltd"; 18 | 19 | public struct product 20 | { 21 | public const string FileVersion = @"1.0.0.000"; 22 | } 23 | 24 | public struct sdk 25 | { 26 | public const string FileVersion = @"1.0.0.000"; 27 | } 28 | 29 | public struct service 30 | { 31 | public const string FileVersion = @"1.0.0.000"; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /EMS.Core/Helpers/EntityState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EMS.Core.Helpers 4 | { 5 | // Summary: 6 | // Gets the state of a object. 7 | [Flags] 8 | public enum EntityState 9 | { 10 | // Summary: 11 | // The row has been created but is not part of any ItemCollection. 12 | // A System.Data.DataRow is in this state immediately after it has been created 13 | // and before it is added to a collection, or if it has been removed from a 14 | // collection. 15 | Detached = 1, 16 | // 17 | // Summary: 18 | // The row has not changed since Item.AcceptChanges() was last 19 | // called. 20 | Unchanged = 2, 21 | // 22 | // Summary: 23 | // The row has been added to a ItemCollection, and Item.AcceptChanges() 24 | // has not been called. 25 | Added = 3, 26 | // 27 | // Summary: 28 | // The row was deleted using the Item.Delete() method of the 29 | // Item. 30 | Deleted = 4, 31 | // 32 | // Summary: 33 | // The row has been modified and Item.AcceptChanges() has not 34 | // been called. 35 | Modified = 5 36 | } 37 | } -------------------------------------------------------------------------------- /EMS.Core/Helpers/EnumDatabase.cs: -------------------------------------------------------------------------------- 1 | namespace EMS.Core.Helpers 2 | { 3 | public enum DBMS 4 | { 5 | PostgreSQL, 6 | SQLite, 7 | SQLServer2014, 8 | Oracle11 9 | } 10 | } -------------------------------------------------------------------------------- /EMS.Core/Helpers/EnumHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Reflection; 6 | 7 | namespace EMS.Core.Helpers 8 | { 9 | public static class EnumHelper 10 | { 11 | public static string Description(this Enum value) 12 | { 13 | FieldInfo fi = value.GetType().GetField(value.ToString()); 14 | 15 | DescriptionAttribute[] attributes = 16 | (DescriptionAttribute[]) fi.GetCustomAttributes(typeof (DescriptionAttribute), false); 17 | 18 | if (attributes != null && 19 | attributes.Length > 0) 20 | return attributes[0].Description; 21 | return value.ToString(); 22 | } 23 | 24 | public static List GetEnumList(this Type enumType) 25 | { 26 | List enumTypeList = new List(); 27 | 28 | foreach (var item in Enum.GetValues(enumType)) 29 | { 30 | string description = enumType.GetField(Enum.GetName(enumType, item)) 31 | .GetCustomAttributes(typeof (DescriptionAttribute), false) 32 | .OfType() 33 | .FirstOrDefault().Description; 34 | 35 | var result = new {Id = item, Name = description}; 36 | enumTypeList.Add(result); 37 | } 38 | return enumTypeList; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /EMS.Core/Helpers/EnumSchema.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EMS.Core.Helpers 8 | { 9 | public enum EnumSchema 10 | { 11 | ADM, 12 | SET, 13 | HRM 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /EMS.Core/Helpers/JSONHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Script.Serialization; 3 | 4 | namespace EMS.Core.Helpers 5 | { 6 | public static class JSONHelper 7 | { 8 | #region Public extension methods. 9 | 10 | /// 11 | /// Extened method of object class 12 | /// Converts an object to a json string. 13 | /// 14 | /// 15 | /// 16 | public static string ToJSON(this object obj) 17 | { 18 | var serializer = new JavaScriptSerializer(); 19 | try 20 | { 21 | return serializer.Serialize(obj); 22 | } 23 | catch (Exception) 24 | { 25 | return ""; 26 | } 27 | } 28 | 29 | #endregion 30 | } 31 | } -------------------------------------------------------------------------------- /EMS.Core/Helpers/ServiceStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Newtonsoft.Json; 4 | 5 | namespace EMS.Core.Helpers 6 | { 7 | 8 | #region Status Object Class 9 | 10 | /// 11 | /// Public class to return input status 12 | /// 13 | [Serializable] 14 | [DataContract] 15 | public class ServiceStatus 16 | { 17 | #region Public properties. 18 | 19 | /// 20 | /// Get/Set property for accessing Status Code 21 | /// 22 | [JsonProperty("StatusCode")] 23 | [DataMember] 24 | public int StatusCode { get; set; } 25 | 26 | /// 27 | /// Get/Set property for accessing Status Message 28 | /// 29 | [JsonProperty("StatusMessage")] 30 | [DataMember] 31 | public string StatusMessage { get; set; } 32 | 33 | /// 34 | /// Get/Set property for accessing Status Message 35 | /// 36 | [JsonProperty("ReasonPhrase")] 37 | [DataMember] 38 | public string ReasonPhrase { get; set; } 39 | 40 | #endregion 41 | } 42 | 43 | #endregion 44 | } -------------------------------------------------------------------------------- /EMS.Core/Infra/Data/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data; 3 | using NHibernate; 4 | 5 | namespace EMS.Core.Infra.Data 6 | { 7 | /// 8 | /// Represents a transactional job. 9 | /// 10 | public interface IUnitOfWork : IDisposable 11 | { 12 | /// 13 | /// Current Session Container 14 | /// 15 | ISession CurrentSession { get; } 16 | 17 | /// 18 | /// Opens database connection and begins transaction. 19 | /// 20 | void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted); 21 | 22 | /// 23 | /// Commits transaction and closes database connection. 24 | /// 25 | void Commit(); 26 | 27 | /// 28 | /// Rollbacks transaction and closes database connection. 29 | /// 30 | void Rollback(); 31 | } 32 | } -------------------------------------------------------------------------------- /EMS.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using EMS.Core.ErpSetup; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | 9 | [assembly: AssemblyTitle("EMS.Core")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany(VersionInfo.Company)] 13 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 14 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | 26 | [assembly: Guid("b0a5a4cf-ba80-40a4-9058-c248381612b7")] 27 | 28 | // Version information for an assembly consists of the following four values: 29 | // 30 | // Major Version 31 | // Minor Version 32 | // Build Number 33 | // Revision 34 | // 35 | // You can specify all the values or you can default the Build and Revision Numbers 36 | // by using the '*' as shown below: 37 | // [assembly: AssemblyVersion("1.0.*")] 38 | 39 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 40 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] -------------------------------------------------------------------------------- /EMS.Core/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Common/ReadOnlyService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Core.Domain.Repository; 3 | using EMS.Core.Domain.Service; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using EMS.Core.Domain.Specification; 10 | 11 | namespace EMS.Domain.Services.Common 12 | { 13 | public class ReadOnlyService : IReadOnlyService where TEntity : IAggregateRoot, new() 14 | { 15 | #region Constructor 16 | 17 | private readonly IReadOnlyRepository _readOnlyRepository; 18 | 19 | public ReadOnlyService(IReadOnlyRepository readOnlyRepository) 20 | { 21 | if (readOnlyRepository == null) 22 | throw new ArgumentNullException("readOnlyRepository"); 23 | 24 | _readOnlyRepository = readOnlyRepository; 25 | } 26 | 27 | #endregion 28 | 29 | #region Properties 30 | 31 | protected IReadOnlyRepository ReadOnlyRepository 32 | { 33 | get { return _readOnlyRepository; } 34 | } 35 | 36 | #endregion 37 | 38 | #region Implementations 39 | 40 | public virtual TEntity FindBy(ISpecification spec) 41 | { 42 | return _readOnlyRepository.FindBy(spec); 43 | } 44 | 45 | public virtual IQueryable FilterBy(ISpecification spec) 46 | { 47 | return _readOnlyRepository.FilterBy(spec); 48 | } 49 | 50 | public virtual IQueryable GetAll() 51 | { 52 | return _readOnlyRepository.GetAll(); 53 | } 54 | 55 | public virtual TEntity GetById(object id) 56 | { 57 | return _readOnlyRepository.GetById(id); 58 | } 59 | 60 | #endregion 61 | 62 | #region Dispose 63 | 64 | public void Dispose() 65 | { 66 | Dispose(true); 67 | } 68 | 69 | ~ReadOnlyService() 70 | { 71 | Dispose(false); 72 | } 73 | 74 | protected virtual void Dispose(bool disposing) 75 | { 76 | if (disposing) 77 | { 78 | _readOnlyRepository.Dispose(); 79 | GC.SuppressFinalize(this); 80 | } 81 | } 82 | 83 | #endregion 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Common/Service.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Core.Domain.Repository; 3 | using EMS.Core.Domain.Service; 4 | using EMS.Core.Domain.Validation; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using EMS.Core.Domain.Specification; 11 | 12 | namespace EMS.Domain.Services.Common 13 | { 14 | public class Service : IService where TEntity : IAggregateRoot, new() 15 | { 16 | #region Constructor 17 | 18 | private readonly IRepository _repository; 19 | private readonly ValidationResult _validationResult; 20 | 21 | public Service(IRepository repository) 22 | { 23 | if (repository == null) 24 | throw new ArgumentNullException("repository"); 25 | 26 | _repository = repository; 27 | _validationResult = new ValidationResult(); 28 | } 29 | 30 | #endregion 31 | 32 | #region Properties 33 | 34 | protected IRepository Repository 35 | { 36 | get { return _repository; } 37 | } 38 | 39 | protected ValidationResult ValidationResult 40 | { 41 | get { return _validationResult; } 42 | } 43 | 44 | #endregion 45 | 46 | #region Read Methods 47 | 48 | public virtual TEntity FindBy(ISpecification spec, bool @readonly = false) 49 | { 50 | return _repository.FindBy(spec, @readonly); 51 | } 52 | 53 | public virtual IQueryable FilterBy(ISpecification spec, bool @readonly = false) 54 | { 55 | return _repository.FilterBy(spec, @readonly); 56 | } 57 | 58 | public virtual IQueryable GetAll(bool @readonly = false) 59 | { 60 | return _repository.GetAll(@readonly); 61 | } 62 | 63 | public virtual TEntity GetById(object id, bool @readonly = false) 64 | { 65 | return _repository.GetById(id, @readonly); 66 | } 67 | 68 | #endregion 69 | 70 | #region CRUD Methods 71 | 72 | public virtual ValidationResult Add(TEntity entity) 73 | { 74 | if (!ValidationResult.IsValid) 75 | return ValidationResult; 76 | 77 | var selfValidationEntity = entity as ISelfValidation; 78 | //if (selfValidationEntity != null && !selfValidationEntity.IsValid) 79 | // return selfValidationEntity.ValidationResult; 80 | 81 | 82 | _repository.Add(entity); 83 | return _validationResult; 84 | } 85 | 86 | public virtual ValidationResult Add(IEnumerable entities) 87 | { 88 | throw new NotImplementedException(); 89 | } 90 | 91 | public virtual ValidationResult Update(TEntity entity) 92 | { 93 | if (!ValidationResult.IsValid) 94 | return ValidationResult; 95 | 96 | var selfValidationEntity = entity as ISelfValidation; 97 | //if (selfValidationEntity != null && !selfValidationEntity.IsValid) 98 | // return selfValidationEntity.ValidationResult; 99 | 100 | _repository.Update(entity); 101 | return _validationResult; 102 | } 103 | 104 | public virtual ValidationResult Update(IEnumerable entities) 105 | { 106 | throw new NotImplementedException(); 107 | } 108 | 109 | public virtual ValidationResult Remove(TEntity entity) 110 | { 111 | if (!ValidationResult.IsValid) 112 | return ValidationResult; 113 | 114 | _repository.Delete(entity); 115 | return _validationResult; 116 | } 117 | 118 | public virtual ValidationResult Remove(IEnumerable entities) 119 | { 120 | throw new NotImplementedException(); 121 | } 122 | 123 | #endregion 124 | 125 | #region Dispose 126 | 127 | public void Dispose() 128 | { 129 | Dispose(true); 130 | } 131 | 132 | ~Service() 133 | { 134 | Dispose(false); 135 | } 136 | 137 | protected virtual void Dispose(bool disposing) 138 | { 139 | if (disposing) 140 | { 141 | _repository.Dispose(); 142 | GC.SuppressFinalize(this); 143 | } 144 | } 145 | 146 | #endregion 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Common/WriteOnlyService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Core.Domain.Repository; 3 | using EMS.Core.Domain.Service; 4 | using System; 5 | using System.Collections.Generic; 6 | using EMS.Core.Domain.Validation; 7 | 8 | namespace EMS.Domain.Services.Common 9 | { 10 | public class WriteOnlyService : IWriteOnlyService where TEntity : IAggregateRoot, new() 11 | { 12 | #region Constructor 13 | 14 | private readonly IWriteOnlyRepository _writeOnlyRepository; 15 | private readonly ValidationResult _validationResult; 16 | 17 | public WriteOnlyService(IWriteOnlyRepository writeOnlyRepository) 18 | { 19 | if (writeOnlyRepository == null) 20 | throw new ArgumentNullException("writeOnlyRepository"); 21 | 22 | _writeOnlyRepository = writeOnlyRepository; 23 | _validationResult = new ValidationResult(); 24 | } 25 | 26 | #endregion 27 | 28 | #region Properties 29 | 30 | protected IWriteOnlyRepository WriteOnlyRepository 31 | { 32 | get { return _writeOnlyRepository; } 33 | } 34 | 35 | protected ValidationResult ValidationResult 36 | { 37 | get { return _validationResult; } 38 | } 39 | 40 | #endregion 41 | 42 | #region Implementations 43 | 44 | public virtual ValidationResult Add(TEntity entity) 45 | { 46 | if (!ValidationResult.IsValid) 47 | return ValidationResult; 48 | 49 | var selfValidationEntity = entity as ISelfValidation; 50 | //if (selfValidationEntity != null && !selfValidationEntity.IsValid) 51 | // return selfValidationEntity.ValidationResult; 52 | 53 | 54 | _writeOnlyRepository.Add(entity); 55 | return _validationResult; 56 | } 57 | 58 | public virtual ValidationResult Add(IEnumerable entities) 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | public virtual ValidationResult Update(TEntity entity) 64 | { 65 | if (!ValidationResult.IsValid) 66 | return ValidationResult; 67 | 68 | var selfValidationEntity = entity as ISelfValidation; 69 | //if (selfValidationEntity != null && !selfValidationEntity.IsValid) 70 | // return selfValidationEntity.ValidationResult; 71 | 72 | _writeOnlyRepository.Update(entity); 73 | return _validationResult; 74 | } 75 | 76 | public virtual ValidationResult Update(IEnumerable entities) 77 | { 78 | throw new NotImplementedException(); 79 | } 80 | 81 | public virtual ValidationResult Remove(TEntity entity) 82 | { 83 | if (!ValidationResult.IsValid) 84 | return ValidationResult; 85 | 86 | _writeOnlyRepository.Delete(entity); 87 | return _validationResult; 88 | } 89 | 90 | public virtual ValidationResult Remove(IEnumerable entities) 91 | { 92 | throw new NotImplementedException(); 93 | } 94 | 95 | #endregion 96 | 97 | #region Dispose 98 | 99 | public void Dispose() 100 | { 101 | Dispose(true); 102 | } 103 | 104 | ~WriteOnlyService() 105 | { 106 | Dispose(false); 107 | } 108 | 109 | protected virtual void Dispose(bool disposing) 110 | { 111 | if (disposing) 112 | { 113 | _writeOnlyRepository.Dispose(); 114 | GC.SuppressFinalize(this); 115 | } 116 | } 117 | 118 | #endregion 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /EMS.Domain.Services/EMS.Domain.Services.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B08951E0-93AF-4918-9DB3-7DEF78056C4B} 8 | Library 9 | Properties 10 | EMS.Domain.Services 11 | EMS.Domain.Services 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 53 | EMS.Core 54 | 55 | 56 | {5b727fc1-09b7-48f0-93e2-5d592e4df071} 57 | EMS.Domain 58 | 59 | 60 | 61 | 62 | 63 | 64 | 71 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Hrm/Implementations/EmployeeService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Domain.Hrm.Entities; 2 | using EMS.Domain.Hrm.Repository; 3 | using EMS.Domain.Services.Common; 4 | using EMS.Domain.Services.Hrm.Interfaces; 5 | using System; 6 | 7 | namespace EMS.Domain.Services.Hrm.Implementations 8 | { 9 | public class EmployeeService : Service, IEmployeeService 10 | { 11 | private readonly IEmployeeRepository _employeeRepository; 12 | 13 | #region Constructor 14 | 15 | public EmployeeService(IEmployeeRepository repository) : base(repository) 16 | { 17 | if (repository == null) 18 | throw new ArgumentNullException("repository"); 19 | 20 | _employeeRepository = repository; 21 | } 22 | 23 | #endregion 24 | 25 | #region Read Methods 26 | 27 | #endregion 28 | 29 | #region Write Methods 30 | 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Hrm/Interfaces/IEmployeeService.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain; 2 | using EMS.Core.Domain.Service; 3 | using EMS.Domain.Hrm.Entities; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace EMS.Domain.Services.Hrm.Interfaces 11 | { 12 | public interface IEmployeeService : IService 13 | { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /EMS.Domain.Services/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Domain.Services")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("b08951e0-93af-4918-9db3-7def78056c4b")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Domain.Services/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Domain/EMS.Domain.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5B727FC1-09B7-48F0-93E2-5D592E4DF071} 8 | Library 9 | Properties 10 | EMS.Domain 11 | EMS.Domain 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | True 50 | True 51 | ValidationMessages.resx 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 65 | EMS.Core 66 | 67 | 68 | 69 | 70 | ResXFileCodeGenerator 71 | ValidationMessages.Designer.cs 72 | 73 | 74 | 75 | 76 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Dtos/EmployeeDto.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Domain.Hrm.Resorces; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace EMS.Domain.Hrm.Dto 11 | { 12 | [Serializable()] 13 | public class EmployeeDto : BaseDto 14 | { 15 | public int SalutationId { get; set; } 16 | 17 | [Required(ErrorMessageResourceName = "FirstNameIsRequired", ErrorMessageResourceType = typeof(ValidationMessages))] 18 | public string FirstName { get; set; } 19 | 20 | public string MiddleName { get; set; } 21 | 22 | [Required(ErrorMessageResourceName = "LastNameIsRequired", ErrorMessageResourceType = typeof(ValidationMessages))] 23 | public string LastName { get; set; } 24 | 25 | public string NickName { get; set; } 26 | 27 | public string EmpName { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Entities/Employee.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Core.Domain.Validation; 3 | using EMS.Domain.Hrm.Validations; 4 | using System; 5 | using System.ComponentModel; 6 | 7 | namespace EMS.Domain.Hrm.Entities 8 | { 9 | [Serializable()] 10 | public class Employee : BaseEntity, ISelfValidation 11 | { 12 | #region Tables Memebers 13 | 14 | /// SQL Type:int - 15 | private int _SalutationId; 16 | 17 | [DisplayName("Salutation Id")] 18 | [Category("Column")] 19 | public virtual int SalutationId 20 | { 21 | get 22 | { 23 | try 24 | { 25 | return _SalutationId; 26 | } 27 | catch (System.Exception err) 28 | { 29 | throw new Exception("Error getting SalutationId", err); 30 | } 31 | } 32 | set 33 | { 34 | try 35 | { 36 | _SalutationId = value; 37 | } 38 | catch (System.Exception err) 39 | { 40 | throw new Exception("Error setting SalutationId", err); 41 | } 42 | } 43 | } 44 | 45 | /// SQL Type:nvarchar - 46 | private string _FirstName; 47 | 48 | [DisplayName("First Name")] 49 | [Category("Column")] 50 | public virtual string FirstName 51 | { 52 | get 53 | { 54 | try 55 | { 56 | return _FirstName; 57 | } 58 | catch (System.Exception err) 59 | { 60 | throw new Exception("Error getting FirstName", err); 61 | } 62 | } 63 | set 64 | { 65 | try 66 | { 67 | if ((value.Length <= 100)) 68 | { 69 | _FirstName = value; 70 | } 71 | else 72 | { 73 | throw new OverflowException("Error setting FirstName, Length of value is to long. Maximum Length: 100"); 74 | } 75 | } 76 | catch (System.Exception err) 77 | { 78 | throw new Exception("Error setting FirstName", err); 79 | } 80 | } 81 | } 82 | 83 | /// SQL Type:nvarchar - 84 | private string _MiddleName; 85 | 86 | [DisplayName("Middle Name")] 87 | [Category("Column")] 88 | public virtual string MiddleName 89 | { 90 | get 91 | { 92 | try 93 | { 94 | return _MiddleName; 95 | } 96 | catch (System.Exception err) 97 | { 98 | throw new Exception("Error getting MiddleName", err); 99 | } 100 | } 101 | set 102 | { 103 | try 104 | { 105 | if ((value.Length <= 100)) 106 | { 107 | _MiddleName = value; 108 | } 109 | else 110 | { 111 | throw new OverflowException("Error setting MiddleName, Length of value is to long. Maximum Length: 100"); 112 | } 113 | } 114 | catch (System.Exception err) 115 | { 116 | throw new Exception("Error setting MiddleName", err); 117 | } 118 | } 119 | } 120 | 121 | /// SQL Type:nvarchar - 122 | private string _LastName; 123 | 124 | [DisplayName("Last Name")] 125 | [Category("Column")] 126 | public virtual string LastName 127 | { 128 | get 129 | { 130 | try 131 | { 132 | return _LastName; 133 | } 134 | catch (System.Exception err) 135 | { 136 | throw new Exception("Error getting LastName", err); 137 | } 138 | } 139 | set 140 | { 141 | try 142 | { 143 | if ((value.Length <= 100)) 144 | { 145 | _LastName = value; 146 | } 147 | else 148 | { 149 | throw new OverflowException("Error setting LastName, Length of value is to long. Maximum Length: 100"); 150 | } 151 | } 152 | catch (System.Exception err) 153 | { 154 | throw new Exception("Error setting LastName", err); 155 | } 156 | } 157 | } 158 | 159 | /// SQL Type:nvarchar - 160 | private string _NickName; 161 | 162 | [DisplayName("Nick Name")] 163 | [Category("Column")] 164 | public virtual string NickName 165 | { 166 | get 167 | { 168 | try 169 | { 170 | return _NickName; 171 | } 172 | catch (System.Exception err) 173 | { 174 | throw new Exception("Error getting NickName", err); 175 | } 176 | } 177 | set 178 | { 179 | try 180 | { 181 | if ((value.Length <= 100)) 182 | { 183 | _NickName = value; 184 | } 185 | else 186 | { 187 | throw new OverflowException("Error setting NickName, Length of value is to long. Maximum Length: 100"); 188 | } 189 | } 190 | catch (System.Exception err) 191 | { 192 | throw new Exception("Error setting NickName", err); 193 | } 194 | } 195 | } 196 | 197 | /// SQL Type:nvarchar - 198 | private string _EmpName; 199 | 200 | [DisplayName("Emp Name")] 201 | [Category("Column")] 202 | public virtual string EmpName 203 | { 204 | get 205 | { 206 | try 207 | { 208 | return _EmpName; 209 | } 210 | catch (System.Exception err) 211 | { 212 | throw new Exception("Error getting EmpName", err); 213 | } 214 | } 215 | set 216 | { 217 | try 218 | { 219 | if ((value.Length <= 300)) 220 | { 221 | _EmpName = value; 222 | } 223 | else 224 | { 225 | throw new OverflowException("Error setting EmpName, Length of value is to long. Maximum Length: 300"); 226 | } 227 | } 228 | catch (System.Exception err) 229 | { 230 | throw new Exception("Error setting EmpName", err); 231 | } 232 | } 233 | } 234 | 235 | #endregion 236 | 237 | #region Public Methods 238 | 239 | #endregion 240 | 241 | #region Private Methods 242 | 243 | #endregion 244 | 245 | #region Self Validation 246 | 247 | public virtual bool IsValid 248 | { 249 | get 250 | { 251 | var fiscal = new EmployeeIsValidValidation(); 252 | ValidationResult = fiscal.Valid(this); 253 | return ValidationResult.IsValid; 254 | } 255 | } 256 | 257 | #endregion 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Repository/IEmployeeRepository.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain; 2 | using EMS.Core.Domain.Repository; 3 | using EMS.Domain.Hrm.Entities; 4 | 5 | namespace EMS.Domain.Hrm.Repository 6 | { 7 | public interface IEmployeeRepository : IRepository 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Repository/ReadOnly/IEmployeeReadOnlyRepository.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Repository; 2 | using EMS.Domain.Hrm.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace EMS.Domain.Hrm.Repository.ReadOnly 10 | { 11 | public interface IEmployeeReadOnlyRepository : IReadOnlyRepository 12 | { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Resorces/ValidationMessages.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EMS.Domain.Hrm.Resorces { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class ValidationMessages { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal ValidationMessages() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EMS.Domain.Hrm.Resorces.ValidationMessages", typeof(ValidationMessages).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to First name is required. 65 | /// 66 | internal static string FirstNameIsRequired { 67 | get { 68 | return ResourceManager.GetString("FirstNameIsRequired", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to First name too long. 74 | /// 75 | internal static string FirstNameTooLong { 76 | get { 77 | return ResourceManager.GetString("FirstNameTooLong", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Last name is required. 83 | /// 84 | internal static string LastNameIsRequired { 85 | get { 86 | return ResourceManager.GetString("LastNameIsRequired", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to Last name too long. 92 | /// 93 | internal static string LastNameTooLong { 94 | get { 95 | return ResourceManager.GetString("LastNameTooLong", resourceCulture); 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Resorces/ValidationMessages.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | First name is required 122 | Hrm 123 | 124 | 125 | First name too long 126 | 127 | 128 | Last name is required 129 | 130 | 131 | Last name too long 132 | 133 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Specifications/EmployeeSpecs/EmployeeFirstNameIsRequiredSpec.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Specification; 2 | using EMS.Domain.Hrm.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Linq.Expressions; 9 | 10 | namespace EMS.Domain.Hrm.Specifications.EmployeeSpecs 11 | { 12 | public class EmployeeFirstNameIsRequiredSpec : SpecificationBase 13 | { 14 | public override bool IsSatisfiedBy(Employee obj) 15 | { 16 | return obj.FirstName.Trim().Length > 0; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /EMS.Domain/Hrm/Validations/EmployeeIsValidValidation.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Validation; 2 | using EMS.Domain.Hrm.Entities; 3 | using EMS.Domain.Hrm.Resorces; 4 | using EMS.Domain.Hrm.Specifications.EmployeeSpecs; 5 | 6 | namespace EMS.Domain.Hrm.Validations 7 | { 8 | public class EmployeeIsValidValidation : Validation 9 | { 10 | public EmployeeIsValidValidation() 11 | { 12 | base.AddRule(new ValidationRule(new EmployeeFirstNameIsRequiredSpec(), ValidationMessages.FirstNameIsRequired)); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /EMS.Domain/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Domain")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct("EMS.Domain")] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("5b727fc1-09b7-48f0-93e2-5d592e4df071")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Domain/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Automapper/AutoMapperRegistry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EMS.Infra.CrossCutting.Automapper 8 | { 9 | public class AutoMapperRegistry 10 | { 11 | public AutoMapperRegistry() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Automapper/EMS.Infra.CrossCutting.Automapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E1B39912-036A-469A-944C-1A03AB4AFF15} 8 | Library 9 | Properties 10 | EMS.Infra.CrossCutting.Automapper 11 | EMS.Infra.CrossCutting.Automapper 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 57 | EMS.Core 58 | 59 | 60 | {5b727fc1-09b7-48f0-93e2-5d592e4df071} 61 | EMS.Domain 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Automapper/HRMappingProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using EMS.Domain.Hrm.Dto; 3 | using EMS.Domain.Hrm.Entities; 4 | 5 | namespace EMS.Infra.CrossCutting.Automapper 6 | { 7 | public class HRMappingProfile : Profile 8 | { 9 | public override string ProfileName 10 | { 11 | get { return "HRMappingProfileMappings"; } 12 | } 13 | 14 | public HRMappingProfile() 15 | { 16 | CreateMap().ReverseMap(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Automapper/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Infra.CrossCutting.Automapper")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("e1b39912-036a-469a-944c-1a03ab4aff15")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Automapper/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Config/EMS.Infra.CrossCutting.Config.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AAD8D576-9ED3-4646-AAD6-5CD73492F82F} 8 | Library 9 | Properties 10 | EMS.Infra.CrossCutting.Config 11 | EMS.Infra.CrossCutting.Config 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 48 | EMS.Core 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Config/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Infra.CrossCutting.Config")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("aad8d576-9ed3-4646-aad6-5cd73492f82f")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/DependencyResolution/DefaultRegistry.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2012 Web Advanced (www.webadvanced.com) 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // -------------------------------------------------------------------------------------------------------------------- 17 | 18 | namespace EMS.Infra.CrossCutting.Ioc.DependencyResolution 19 | { 20 | using Automapper; 21 | using AutoMapper; 22 | using StructureMap.Configuration.DSL; 23 | using StructureMap.Graph; 24 | using System; 25 | using System.Linq; 26 | public class DefaultRegistry : Registry 27 | { 28 | #region Constructors and Destructors 29 | 30 | public DefaultRegistry() 31 | { 32 | Scan( 33 | scan => 34 | { 35 | scan.TheCallingAssembly(); 36 | scan.WithDefaultConventions(); 37 | scan.Assembly("EMS.Core"); 38 | scan.Assembly("EMS.Infra.Data"); 39 | scan.Assembly("EMS.Infra.Repository"); 40 | scan.Assembly("EMS.Domain"); 41 | scan.Assembly("EMS.Domain.Services"); 42 | scan.Assembly("EMS.Application"); 43 | }); 44 | //For().Use(); 45 | 46 | #region Auto Mapper configurations 47 | 48 | var profiles = from t in typeof(AutoMapperRegistry).Assembly.GetTypes() 49 | where typeof(Profile).IsAssignableFrom(t) 50 | select (Profile)Activator.CreateInstance(t); 51 | 52 | var config = new MapperConfiguration(cfg => 53 | { 54 | foreach (var profile in profiles) 55 | { 56 | cfg.AddProfile(profile); 57 | } 58 | }); 59 | 60 | var mapper = config.CreateMapper(); 61 | For().Use(config); 62 | For().Use(mapper); 63 | 64 | #endregion 65 | } 66 | 67 | #endregion 68 | } 69 | } -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/DependencyResolution/IoC.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2012 Web Advanced (www.webadvanced.com) 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // -------------------------------------------------------------------------------------------------------------------- 17 | 18 | 19 | namespace EMS.Infra.CrossCutting.Ioc.DependencyResolution { 20 | using StructureMap; 21 | 22 | public static class IoC { 23 | public static IContainer Initialize() { 24 | return new Container(c => c.AddRegistry()); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/DependencyResolution/StructureMapDependencyScope.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2012 Web Advanced (www.webadvanced.com) 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // -------------------------------------------------------------------------------------------------------------------- 17 | 18 | namespace EMS.Infra.CrossCutting.Ioc.DependencyResolution { 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | using System.Web; 23 | 24 | using Microsoft.Practices.ServiceLocation; 25 | 26 | using StructureMap; 27 | 28 | /// 29 | /// The structure map dependency scope. 30 | /// 31 | public class StructureMapDependencyScope : ServiceLocatorImplBase { 32 | #region Constants and Fields 33 | 34 | private const string NestedContainerKey = "Nested.Container.Key"; 35 | 36 | #endregion 37 | 38 | #region Constructors and Destructors 39 | 40 | public StructureMapDependencyScope(IContainer container) { 41 | if (container == null) { 42 | throw new ArgumentNullException("container"); 43 | } 44 | Container = container; 45 | } 46 | 47 | #endregion 48 | 49 | #region Public Properties 50 | 51 | public IContainer Container { get; set; } 52 | 53 | public IContainer CurrentNestedContainer { 54 | get { 55 | return (IContainer)HttpContext.Items[NestedContainerKey]; 56 | } 57 | set { 58 | HttpContext.Items[NestedContainerKey] = value; 59 | } 60 | } 61 | 62 | #endregion 63 | 64 | #region Properties 65 | 66 | private HttpContextBase HttpContext { 67 | get { 68 | var ctx = Container.TryGetInstance(); 69 | return ctx ?? new HttpContextWrapper(System.Web.HttpContext.Current); 70 | } 71 | } 72 | 73 | #endregion 74 | 75 | #region Public Methods and Operators 76 | 77 | public void CreateNestedContainer() { 78 | if (CurrentNestedContainer != null) { 79 | return; 80 | } 81 | CurrentNestedContainer = Container.GetNestedContainer(); 82 | } 83 | 84 | public void Dispose() { 85 | if (CurrentNestedContainer != null) { 86 | CurrentNestedContainer.Dispose(); 87 | } 88 | 89 | Container.Dispose(); 90 | } 91 | 92 | public void DisposeNestedContainer() { 93 | if (CurrentNestedContainer != null) { 94 | CurrentNestedContainer.Dispose(); 95 | } 96 | } 97 | 98 | public IEnumerable GetServices(Type serviceType) { 99 | return DoGetAllInstances(serviceType); 100 | } 101 | 102 | #endregion 103 | 104 | #region Methods 105 | 106 | protected override IEnumerable DoGetAllInstances(Type serviceType) { 107 | return (CurrentNestedContainer ?? Container).GetAllInstances(serviceType).Cast(); 108 | } 109 | 110 | protected override object DoGetInstance(Type serviceType, string key) { 111 | IContainer container = (CurrentNestedContainer ?? Container); 112 | 113 | if (string.IsNullOrEmpty(key)) { 114 | return serviceType.IsAbstract || serviceType.IsInterface 115 | ? container.TryGetInstance(serviceType) 116 | : container.GetInstance(serviceType); 117 | } 118 | 119 | return container.GetInstance(serviceType, key); 120 | } 121 | 122 | #endregion 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/DependencyResolution/StructureMapWebApiDependencyResolver.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2012 Web Advanced (www.webadvanced.com) 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // -------------------------------------------------------------------------------------------------------------------- 17 | 18 | using System.Web.Http.Dependencies; 19 | using StructureMap; 20 | 21 | namespace EMS.Infra.CrossCutting.Ioc.DependencyResolution 22 | { 23 | /// 24 | /// The structure map dependency resolver. 25 | /// 26 | public class StructureMapWebApiDependencyResolver : StructureMapWebApiDependencyScope, IDependencyResolver 27 | { 28 | #region Constructors and Destructors 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// 34 | /// The container. 35 | /// 36 | public StructureMapWebApiDependencyResolver(IContainer container) 37 | : base(container) 38 | { 39 | } 40 | 41 | #endregion 42 | 43 | #region Public Methods and Operators 44 | 45 | /// 46 | /// The begin scope. 47 | /// 48 | /// 49 | /// The System.Web.Http.Dependencies.IDependencyScope. 50 | /// 51 | public IDependencyScope BeginScope() 52 | { 53 | IContainer child = this.Container.GetNestedContainer(); 54 | return new StructureMapWebApiDependencyResolver(child); 55 | } 56 | 57 | #endregion 58 | } 59 | } -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/DependencyResolution/StructureMapWebApiDependencyScope.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright 2012 Web Advanced (www.webadvanced.com) 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // -------------------------------------------------------------------------------------------------------------------- 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Linq; 21 | using System.Web.Http.Dependencies; 22 | using Microsoft.Practices.ServiceLocation; 23 | using StructureMap; 24 | 25 | namespace EMS.Infra.CrossCutting.Ioc.DependencyResolution 26 | { 27 | /// 28 | /// The structure map web api dependency scope. 29 | /// 30 | public class StructureMapWebApiDependencyScope : StructureMapDependencyScope, IDependencyScope 31 | { 32 | public StructureMapWebApiDependencyScope(IContainer container) 33 | : base(container) { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/EMS.Infra.CrossCutting.Ioc.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2684ECAA-8187-4CBD-ADB8-555E22849F16} 8 | Library 9 | Properties 10 | EMS.Infra.CrossCutting.Ioc 11 | EMS.Infra.CrossCutting.Ioc 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll 35 | True 36 | 37 | 38 | ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll 39 | True 40 | 41 | 42 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 43 | True 44 | 45 | 46 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 47 | True 48 | 49 | 50 | ..\packages\structuremap.3.0.0.108\lib\net40\StructureMap.dll 51 | True 52 | 53 | 54 | ..\packages\structuremap.3.0.0.108\lib\net40\StructureMap.Net4.dll 55 | True 56 | 57 | 58 | ..\packages\structuremap.web.3.0.0.108\lib\net40\StructureMap.Web.dll 59 | True 60 | 61 | 62 | 63 | 64 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll 65 | True 66 | 67 | 68 | 69 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll 70 | True 71 | 72 | 73 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll 74 | True 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | ..\packages\WebActivatorEx.2.0.5\lib\net40\WebActivatorEx.dll 84 | True 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 101 | EMS.Core 102 | 103 | 104 | {e1b39912-036a-469a-944c-1a03ab4aff15} 105 | EMS.Infra.CrossCutting.Automapper 106 | 107 | 108 | 109 | 116 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Infra.CrossCutting.Ioc")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("2684ecaa-8187-4cbd-adb8-555e22849f16")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Infra.CrossCutting.Ioc/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /EMS.Infra.Data.Test/EMS.Infra.Data.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2FBB0183-6CF4-4F19-A3B0-C18E15393716} 8 | Library 9 | Properties 10 | EMS.Infra.Data.Test 11 | EMS.Infra.Data.Test 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 64 | -------------------------------------------------------------------------------- /EMS.Infra.Data.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EMS.Infra.Data.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("EMS.Infra.Data.Test")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2fbb0183-6cf4-4f19-a3b0-c18e15393716")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /EMS.Infra.Data.Test/UnitOfWorkFixture.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EMS.Infra.Data.Test 9 | { 10 | [TestFixture] 11 | public class UnitOfWorkFixture 12 | { 13 | [Test] 14 | public void TestMethod() 15 | { 16 | // TODO: Add your test code here 17 | Assert.Pass("Your first passing test"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /EMS.Infra.Data.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /EMS.Infra.Data/EMS.Infra.Data.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {16590E97-DB51-4A24-AA87-5187AB62AB7E} 8 | Library 9 | Properties 10 | EMS.Infra.Data 11 | EMS.Infra.Data 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll 35 | True 36 | 37 | 38 | ..\packages\Iesi.Collections.4.0.1.4000\lib\net40\Iesi.Collections.dll 39 | True 40 | 41 | 42 | ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll 43 | True 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 68 | EMS.Core 69 | 70 | 71 | {5b727fc1-09b7-48f0-93e2-5d592e4df071} 72 | EMS.Domain 73 | 74 | 75 | 76 | 77 | 84 | -------------------------------------------------------------------------------- /EMS.Infra.Data/Mapping/EmployeeMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using EMS.Core.Helpers; 3 | using EMS.Domain.Hrm.Entities; 4 | using FluentNHibernate.Mapping; 5 | 6 | namespace EMS.Infra.Data.Mapping 7 | { 8 | public class EmployeeMap : ClassMap 9 | { 10 | public EmployeeMap() 11 | { 12 | Schema(EnumSchema.HRM.Description()); 13 | Table(typeof(Employee).Name); 14 | Id(x => x.Id).GeneratedBy.Identity(); 15 | Map(x => x.LocationId); 16 | Map(x => x.SalutationId); 17 | Map(x => x.FirstName); 18 | Map(x => x.MiddleName); 19 | Map(x => x.LastName); 20 | Map(x => x.NickName); 21 | Map(x => x.EmpName); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /EMS.Infra.Data/NH/NHSessionFactorySingleton.cs: -------------------------------------------------------------------------------- 1 | using EMS.Infra.Data.Mapping; 2 | using FluentNHibernate.Cfg; 3 | using FluentNHibernate.Cfg.Db; 4 | using NHibernate; 5 | using NHibernate.Tool.hbm2ddl; 6 | using System.Reflection; 7 | 8 | namespace EMS.Infra.Data.NH 9 | { 10 | public static class NHSessionFactorySingleton 11 | { 12 | private static ISessionFactory sessionFactory = null; 13 | private static object lockObj = new object(); 14 | 15 | public static ISessionFactory SessionFactory 16 | { 17 | get 18 | { 19 | lock (lockObj) 20 | { 21 | if (sessionFactory == null) 22 | { 23 | sessionFactory = Fluently.Configure() 24 | .Database(MsSqlConfiguration.MsSql2012.ConnectionString(c => c.FromConnectionStringWithKey("EMS")).ShowSql()) 25 | .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetAssembly(typeof(EmployeeMap)))) 26 | .BuildSessionFactory(); 27 | } 28 | } 29 | return sessionFactory; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /EMS.Infra.Data/NH/UnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Infra.Data; 2 | using NHibernate; 3 | using System; 4 | using System.Data; 5 | 6 | namespace EMS.Infra.Data.NH 7 | { 8 | /// 9 | /// Implements Unit of work for NHibernate. 10 | /// 11 | public class UnitOfWork : IUnitOfWork 12 | { 13 | /// 14 | /// Gets Nhibernate session object to perform queries. 15 | /// 16 | private ISession _session; 17 | 18 | public ISession CurrentSession { get { return _session; } } 19 | 20 | /// 21 | /// Reference to the currently running transcation. 22 | /// 23 | private ITransaction _transaction; 24 | 25 | ///// 26 | ///// Creates a new instance of NhUnitOfWork. 27 | ///// 28 | ///// 29 | public UnitOfWork() 30 | { 31 | OpenSession(); 32 | } 33 | 34 | /// 35 | /// OpenSession if not connected 36 | /// 37 | public void OpenSession() 38 | { 39 | if (_session == null || !_session.IsConnected) 40 | { 41 | if (_session != null) 42 | _session.Dispose(); 43 | _session = NHSessionFactorySingleton.SessionFactory.OpenSession(); 44 | //_session.FlushMode = FlushMode.Auto; 45 | //_session.CacheMode = CacheMode.Normal; 46 | } 47 | } 48 | 49 | /// 50 | /// Opens database connection and begins transaction. 51 | /// 52 | public void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted) 53 | { 54 | if (_transaction == null || !_transaction.IsActive) 55 | { 56 | if (_transaction != null) 57 | _transaction.Dispose(); 58 | 59 | _transaction = _session.BeginTransaction(isolationLevel); 60 | } 61 | } 62 | 63 | /// 64 | /// Commits transaction and closes database connection. 65 | /// 66 | public void Commit() 67 | { 68 | try 69 | { 70 | // commit transaction if there is one active 71 | if (_transaction != null && _transaction.IsActive) 72 | _transaction.Commit(); 73 | } 74 | catch 75 | { 76 | // rollback if there was an exception 77 | if (_transaction != null && _transaction.IsActive) 78 | _transaction.Rollback(); 79 | throw; 80 | } 81 | finally 82 | { 83 | Dispose(); 84 | } 85 | } 86 | 87 | /// 88 | /// Rollbacks transaction and closes database connection. 89 | /// 90 | public void Rollback() 91 | { 92 | try 93 | { 94 | if (_transaction != null && _transaction.IsActive) 95 | _transaction.Rollback(); 96 | } 97 | finally 98 | { 99 | Dispose(); 100 | } 101 | } 102 | 103 | #region Dispose 104 | 105 | public void Dispose() 106 | { 107 | if (_transaction != null) 108 | { 109 | _transaction.Dispose(); 110 | _transaction = null; 111 | } 112 | 113 | if (_session != null) 114 | { 115 | _session.Flush(); 116 | _session.Close(); 117 | _session.Dispose(); 118 | _session = null; 119 | } 120 | GC.SuppressFinalize(this); 121 | } 122 | 123 | #endregion 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /EMS.Infra.Data/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Infra.Data")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("16590e97-db51-4a24-aa87-5187ab62ab7e")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Infra.Data/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Infra.Data/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/EMS.Infra.Repository.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {01F213A3-92EA-49A8-9DF5-EF789C4CA217} 8 | Library 9 | Properties 10 | EMS.Infra.Repository 11 | EMS.Infra.Repository 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll 35 | True 36 | 37 | 38 | ..\packages\Iesi.Collections.4.0.1.4000\lib\net40\Iesi.Collections.dll 39 | True 40 | 41 | 42 | ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll 43 | True 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {b0a5a4cf-ba80-40a4-9058-c248381612b7} 63 | EMS.Core 64 | 65 | 66 | {5b727fc1-09b7-48f0-93e2-5d592e4df071} 67 | EMS.Domain 68 | 69 | 70 | {16590e97-db51-4a24-aa87-5187ab62ab7e} 71 | EMS.Infra.Data 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 86 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/Hrm/EmployeeRepository.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Repository; 2 | using EMS.Core.Infra.Data; 3 | using EMS.Domain.Hrm.Entities; 4 | using EMS.Domain.Hrm.Repository; 5 | using EMS.Infra.Repository.NH; 6 | 7 | namespace EMS.Infra.Repository.Hrm 8 | { 9 | public class EmployeeRepository : BaseRepository, IEmployeeRepository 10 | { 11 | public EmployeeRepository(IUnitOfWork unitOfWork) : base(unitOfWork) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/NH/BaseRepository.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Domain.Entities; 2 | using EMS.Core.Domain.Repository; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using NHibernate; 7 | using NHibernate.Linq; 8 | using EMS.Core.Domain.Specification; 9 | using EMS.Core.Infra.Data; 10 | 11 | namespace EMS.Infra.Repository.NH 12 | { 13 | public class BaseRepository : IRepository where TEntity : IAggregateRoot, new() 14 | { 15 | private readonly IUnitOfWork _unitOfWork; 16 | 17 | /// 18 | /// Gets the NHibernate session object to perform database operations. 19 | /// 20 | protected ISession _session { get { return _unitOfWork.CurrentSession; } } 21 | 22 | #region Constructor 23 | 24 | public BaseRepository(IUnitOfWork unitOfWork) 25 | { 26 | if (unitOfWork == null) 27 | throw new ArgumentNullException("unitOfWork"); 28 | 29 | _unitOfWork = unitOfWork; 30 | } 31 | 32 | #endregion 33 | 34 | #region Properties 35 | 36 | /// 37 | /// Get the unit of work in this repository 38 | /// 39 | public IUnitOfWork UnitOfWork 40 | { 41 | get { return _unitOfWork; } 42 | } 43 | 44 | #endregion 45 | 46 | #region IWriteRepository 47 | 48 | public virtual void Add(TEntity entity) 49 | { 50 | if (entity == null) 51 | throw new ArgumentNullException("entity"); 52 | 53 | _session.Save(entity); 54 | } 55 | 56 | public virtual void Add(IEnumerable entities) 57 | { 58 | if (entities == null) 59 | throw new ArgumentNullException("entity"); 60 | 61 | foreach (TEntity entity in entities) 62 | { 63 | _session.Save(entity); 64 | } 65 | } 66 | 67 | public virtual void Update(TEntity entity) 68 | { 69 | if (entity == null) 70 | throw new ArgumentNullException("entity"); 71 | 72 | _session.Update(entity); 73 | } 74 | 75 | public virtual void Update(IEnumerable entities) 76 | { 77 | if (entities == null) 78 | throw new ArgumentNullException("entity"); 79 | 80 | foreach (TEntity entity in entities) 81 | { 82 | _session.Update(entity); 83 | } 84 | } 85 | 86 | public virtual void Delete(TEntity entity) 87 | { 88 | if (entity == null) 89 | throw new ArgumentNullException("entity"); 90 | 91 | _session.Delete(entity); 92 | } 93 | 94 | public virtual void Delete(IEnumerable entities) 95 | { 96 | if (entities == null) 97 | throw new ArgumentNullException("entity"); 98 | 99 | foreach (TEntity entity in entities) 100 | { 101 | _session.Delete(entity); 102 | } 103 | } 104 | 105 | #endregion 106 | 107 | #region IReadRepository 108 | 109 | public virtual IQueryable FilterBy(ISpecification spec, bool @readonly = false) 110 | { 111 | _session.FlushMode = @readonly ? FlushMode.Never : FlushMode.Auto; 112 | 113 | return GetAll().Where(spec.SpecExpression).AsQueryable(); 114 | } 115 | 116 | public virtual TEntity FindBy(ISpecification spec, bool @readonly = false) 117 | { 118 | _session.FlushMode = @readonly ? FlushMode.Never : FlushMode.Auto; 119 | 120 | return GetAll().Where(spec.SpecExpression).SingleOrDefault(); 121 | } 122 | 123 | public virtual TEntity GetById(object id, bool @readonly = false) 124 | { 125 | _session.FlushMode = @readonly ? FlushMode.Never : FlushMode.Auto; 126 | 127 | return _session.Get(id); 128 | } 129 | 130 | public virtual IQueryable GetAll(bool @readonly = false) 131 | { 132 | _session.FlushMode = @readonly ? FlushMode.Never : FlushMode.Auto; 133 | 134 | return _session.Query(); 135 | } 136 | 137 | #endregion 138 | 139 | #region Dispose 140 | 141 | public void Dispose() 142 | { 143 | Dispose(true); 144 | } 145 | 146 | ~BaseRepository() 147 | { 148 | Dispose(false); 149 | } 150 | 151 | protected virtual void Dispose(bool disposing) 152 | { 153 | if (disposing) 154 | { 155 | _unitOfWork.Dispose(); 156 | GC.SuppressFinalize(this); 157 | } 158 | } 159 | 160 | #endregion 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Infra.Repository")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("01f213a3-92ea-49a8-9df5-ef789c4ca217")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 38 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 39 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Infra.Repository/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /EMS.Services.Tests/EMS.Services.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {77CDE134-D2DC-4283-AEFD-2ABDCD8D5977} 7 | Library 8 | Properties 9 | EMS.Services.Tests 10 | EMS.Services.Tests 11 | v4.5.2 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | False 15 | UnitTest 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {ECCB98ED-66E4-41A9-BFF4-2A2B1046BCDC} 57 | EMS.Services 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /EMS.Services.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EMS.Services.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("EMS.Services.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("77cde134-d2dc-4283-aefd-2abdcd8d5977")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /EMS.Services.Tests/UnitTest1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace EMS.Services.Tests 5 | { 6 | [TestClass] 7 | public class UnitTest1 8 | { 9 | [TestMethod] 10 | public void TestMethod1() 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /EMS.Services.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /EMS.Services/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace EMS.Services.App_Start 8 | { 9 | public class FilterConfig 10 | { 11 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 12 | { 13 | filters.Add(new HandleErrorAttribute()); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /EMS.Services/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using EMS.Infra.CrossCutting.Log.ActionFilters; 2 | using System.Web.Http; 3 | 4 | namespace EMS.Services 5 | { 6 | public static class WebApiConfig 7 | { 8 | public static string ControllerOnly = "ApiControllerOnly"; 9 | public static string ControllerAndId = "ApiControllerAndIntegerId"; 10 | public static string ControllerAction = "ApiControllerAction"; 11 | 12 | public static void Register(HttpConfiguration config) 13 | { 14 | config.Filters.Add(new LoggingFilterAttribute()); 15 | config.Filters.Add(new GlobalExceptionAttribute()); 16 | 17 | // Web API routes 18 | config.MapHttpAttributeRoutes(); 19 | //config.EnsureInitialized(); 20 | 21 | var routes = config.Routes; 22 | 23 | // This controller-per-type route is ideal for GetAll calls. 24 | // It finds the method on the controller using WebAPI conventions 25 | // The template has no parameters. 26 | // 27 | // ex: api/sessionbriefs 28 | // ex: api/sessions 29 | // ex: api/persons 30 | routes.MapHttpRoute( 31 | name: ControllerOnly, 32 | routeTemplate: "api/{controller}" 33 | ); 34 | 35 | // This is the default route that a "File | New MVC 4 " project creates. 36 | // (I changed the name, removed the defaults, and added the constraints) 37 | // 38 | // This controller-per-type route lets us fetch a single resource by numeric id 39 | // It finds the appropriate method GetById method 40 | // on the controller using WebAPI conventions 41 | // The {id} is not optional, must be an integer, and 42 | // must match a method with a parameter named "id" (case insensitive) 43 | // 44 | // ex: api/sessions/1 45 | // ex: api/persons/1 46 | routes.MapHttpRoute( 47 | name: ControllerAndId, 48 | routeTemplate: "api/{controller}/{id}", 49 | defaults: null, //defaults: new { id = RouteParameter.Optional } //, 50 | constraints: new { id = @"^\d+$" } // id must be all digits 51 | ); 52 | 53 | /******************************************************** 54 | * The integer id constraint is necessary to distinguish 55 | * the {id} route above from the {action} route below. 56 | * For example, the route above handles 57 | * "api/sessions/1" 58 | * whereas the route below handles 59 | * "api/lookups/all" 60 | ********************************************************/ 61 | 62 | // This RPC style route is great for lookups and custom calls 63 | // It matches the {action} to a method on the controller 64 | // 65 | // ex: api/lookups/all 66 | // ex: api/lookups/rooms 67 | routes.MapHttpRoute( 68 | name: ControllerAction, 69 | routeTemplate: "api/{controller}/{action}", 70 | defaults: new { id = RouteParameter.Optional } 71 | ); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /EMS.Services/Controllers/Common/BaseApiController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.Http; 7 | 8 | namespace EMS.Services.Controllers.Common 9 | { 10 | public class BaseApiController : ApiController 11 | { 12 | #region Dispose 13 | 14 | //public void Dispose() 15 | //{ 16 | // Dispose(true); 17 | //} 18 | 19 | //~BaseApiController() 20 | //{ 21 | // Dispose(false); 22 | //} 23 | 24 | //protected virtual void Dispose(bool disposing) 25 | //{ 26 | // if (disposing) 27 | // { 28 | // GC.SuppressFinalize(this); 29 | // } 30 | //} 31 | 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /EMS.Services/Controllers/Hrm/EmployeeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using EMS.Services.Interfaces; 4 | using System.Web.Http; 5 | using EMS.Application.Hrm.Interfaces; 6 | using System.Net; 7 | using EMS.Infra.CrossCutting.Log.ErrorHelper; 8 | using EMS.Domain.Hrm.Dto; 9 | using EMS.Services.Controllers.Common; 10 | 11 | namespace EMS.Services.Controllers.Hrm 12 | { 13 | //[AuthorizationRequired] 14 | //[RoutePrefix("v1/Employee/Product")] 15 | public class EmployeeController : BaseApiController, IEmployeeApiController 16 | { 17 | private readonly IEmployeeAppService _employeeAppService; 18 | 19 | #region Constructor 20 | 21 | public EmployeeController(IEmployeeAppService employeeAppService) 22 | { 23 | if (employeeAppService == null) 24 | throw new ArgumentNullException("employeeAppService"); 25 | 26 | _employeeAppService = employeeAppService; 27 | } 28 | 29 | #endregion 30 | 31 | [HttpGet] 32 | public HttpResponseMessage GetEmployeeById(long id) 33 | { 34 | if (id != 0) 35 | { 36 | var employee = _employeeAppService.GetById(id); 37 | if (employee != null) 38 | return Request.CreateResponse(HttpStatusCode.OK, employee); 39 | 40 | throw new ApiDataException(1001, "No product found for this id.", HttpStatusCode.NotFound); 41 | } 42 | throw new ApiException() { ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = "Bad Request..." }; 43 | } 44 | 45 | [HttpDelete] 46 | public HttpResponseMessage Delete(long id) 47 | { 48 | throw new NotImplementedException(); 49 | //if (id > 0) 50 | //{ 51 | // var isSuccess = _employeeAppService.Remove(id); 52 | // if (isSuccess) 53 | // { 54 | // return Request.CreateResponse(HttpStatusCode.OK, isSuccess); 55 | // } 56 | // throw new ApiDataException(1002, "Product is already deleted or not exist in system.", HttpStatusCode.NoContent); 57 | //} 58 | //throw new ApiException() { ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = "Bad Request..." }; 59 | } 60 | 61 | [HttpPost] 62 | public HttpResponseMessage Post(EmployeeDto employeeDto) 63 | { 64 | throw new NotImplementedException(); 65 | //return Request.CreateResponse(HttpStatusCode.OK, _employeeAppService.Create(employeeDto)); 66 | } 67 | 68 | [HttpPut] 69 | public HttpResponseMessage Put(EmployeeDto employeeDto) 70 | { 71 | throw new NotImplementedException(); 72 | } 73 | 74 | #region Dispose 75 | 76 | protected override void Dispose(bool disposing) 77 | { 78 | //_employeeAppService.Dispose(); 79 | base.Dispose(disposing); 80 | } 81 | 82 | #endregion 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /EMS.Services/Controllers/Hrm/Interfaces/IEmployeeApiController.cs: -------------------------------------------------------------------------------- 1 | using EMS.Domain.Hrm.Dto; 2 | using EMS.Domain.Hrm.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Net.Http; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace EMS.Services.Interfaces 11 | { 12 | public interface IEmployeeApiController 13 | { 14 | HttpResponseMessage GetEmployeeById(long id); 15 | HttpResponseMessage Delete(long id); 16 | HttpResponseMessage Post(EmployeeDto employeeDto); 17 | HttpResponseMessage Put(EmployeeDto employeeDto); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /EMS.Services/Core/ActionFilters/AntiForgeryTokenFilterProvider .cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Web; 5 | //using System.Web.Mvc; 6 | //namespace EMS.Core.Services.ActionFilters 7 | //{ 8 | // public class AntiForgeryTokenFilterProvider : System.Web.Mvc.IFilterProvider 9 | // { 10 | // public IEnumerable GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) 11 | // { 12 | // List result = new List(); 13 | 14 | // string incomingVerb = controllerContext.HttpContext.Request.HttpMethod; 15 | 16 | // if (String.Equals(incomingVerb, "POST", StringComparison.OrdinalIgnoreCase)) 17 | // { 18 | // result.Add(new Filter(new ValidateAntiForgeryTokenAttribute(), FilterScope.Global, null)); 19 | // } 20 | 21 | // return result; 22 | // } 23 | // } 24 | //} 25 | -------------------------------------------------------------------------------- /EMS.Services/Core/ActionFilters/CompressResponseAttribute.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Text; 5 | //using System.Web; 6 | //using System.Web.Mvc; 7 | //using System.IO.Compression; 8 | 9 | //namespace FNHMVC.Web.Core.ActionFilters 10 | //{ 11 | // public class CompressResponseAttribute : ActionFilterAttribute 12 | // { 13 | // public override void OnActionExecuting(ActionExecutingContext filterContext) 14 | // { 15 | // HttpRequestBase request = filterContext.HttpContext.Request; 16 | 17 | // string acceptEncoding = request.Headers["Accept-Encoding"]; 18 | 19 | // if (!String.IsNullOrEmpty(acceptEncoding)) 20 | // { 21 | // acceptEncoding = acceptEncoding.ToUpperInvariant(); 22 | 23 | // HttpResponseBase response = filterContext.HttpContext.Response; 24 | 25 | // if (acceptEncoding.Contains("GZIP")) 26 | // { 27 | // response.AppendHeader("Content-encoding", "gzip"); 28 | // response.Filter = new GZipStream(response.Filter, CompressionMode.Compress); 29 | // } 30 | // else if (acceptEncoding.Contains("DEFLATE")) 31 | // { 32 | // response.AppendHeader("Content-encoding", "deflate"); 33 | // response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress); 34 | // } 35 | // } 36 | // } 37 | // } 38 | //} 39 | -------------------------------------------------------------------------------- /EMS.Services/Core/ActionFilters/ValidationActionFilter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Net.Http; 7 | using System.Web; 8 | using System.Web.Http.Controllers; 9 | using System.Web.Http.Filters; 10 | 11 | namespace EMS.Services.Core.ActionFilters 12 | { 13 | public class ValidationActionFilter : ActionFilterAttribute 14 | { 15 | public override void OnActionExecuting(HttpActionContext context) 16 | { 17 | var modelState = context.ModelState; 18 | if (!modelState.IsValid) 19 | { 20 | var errors = new JObject(); 21 | foreach (var key in modelState.Keys) 22 | { 23 | var state = modelState[key]; 24 | if (state.Errors.Any()) 25 | { 26 | errors[key] = state.Errors.First().ErrorMessage; 27 | } 28 | } 29 | 30 | context.Response = context.Request.CreateResponse(HttpStatusCode.BadRequest, errors); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /EMS.Services/Core/Config/GlobalConfig.cs: -------------------------------------------------------------------------------- 1 | using EMS.Services.Core.ActionFilters; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Serialization; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Web; 8 | using System.Web.Http; 9 | 10 | namespace EMS.Services.Core.Config 11 | { 12 | public static class GlobalCustomizeConfig 13 | { 14 | public static void CustomizeConfig(HttpConfiguration config) 15 | { 16 | // Return request in JSON format 17 | var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); 18 | config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); 19 | config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; 20 | 21 | // Remove Xml formatters. This means when we visit an endpoint from a browser, 22 | // Instead of returning Xml, it will return Json. 23 | // More information from Dave Ward: http://jpapa.me/P4vdx6 24 | config.Formatters.Remove(config.Formatters.XmlFormatter); 25 | 26 | // Configure json camelCasing per the following post: http://jpapa.me/NqC2HH 27 | // Here we configure it to write JSON property names with camel casing 28 | // without changing our server-side data model: 29 | var json = config.Formatters.JsonFormatter; 30 | 31 | // Handle cyclical references for json 32 | json.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None; 33 | //json.UseDataContractJsonSerializer = false; 34 | var settings = json.SerializerSettings; 35 | 36 | #if DEBUG 37 | // Pretty json for developers. 38 | settings.Formatting = Formatting.Indented; 39 | #else 40 | settings.Formatting = Formatting.None; 41 | #endif 42 | json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 43 | 44 | 45 | //set date time for local date 46 | settings.DateTimeZoneHandling = DateTimeZoneHandling.Local; 47 | 48 | // Add model validation, globally 49 | config.Filters.Add(new ValidationActionFilter()); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /EMS.Services/Core/Cors/CorsHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace EMS.Core.Services.Cors 8 | { 9 | public class CorsHandler : DelegatingHandler 10 | { 11 | private const string Origin = "Origin"; 12 | private const string AccessControlRequestMethod = "Access-Control-Request-Method"; 13 | private const string AccessControlRequestHeaders = "Access-Control-Request-Headers"; 14 | private const string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; 15 | private const string AccessControlAllowMethods = "Access-Control-Allow-Methods"; 16 | private const string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; 17 | 18 | protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 19 | { 20 | bool isCorsRequest = request.Headers.Contains(Origin); 21 | bool isPreflightRequest = request.Method == HttpMethod.Options; 22 | 23 | if (isCorsRequest) 24 | { 25 | if (isPreflightRequest) 26 | { 27 | var response = new HttpResponseMessage(HttpStatusCode.OK); 28 | response.Headers.Add(AccessControlAllowOrigin, request.Headers.GetValues(Origin).First()); 29 | 30 | string accessControlRequestMethod = request.Headers.GetValues(AccessControlRequestMethod).FirstOrDefault(); 31 | if (accessControlRequestMethod != null) 32 | { 33 | response.Headers.Add(AccessControlAllowMethods, accessControlRequestMethod); 34 | } 35 | 36 | string requestedHeaders = string.Join(", ", request.Headers.GetValues(AccessControlRequestHeaders)); 37 | if (!string.IsNullOrEmpty(requestedHeaders)) 38 | { 39 | response.Headers.Add(AccessControlAllowHeaders, requestedHeaders); 40 | } 41 | 42 | var tcs = new TaskCompletionSource(); 43 | tcs.SetResult(response); 44 | return tcs.Task; 45 | } 46 | 47 | return base.SendAsync(request, cancellationToken).ContinueWith(t => 48 | { 49 | HttpResponseMessage resp = t.Result; 50 | resp.Headers.Add(AccessControlAllowOrigin, request.Headers.GetValues(Origin).First()); 51 | return resp; 52 | }); 53 | } 54 | return base.SendAsync(request, cancellationToken); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /EMS.Services/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="EMS.Services.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /EMS.Services/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | using System.Web.Http; 5 | using EMS.Services.App_Start; 6 | using EMS.Services.Core.Config; 7 | using EMS.Core.Services.Cors; 8 | using StructureMap; 9 | using EMS.Infra.CrossCutting.Ioc.DependencyResolution; 10 | 11 | namespace EMS.Services 12 | { 13 | public class Global : HttpApplication 14 | { 15 | void Application_Start(object sender, EventArgs e) 16 | { 17 | // Code that runs on application startup 18 | AreaRegistration.RegisterAllAreas(); 19 | GlobalConfiguration.Configure(WebApiConfig.Register); 20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 21 | 22 | GlobalCustomizeConfig.CustomizeConfig(GlobalConfiguration.Configuration); 23 | GlobalConfiguration.Configuration.MessageHandlers.Add(new CorsHandler()); 24 | 25 | //dependency resoulver 26 | IContainer container = IoC.Initialize(); 27 | GlobalConfiguration.Configuration.DependencyResolver = new StructureMapWebApiDependencyResolver(container); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /EMS.Services/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using EMS.Core.Helpers; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using EMS.Core.ErpSetup; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("EMS.Services")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany(VersionInfo.Company)] 14 | [assembly: AssemblyProduct(VersionInfo.ProductName)] 15 | [assembly: AssemblyCopyright(VersionInfo.Copyright)] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("eccb98ed-66e4-41a9-bff4-2a2b1046bcdc")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Revision and Build Numbers 35 | // by using the '*' as shown below: 36 | [assembly: AssemblyVersion(VersionInfo.product.FileVersion)] 37 | [assembly: AssemblyFileVersion(VersionInfo.sdk.FileVersion)] 38 | -------------------------------------------------------------------------------- /EMS.Services/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /EMS.Services/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /EMS.Services/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /EMS.Services/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | EMS 5 | false 6 | true 7 | thread_static 8 | NHibernate.Connection.DriverConnectionProvider 9 | NHibernate.Dialect.MsSql2012Dialect 10 | NHibernate.Driver.SqlClientDriver 11 | false 12 | false 13 | EMS.dbo 14 | 200 15 | 16 | 17 | -------------------------------------------------------------------------------- /EMS.Services/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /EMS.UI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EMS.UI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("EMS.UI")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3e80f895-155c-4c1b-8cbc-7f2534e5686c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /EMS.UI/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /EMS.UI/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /EMS.UI/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # webapi-erp-app-architecture 2 | Large scale application architecture of asp.net web api 3 | --------------------------------------------------------------------------------