Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #131 from AppliedIS/sprint3-refactor
Browse files Browse the repository at this point in the history
Sprint 3 Refactor into Main
  • Loading branch information
MrMatt57 committed Nov 11, 2016
2 parents 7c11409 + 26ac63c commit 045b53a
Show file tree
Hide file tree
Showing 110 changed files with 1,209 additions and 1,333 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static void Register()
container.Register<IEmployeeValidator, EmployeeValidator>(Lifestyle.Singleton);
container.Register<IWIOAWorkerValidator, WIOAWorkerValidator>(Lifestyle.Singleton);
container.Register<IAddressValidatorNoCounty, AddressValidatorNoCounty>(Lifestyle.Singleton);
container.Register<ISignatureValidator, SignatureValidator>(Lifestyle.Singleton);

// This is an extension method from the integration package.
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
Expand Down
15 changes: 1 addition & 14 deletions DOL.WHD.Section14c.Api/Controllers/ApplicationController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Net;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
Expand Down Expand Up @@ -47,18 +46,6 @@ public async Task<HttpResponseMessage> Submit([FromBody]ApplicationSubmission su
return Request.CreateResponse(HttpStatusCode.Created);
}

[HttpGet]
[AuthorizeClaims(ApplicationClaimTypes.ViewAllApplications)]
public HttpResponseMessage GetApplication(Guid id)
{
var application = _applicationService.GetApplicationById(id);
if (application != null)
{
return Request.CreateResponse(HttpStatusCode.OK, application);
}
return Request.CreateResponse(HttpStatusCode.NotFound);
}

[AllowAnonymous]
public HttpResponseMessage Options()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<Compile Include="Validators\IAlternateWageDataValidator.cs" />
<Compile Include="Validators\IEmployeeValidator.cs" />
<Compile Include="Validators\IPrevailingWageSurveyInfoValidator.cs" />
<Compile Include="Validators\ISignatureValidator.cs" />
<Compile Include="Validators\ISourceEmployerValidator.cs" />
<Compile Include="Validators\IWIOAValidator.cs" />
<Compile Include="Validators\IWIOAWorkerValidator.cs" />
Expand All @@ -93,7 +92,6 @@
<Compile Include="Validators\IPieceRateWageInfoValidator.cs" />
<Compile Include="Validators\IHourlyWageInfoValidator.cs" />
<Compile Include="Validators\PrevailingWageSurveyInfoValidator.cs" />
<Compile Include="Validators\SignatureValidator.cs" />
<Compile Include="Validators\SourceEmployerValidator.cs" />
<Compile Include="Validators\WageTypeInfoValidator.cs" />
<Compile Include="Validators\WIOAValidator.cs" />
Expand Down
4 changes: 1 addition & 3 deletions DOL.WHD.Section14c.Business/IApplicationService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.Business
{
public interface IApplicationService
{
Task<int> SubmitApplicationAsync(ApplicationSubmission submission);
ApplicationSubmission GetApplicationById(Guid id);
ApplicationSubmission CleanupModel(ApplicationSubmission vm);
}
}
20 changes: 7 additions & 13 deletions DOL.WHD.Section14c.Business/Services/ApplicationService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks;
using DOL.WHD.Section14c.DataAccess;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.Business.Services
Expand All @@ -19,21 +18,16 @@ public Task<int> SubmitApplicationAsync(ApplicationSubmission submission)
return _applicationRepository.AddAsync(submission);
}

public ApplicationSubmission GetApplicationById(Guid id)
{
return _applicationRepository.Get().SingleOrDefault(x => x.Id == id);
}

public ApplicationSubmission CleanupModel(ApplicationSubmission vm)
{
var result = vm;

// clear out non-selected wage type
if (result.PayTypeId == 21) // hourly
if (result.PayTypeId == ResponseIds.PayType.Hourly)
{
result.PieceRateWageInfo = null;
}
else if (result.PayTypeId == 22) // piece rate
else if (result.PayTypeId == ResponseIds.PayType.PieceRate)
{
result.HourlyWageInfo = null;
}
Expand All @@ -48,17 +42,17 @@ public ApplicationSubmission CleanupModel(ApplicationSubmission vm)
private void CleanupWageTypeInfo(WageTypeInfo wageTypeInfo)
{
var prevailingWageMethod = wageTypeInfo?.PrevailingWageMethodId;
if (prevailingWageMethod == 24) // Prevailing Wage Survey
if (prevailingWageMethod == ResponseIds.PrevailingWageMethod.PrevailingWageSurvey)
{
wageTypeInfo.AlternateWageData = null;
wageTypeInfo.SCAWageDeterminationId = null;
}
else if (prevailingWageMethod == 25) // Alternate Wage Data
else if (prevailingWageMethod == ResponseIds.PrevailingWageMethod.AlternateWageData)
{
wageTypeInfo.MostRecentPrevailingWageSurvey = null;
wageTypeInfo.SCAWageDeterminationId = null;
}
else if (prevailingWageMethod == 26) // SCA Wage Determination
else if (prevailingWageMethod == ResponseIds.PrevailingWageMethod.SCAWageDetermination)
{
wageTypeInfo.MostRecentPrevailingWageSurvey = null;
wageTypeInfo.AlternateWageData = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using System.Linq;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

namespace DOL.WHD.Section14c.Business.Validators
{
public class ApplicationSubmissionValidator : BaseValidator<ApplicationSubmission>, IApplicationSubmissionValidator
{
public ApplicationSubmissionValidator(ISignatureValidator signatureValidator, IEmployerValidator employerValidator, IHourlyWageInfoValidator hourlyWageInfoValidator, IPieceRateWageInfoValidator pieceRateWageInfoValidator, IWorkSiteValidator workSiteValidator, IWIOAValidator wioaValidator)
public ApplicationSubmissionValidator(IEmployerValidator employerValidator, IHourlyWageInfoValidator hourlyWageInfoValidator, IPieceRateWageInfoValidator pieceRateWageInfoValidator, IWorkSiteValidator workSiteValidator, IWIOAValidator wioaValidator)
{
// required
RuleFor(a => a.EIN).NotEmpty();
RuleFor(a => a.Signature).NotNull().SetValidator(signatureValidator);
RuleFor(a => a.ApplicationTypeId).NotNull().GreaterThanOrEqualTo(1).LessThanOrEqualTo(2);
RuleFor(a => a.ApplicationTypeId).NotNull().InclusiveBetween(ResponseIds.ApplicationType.Initial, ResponseIds.ApplicationType.Renewal);
RuleFor(a => a.HasPreviousApplication).NotNull();
RuleFor(a => a.HasPreviousCertificate).NotNull();
RuleFor(a => a.EstablishmentType).NotNull().Must(et => et.Any() && !et.Any(x => x.EstablishmentTypeId < 3) && !et.Any(x => x.EstablishmentTypeId > 6));
RuleFor(a => a.EstablishmentType).NotNull().Must(et => et.Any() && !et.Any(x => x.EstablishmentTypeId < ResponseIds.EstablishmentType.WorkCenter) && !et.Any(x => x.EstablishmentTypeId > ResponseIds.EstablishmentType.BusinessEstablishment));
RuleFor(a => a.ContactName).NotEmpty();
RuleFor(a => a.ContactPhone).NotEmpty();
RuleFor(a => a.ContactEmail).NotEmpty();
RuleFor(a => a.PayTypeId).NotEmpty().GreaterThanOrEqualTo(21).LessThanOrEqualTo(23);
RuleFor(a => a.PayTypeId).NotEmpty().InclusiveBetween(ResponseIds.PayType.Hourly, ResponseIds.PayType.Both);
RuleFor(a => a.TotalNumWorkSites).NotNull();
RuleFor(a => a.Employer).NotNull().SetValidator(employerValidator);
RuleFor(a => a.WorkSites).NotNull().Must(w => w.Any()).SetCollectionValidator(workSiteValidator);
Expand All @@ -32,12 +32,12 @@ public ApplicationSubmissionValidator(ISignatureValidator signatureValidator, IE
RuleFor(a => a.HourlyWageInfo)
.NotNull()
.SetValidator(hourlyWageInfoValidator)
.When(x => x.PayTypeId == 21 || x.PayTypeId == 23);
.When(x => x.PayTypeId == ResponseIds.PayType.Hourly || x.PayTypeId == ResponseIds.PayType.Both);

RuleFor(a => a.PieceRateWageInfo)
.NotNull()
.SetValidator(pieceRateWageInfoValidator)
.When(x => x.PayTypeId == 22 || x.PayTypeId == 23);
.When(x => x.PayTypeId == ResponseIds.PayType.PieceRate || x.PayTypeId == ResponseIds.PayType.Both);

// Other validation
RuleFor(a => a.ContactEmail).EmailAddress();
Expand Down
7 changes: 4 additions & 3 deletions DOL.WHD.Section14c.Business/Validators/EmployeeValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DOL.WHD.Section14c.Domain.Models.Submission;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

namespace DOL.WHD.Section14c.Business.Validators
Expand All @@ -8,7 +9,7 @@ public class EmployeeValidator : BaseValidator<Employee>, IEmployeeValidator
public EmployeeValidator()
{
RuleFor(e => e.Name).NotEmpty();
RuleFor(e => e.PrimaryDisabilityId).NotNull().GreaterThanOrEqualTo(31).LessThanOrEqualTo(38);
RuleFor(e => e.PrimaryDisabilityId).NotNull().InclusiveBetween(ResponseIds.PrimaryDisability.IntellectualDevelopmental, ResponseIds.PrimaryDisability.Other);
RuleFor(e => e.WorkType).NotEmpty();
RuleFor(e => e.NumJobs).NotNull();
RuleFor(e => e.AvgWeeklyHours).NotNull();
Expand All @@ -20,7 +21,7 @@ public EmployeeValidator()
RuleFor(e => e.WorkAtOtherSite).NotNull();

// conditional
RuleFor(e => e.PrimaryDisabilityOther).NotEmpty().When(e => e.PrimaryDisabilityId == 38);
RuleFor(e => e.PrimaryDisabilityOther).NotEmpty().When(e => e.PrimaryDisabilityId == ResponseIds.PrimaryDisability.Other);
}
}
}
15 changes: 8 additions & 7 deletions DOL.WHD.Section14c.Business/Validators/EmployerValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

Expand All @@ -14,13 +15,13 @@ public EmployerValidator(IAddressValidator addressValidator, IWorkerCountInfoVal
RuleFor(e => e.LegalNameHasChanged).NotNull();
RuleFor(e => e.PhysicalAddress).NotNull().SetValidator(addressValidator);
RuleFor(e => e.HasParentOrg).NotNull();
RuleFor(e => e.EmployerStatusId).NotNull().GreaterThanOrEqualTo(7).LessThanOrEqualTo(10);
RuleFor(e => e.EmployerStatusId).NotNull().InclusiveBetween(ResponseIds.EmployerStatus.Public, ResponseIds.EmployerStatus.Other);
RuleFor(e => e.IsEducationalAgency).NotNull();
RuleFor(e => e.FiscalQuarterEndDate).NotEmpty();
RuleFor(e => e.NumSubminimalWageWorkers).NotNull().SetValidator(workerCountInfoValidator);
RuleFor(e => e.PCA).NotNull();
RuleFor(e => e.SCAId).NotNull().GreaterThanOrEqualTo(11).LessThanOrEqualTo(13);
RuleFor(e => e.EO13658Id).NotNull().GreaterThanOrEqualTo(14).LessThanOrEqualTo(16);
RuleFor(e => e.SCAId).NotNull().InclusiveBetween(ResponseIds.SCA.Yes, ResponseIds.SCA.NoButIntendTo);
RuleFor(e => e.EO13658Id).NotNull().InclusiveBetween(ResponseIds.EO13658.Yes, ResponseIds.EO13658.NoButIntendTo);
RuleFor(e => e.RepresentativePayee).NotNull();
RuleFor(e => e.TakeCreditForCosts).NotNull();
RuleFor(e => e.TemporaryAuthority).NotNull();
Expand All @@ -30,10 +31,10 @@ public EmployerValidator(IAddressValidator addressValidator, IWorkerCountInfoVal
{
RuleFor(a => a.ProvidingFacilitiesDeductionType)
.NotNull()
.Must(p => p.Any() && !p.Any(x => x.ProvidingFacilitiesDeductionTypeId < 17) && !p.Any(x => x.ProvidingFacilitiesDeductionTypeId > 20));
.Must(p => p.Any() && !p.Any(x => x.ProvidingFacilitiesDeductionTypeId < ResponseIds.ProvidingFacilitiesDeductionType.Transportation) && !p.Any(x => x.ProvidingFacilitiesDeductionTypeId > ResponseIds.ProvidingFacilitiesDeductionType.Other));
RuleFor(a => a.ProvidingFacilitiesDeductionTypeOther)
.NotEmpty()
.When(a => a.ProvidingFacilitiesDeductionType != null && a.ProvidingFacilitiesDeductionType.Any(x => x.ProvidingFacilitiesDeductionTypeId == 20));
.When(a => a.ProvidingFacilitiesDeductionType != null && a.ProvidingFacilitiesDeductionType.Any(x => x.ProvidingFacilitiesDeductionTypeId == ResponseIds.ProvidingFacilitiesDeductionType.Other));
});
RuleFor(e => e.TradeName).NotEmpty().When(e => e.HasTradeName.GetValueOrDefault());
RuleFor(e => e.PriorLegalName).NotEmpty().When(e => e.LegalNameHasChanged.GetValueOrDefault());
Expand All @@ -44,8 +45,8 @@ public EmployerValidator(IAddressValidator addressValidator, IWorkerCountInfoVal
RuleFor(e => e.ParentAddress).NotNull().SetValidator(addressValidator);
RuleFor(e => e.SendMailToParent).NotNull();
});
RuleFor(e => e.EmployerStatusOther).NotEmpty().When(e => e.EmployerStatusId == 10);
When(e => e.SCAId == 11, () =>
RuleFor(e => e.EmployerStatusOther).NotEmpty().When(e => e.EmployerStatusId == ResponseIds.EmployerStatus.Other);
When(e => e.SCAId == ResponseIds.SCA.Yes, () =>
{
RuleFor(e => e.SCACount).NotNull();
RuleFor(e => e.SCAAttachmentId).NotNull();
Expand Down
9 changes: 0 additions & 9 deletions DOL.WHD.Section14c.Business/Validators/ISignatureValidator.cs

This file was deleted.

16 changes: 0 additions & 16 deletions DOL.WHD.Section14c.Business/Validators/SignatureValidator.cs

This file was deleted.

5 changes: 3 additions & 2 deletions DOL.WHD.Section14c.Business/Validators/WIOAWorkerValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DOL.WHD.Section14c.Domain.Models.Submission;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

namespace DOL.WHD.Section14c.Business.Validators
Expand All @@ -8,7 +9,7 @@ public class WIOAWorkerValidator : BaseValidator<WIOAWorker>, IWIOAWorkerValidat
public WIOAWorkerValidator()
{
RuleFor(w => w.FullName).NotEmpty();
RuleFor(w => w.WIOAWorkerVerifiedId).NotNull().GreaterThanOrEqualTo(39).LessThanOrEqualTo(41);
RuleFor(w => w.WIOAWorkerVerifiedId).NotNull().InclusiveBetween(ResponseIds.WIOAWorkerVerified.Yes, ResponseIds.WIOAWorkerVerified.NotRequired);
}
}
}
11 changes: 6 additions & 5 deletions DOL.WHD.Section14c.Business/Validators/WageTypeInfoValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DOL.WHD.Section14c.Domain.Models.Submission;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

namespace DOL.WHD.Section14c.Business.Validators
Expand All @@ -10,21 +11,21 @@ public WageTypeInfoValidator(IPrevailingWageSurveyInfoValidator prevailingWageSu
RuleFor(w => w.NumWorkers).NotNull();
RuleFor(w => w.JobName).NotEmpty();
RuleFor(w => w.JobDescription).NotEmpty();
RuleFor(w => w.PrevailingWageMethodId).NotNull().GreaterThanOrEqualTo(24).LessThanOrEqualTo(26);
RuleFor(w => w.PrevailingWageMethodId).NotNull().InclusiveBetween(ResponseIds.PrevailingWageMethod.PrevailingWageSurvey, ResponseIds.PrevailingWageMethod.SCAWageDetermination);
RuleFor(w => w.AttachmentId).NotNull();

// conditional
RuleFor(w => w.MostRecentPrevailingWageSurvey)
.NotNull()
.SetValidator(prevailingWageSurveyInfoValidator)
.When(w => w.PrevailingWageMethodId == 24);
.When(w => w.PrevailingWageMethodId == ResponseIds.PrevailingWageMethod.PrevailingWageSurvey);
RuleFor(w => w.AlternateWageData)
.NotNull()
.SetValidator(alternateWageDataValidator)
.When(w => w.PrevailingWageMethodId == 25);
.When(w => w.PrevailingWageMethodId == ResponseIds.PrevailingWageMethod.AlternateWageData);
RuleFor(w => w.SCAWageDeterminationId)
.NotNull()
.When(w => w.PrevailingWageMethodId == 26);
.When(w => w.PrevailingWageMethodId == ResponseIds.PrevailingWageMethod.SCAWageDetermination);
}
}
}
5 changes: 3 additions & 2 deletions DOL.WHD.Section14c.Business/Validators/WorkSiteValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DOL.WHD.Section14c.Domain.Models.Submission;
using DOL.WHD.Section14c.Domain.Models;
using DOL.WHD.Section14c.Domain.Models.Submission;
using FluentValidation;

namespace DOL.WHD.Section14c.Business.Validators
Expand All @@ -7,7 +8,7 @@ public class WorkSiteValidator : BaseValidator<WorkSite>, IWorkSiteValidator
{
public WorkSiteValidator(IAddressValidatorNoCounty addressValidatorNoCounty, IEmployeeValidator employeeValidator)
{
RuleFor(w => w.WorkSiteTypeId).NotNull();
RuleFor(w => w.WorkSiteTypeId).NotNull().GreaterThanOrEqualTo(ResponseIds.WorkSiteType.MainEstablishment).LessThanOrEqualTo(ResponseIds.WorkSiteType.SWEP);
RuleFor(w => w.Name).NotEmpty();
RuleFor(w => w.Address).NotNull().SetValidator(addressValidatorNoCounty);
RuleFor(w => w.SCA).NotNull();
Expand Down
5 changes: 0 additions & 5 deletions DOL.WHD.Section14c.DataAccess/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
modelBuilder.Entity<Response>().Property(a => a.QuestionKey).IsRequired();
modelBuilder.Entity<Response>().Property(a => a.Display).IsRequired();
modelBuilder.Entity<Response>().Property(a => a.IsActive).IsRequired();
// Signature
modelBuilder.Entity<Signature>().Property(a => a.Agreement).IsRequired();
modelBuilder.Entity<Signature>().Property(a => a.FullName).IsRequired();
modelBuilder.Entity<Signature>().Property(a => a.Title).IsRequired();
modelBuilder.Entity<Signature>().Property(a => a.Date).IsRequired();
// SourceEmployer
modelBuilder.Entity<SourceEmployer>().Property(a => a.EmployerName).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.Phone).IsRequired();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@
<Compile Include="Migrations\201611081954473_RemoveRequiredCounty.Designer.cs">
<DependentUpon>201611081954473_RemoveRequiredCounty.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201611101838282_AddSignature.cs" />
<Compile Include="Migrations\201611101838282_AddSignature.Designer.cs">
<DependentUpon>201611101838282_AddSignature.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\ApplicationRepository.cs" />
Expand Down Expand Up @@ -329,9 +325,6 @@
<EmbeddedResource Include="Migrations\201611081954473_RemoveRequiredCounty.resx">
<DependentUpon>201611081954473_RemoveRequiredCounty.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201611101838282_AddSignature.resx">
<DependentUpon>201611101838282_AddSignature.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Loading

0 comments on commit 045b53a

Please sign in to comment.