This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
forked from 18F/dol-whd-14c
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from AppliedIS/feature-submit
Feature submit
- Loading branch information
Showing
44 changed files
with
1,397 additions
and
43 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
DOL.WHD.Section14c.Api/App_Start/AutoMapperConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Linq; | ||
using AutoMapper; | ||
using AutoMapper.Mappers; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using DOL.WHD.Section14c.Domain.Models.Submission.Dto; | ||
|
||
namespace DOL.WHD.Section14c.Api | ||
{ | ||
public static class AutoMapperConfiguration | ||
{ | ||
public static void Configure() | ||
{ | ||
Mapper.Initialize(cfg => | ||
{ | ||
cfg.AddConditionalObjectMapper().Where((s, d) => s.Name == d.Name + "Dto"); | ||
// many to many relationships | ||
cfg.CreateMap<ApplicationSubmissionDto, ApplicationSubmission>() | ||
.AfterMap( | ||
(src, dest) => | ||
dest.EstablishmentType = | ||
src.EstablishmentTypeId.Select( | ||
x => new ApplicationSubmissionEstablishmentType {EstablishmentTypeId = x, ApplicationSubmissionId = dest.Id}).ToList()) | ||
.AfterMap( | ||
(src, dest) => | ||
dest.ProvidingFacilitiesDeductionType = | ||
src.ProvidingFacilitiesDeductionTypeId.Select( | ||
x => new ApplicationSubmissionProvidingFacilitiesDeductionType { ProvidingFacilitiesDeductionTypeId = x, ApplicationSubmissionId = dest.Id }).ToList()); | ||
cfg.CreateMap<WorkSiteDto, WorkSite>() | ||
.AfterMap( | ||
(src, dest) => | ||
dest.WorkSiteType = | ||
src.WorkSiteTypeId.Select( | ||
x => new WorkSiteWorkSiteType() { WorkSiteTypeId = x, WorkSiteId = dest.Id }).ToList()); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
DOL.WHD.Section14c.Api/Controllers/ApplicationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
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 | ||
{ | ||
[Authorize] | ||
public class ApplicationController : ApiController | ||
{ | ||
private readonly IIdentityService _identityService; | ||
private readonly IApplicationService _applicationService; | ||
public ApplicationController(IIdentityService identityService, IApplicationService applicationService) | ||
{ | ||
_identityService = identityService; | ||
_applicationService = applicationService; | ||
} | ||
|
||
public async Task<IHttpActionResult> Submit([FromBody]ApplicationSubmissionDto submissionDto) | ||
{ | ||
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) | ||
{ | ||
return Unauthorized(); | ||
} | ||
|
||
await _applicationService.SubmitApplicationAsync(submission); | ||
return Created("", (object)null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Threading.Tasks; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
|
||
namespace DOL.WHD.Section14c.Business | ||
{ | ||
public interface IApplicationService | ||
{ | ||
Task<int> SubmitApplicationAsync(ApplicationSubmission submission); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
DOL.WHD.Section14c.Business/Services/ApplicationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Threading.Tasks; | ||
using DOL.WHD.Section14c.DataAccess; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
|
||
namespace DOL.WHD.Section14c.Business.Services | ||
{ | ||
public class ApplicationService : IApplicationService | ||
{ | ||
private readonly IApplicationRepository _applicationRepository; | ||
public ApplicationService(IApplicationRepository applicationRepository) | ||
{ | ||
_applicationRepository = applicationRepository; | ||
} | ||
|
||
public Task<int> SubmitApplicationAsync(ApplicationSubmission submission) | ||
{ | ||
return _applicationRepository.AddAsync(submission); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
|
||
namespace DOL.WHD.Section14c.DataAccess | ||
{ | ||
public interface IApplicationRepository : IDisposable | ||
{ | ||
IQueryable<ApplicationSubmission> Get(); | ||
Task<int> AddAsync(ApplicationSubmission submission); | ||
Task<int> SaveChangesAsync(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
DOL.WHD.Section14c.DataAccess/Migrations/201610261825305_KeyUpdates.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.