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 #84 from AppliedIS/refactor-submission
Browse files Browse the repository at this point in the history
Refactor submission
  • Loading branch information
MrMatt57 committed Oct 27, 2016
2 parents 82be84b + 96103df commit 4406019
Show file tree
Hide file tree
Showing 39 changed files with 348 additions and 632 deletions.
39 changes: 0 additions & 39 deletions DOL.WHD.Section14c.Api/App_Start/AutoMapperConfiguration.cs

This file was deleted.

13 changes: 2 additions & 11 deletions DOL.WHD.Section14c.Api/Controllers/ApplicationController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.Web.Http;
using AutoMapper;
using DOL.WHD.Section14c.Business;
using DOL.WHD.Section14c.Domain.Models.Submission;
using DOL.WHD.Section14c.Domain.Models.Submission.Dto;

namespace DOL.WHD.Section14c.Api.Controllers
{
Expand All @@ -19,14 +16,8 @@ public ApplicationController(IIdentityService identityService, IApplicationServi
_applicationService = applicationService;
}

public async Task<IHttpActionResult> Submit([FromBody]ApplicationSubmissionDto submissionDto)
public async Task<IHttpActionResult> Submit([FromBody]ApplicationSubmission submission)
{
var submission = Mapper.Map<ApplicationSubmission>(submissionDto);
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}

// make sure user has rights to the EIN
var hasEINClaim = _identityService.UserHasEINClaim(User, submission.EIN);
if (!hasEINClaim)
Expand Down
5 changes: 0 additions & 5 deletions DOL.WHD.Section14c.Api/DOL.WHD.Section14c.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoMapper, Version=5.1.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework6.Npgsql, Version=3.1.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework6.Npgsql.3.1.1\lib\net45\EntityFramework6.Npgsql.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -209,7 +205,6 @@
<ItemGroup>
<Compile Include="App_Start\DependencyResolutionConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\AutoMapperConfiguration.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\Startup.Auth.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
Expand Down
3 changes: 0 additions & 3 deletions DOL.WHD.Section14c.Api/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ protected void Application_Start()

// use camel cased JSON in Web API
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

// Automapper
AutoMapperConfiguration.Configure();
}
}
}
1 change: 0 additions & 1 deletion DOL.WHD.Section14c.Api/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="5.1.1" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="EntityFramework6.Npgsql" version="3.1.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net452" />
Expand Down
105 changes: 104 additions & 1 deletion DOL.WHD.Section14c.DataAccess/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System;
using System.Linq;
using System.Web;
using System.Security.Claims;

namespace DOL.WHD.Section14c.DataAccess
{
Expand Down Expand Up @@ -35,6 +34,110 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

// data constraints
// ApplicationSubmission
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.RepresentativePayeeSocialSecurityBenefits).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ProvidingFacilities).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ReviewedDocumentation).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.EIN).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ApplicationTypeId).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.HasPreviousApplication).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.HasPreviousCertificate).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ContactName).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ContactPhone).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.ContactEmail).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.PayTypeId).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().Property(a => a.TotalNumWorkSites).IsRequired();
modelBuilder.Entity<ApplicationSubmission>().HasRequired(a => a.Employer);
modelBuilder.Entity<ApplicationSubmission>().HasRequired(a => a.WIOA);
// Attachment
modelBuilder.Entity<Attachment>().Property(a => a.OriginalFileName).IsRequired().HasMaxLength(255);
modelBuilder.Entity<Attachment>().Property(a => a.RepositoryFilePath).IsRequired().HasMaxLength(255);
modelBuilder.Entity<Attachment>().Property(a => a.FileSize).IsRequired();
modelBuilder.Entity<Attachment>().Property(a => a.MimeType).IsRequired().HasMaxLength(255);
// Employee
modelBuilder.Entity<Employee>().Property(a => a.Name).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.PrimaryDisabilityId).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.WorkType).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.NumJobs).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.AvgWeeklyHours).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.AvgHourlyEarnings).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.PrevailingWage).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.ProductivityMeasure).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.CommensurateWageRate).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.TotalHours).IsRequired();
modelBuilder.Entity<Employee>().Property(a => a.WorkAtOtherSite).IsRequired();
// EmployerInfo
modelBuilder.Entity<EmployerInfo>().Property(a => a.LegalName).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.HasTradeName).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.LegalNameHasChanged).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.HasDifferentMailingAddress).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.HasParentOrg).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.EmployerStatusId).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.IsEducationalAgency).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.FiscalQuarterEndDate).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.PCA).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.SCAId).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.EO13658Id).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.RepresentativePayee).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.TakeCreditForCosts).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.ProvidingFacilitiesDeductionTypeId).IsRequired();
modelBuilder.Entity<EmployerInfo>().Property(a => a.TemporaryAuthority).IsRequired();
modelBuilder.Entity<EmployerInfo>().HasRequired(a => a.PhysicalAddress);
modelBuilder.Entity<EmployerInfo>().HasRequired(a => a.NumSubminimalWageWorkers);
// HourlyWageInfo
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.WorkMeasurementFrequency).IsRequired();
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.NumWorkers).IsRequired();
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.JobName).IsRequired();
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.JobDescription).IsRequired();
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.PrevailingWageMethodId).IsRequired();
modelBuilder.Entity<HourlyWageInfo>().Property(a => a.AttachmentId).IsRequired();
// PieceRateWageInfo
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.PieceRateWorkDescription).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.PrevailingWageDeterminedForJob).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.StandardProductivity).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.PieceRatePaidToWorkers).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.NumWorkers).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.JobName).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.JobDescription).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.PrevailingWageMethodId).IsRequired();
modelBuilder.Entity<PieceRateWageInfo>().Property(a => a.AttachmentId).IsRequired();
// PrevailingWageSurveyInfo
modelBuilder.Entity<PrevailingWageSurveyInfo>().Property(a => a.PrevailingWageDetermined).IsRequired();
// Response
modelBuilder.Entity<Response>().Property(a => a.QuestionKey).IsRequired();
modelBuilder.Entity<Response>().Property(a => a.Display).IsRequired();
modelBuilder.Entity<Response>().Property(a => a.IsActive).IsRequired();
// SourceEmployer
modelBuilder.Entity<SourceEmployer>().Property(a => a.EmployerName).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.Phone).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.ContactName).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.ContactTitle).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.ContactDate).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.JobDescription).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.ExperiencedWorkerWageProvided).IsRequired();
modelBuilder.Entity<SourceEmployer>().Property(a => a.ConclusionWageRateNotBasedOnEntry).IsRequired();
modelBuilder.Entity<SourceEmployer>().HasRequired(a => a.Address);
// WIOA
modelBuilder.Entity<WIOA>().Property(a => a.HasVerfiedDocumentaion).IsRequired();
modelBuilder.Entity<WIOA>().Property(a => a.HasWIOAWorkers).IsRequired();
// WIOAWorker
modelBuilder.Entity<WIOAWorker>().Property(a => a.FullName).IsRequired();
modelBuilder.Entity<WIOAWorker>().Property(a => a.WIOAWorkerVerifiedId).IsRequired();
// WorkerCountInfo
modelBuilder.Entity<WorkerCountInfo>().Property(a => a.Total).IsRequired();
modelBuilder.Entity<WorkerCountInfo>().Property(a => a.WorkCenter).IsRequired();
modelBuilder.Entity<WorkerCountInfo>().Property(a => a.PatientWorkers).IsRequired();
modelBuilder.Entity<WorkerCountInfo>().Property(a => a.SWEP).IsRequired();
modelBuilder.Entity<WorkerCountInfo>().Property(a => a.BusinessEstablishment).IsRequired();
// WorkSite
modelBuilder.Entity<WorkSite>().Property(a => a.Name).IsRequired();
modelBuilder.Entity<WorkSite>().Property(a => a.SCA).IsRequired();
modelBuilder.Entity<WorkSite>().Property(a => a.FederalContractWorkPerformed).IsRequired();
modelBuilder.Entity<WorkSite>().Property(a => a.NumEmployees).IsRequired();
modelBuilder.Entity<WorkSite>().HasRequired(a => a.Address);

// many to many relationships
modelBuilder.Entity<ApplicationSubmissionEstablishmentType>()
.ToTable("AppSubmissionEstablishmentType")
.HasKey(k => new {k.ApplicationSubmissionId, k.EstablishmentTypeId});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
<Compile Include="Migrations\201610261825305_KeyUpdates.Designer.cs">
<DependentUpon>201610261825305_KeyUpdates.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201610262048363_RequiredFieldUpdates.cs" />
<Compile Include="Migrations\201610262048363_RequiredFieldUpdates.Designer.cs">
<DependentUpon>201610262048363_RequiredFieldUpdates.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\ApplicationRepository.cs" />
Expand Down Expand Up @@ -246,6 +250,9 @@
<EmbeddedResource Include="Migrations\201610261825305_KeyUpdates.resx">
<DependentUpon>201610261825305_KeyUpdates.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201610262048363_RequiredFieldUpdates.resx">
<DependentUpon>201610262048363_RequiredFieldUpdates.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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace DOL.WHD.Section14c.DataAccess.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class RequiredFieldUpdates : DbMigration
{
public override void Up()
{
DropForeignKey("dbo.HourlyWageInfoes", "AttachmentId", "dbo.Attachments");
DropForeignKey("dbo.PieceRateWageInfoes", "AttachmentId", "dbo.Attachments");
DropIndex("dbo.HourlyWageInfoes", new[] { "AttachmentId" });
DropIndex("dbo.PieceRateWageInfoes", new[] { "AttachmentId" });
AlterColumn("dbo.EmployerInfoes", "TradeName", c => c.String());
AlterColumn("dbo.EmployerInfoes", "PriorLegalName", c => c.String());
AlterColumn("dbo.HourlyWageInfoes", "AttachmentId", c => c.Guid(nullable: false));
AlterColumn("dbo.PieceRateWageInfoes", "AttachmentId", c => c.Guid(nullable: false));
CreateIndex("dbo.HourlyWageInfoes", "AttachmentId");
CreateIndex("dbo.PieceRateWageInfoes", "AttachmentId");
AddForeignKey("dbo.HourlyWageInfoes", "AttachmentId", "dbo.Attachments", "Id", cascadeDelete: true);
AddForeignKey("dbo.PieceRateWageInfoes", "AttachmentId", "dbo.Attachments", "Id", cascadeDelete: true);
}

public override void Down()
{
DropForeignKey("dbo.PieceRateWageInfoes", "AttachmentId", "dbo.Attachments");
DropForeignKey("dbo.HourlyWageInfoes", "AttachmentId", "dbo.Attachments");
DropIndex("dbo.PieceRateWageInfoes", new[] { "AttachmentId" });
DropIndex("dbo.HourlyWageInfoes", new[] { "AttachmentId" });
AlterColumn("dbo.PieceRateWageInfoes", "AttachmentId", c => c.Guid());
AlterColumn("dbo.HourlyWageInfoes", "AttachmentId", c => c.Guid());
AlterColumn("dbo.EmployerInfoes", "PriorLegalName", c => c.String(nullable: false));
AlterColumn("dbo.EmployerInfoes", "TradeName", c => c.String(nullable: false));
CreateIndex("dbo.PieceRateWageInfoes", "AttachmentId");
CreateIndex("dbo.HourlyWageInfoes", "AttachmentId");
AddForeignKey("dbo.PieceRateWageInfoes", "AttachmentId", "dbo.Attachments", "Id");
AddForeignKey("dbo.HourlyWageInfoes", "AttachmentId", "dbo.Attachments", "Id");
}
}
}
Loading

0 comments on commit 4406019

Please sign in to comment.