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

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
Browse files Browse the repository at this point in the history
…e-ui-design
  • Loading branch information
Shannon Gray committed Nov 15, 2016
2 parents 70dc9a1 + 844f919 commit 4c9b407
Show file tree
Hide file tree
Showing 28 changed files with 348 additions and 25 deletions.
101 changes: 101 additions & 0 deletions .about.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
licenses:
angular:
name: MIT
angular-animate:
name: MIT
angular-cookies:
name: MIT
angular-moment:
name: MIT
angular-recaptcha:
name: MIT
angular-resource:
name: MIT
angular-route:
name: MIT
angular-sanitize:
name: MIT
jquery:
name: MIT
lodash:
name: MIT
moment:
name: MIT
ng-mask:
name: MIT
zxcvbn:
name: MIT
angular-mocks:
name: MIT
babel-core:
name: MIT
babel-loader:
name: MIT
babel-polyfill:
name: MIT
babel-preset-es2015:
name: MIT
copy-webpack-plugin:
name: MIT
css-loader:
name: MIT
eslint:
name: MIT
eslint-loader:
name: MIT
file-loader:
name: MIT
html-loader:
name: MIT
istanbul-instrumenter-loader:
name: WTFPL
jasmine:
name: MIT
jasmine-core:
name: MIT
karma:
name: MIT
karma-chrome-launcher:
name: MIT
karma-coverage:
name: MIT
karma-coveralls:
name: MIT
karma-jasmine:
name: MIT
karma-phantomjs-launcher:
name: MIT
karma-webpack:
name: MIT
ncp:
name: MIT
ng-annotate-loader:
name: MIT
ngtemplate-loader:
name: MIT
node-bourbon:
name: MIT
node-sass:
name: MIT
resolve-url-loader:
name: MIT
rimraf:
name: ISC
sass-loader:
name: MIT
script-loader:
name: MIT
style-loader:
name: MIT
susy:
name: BSD-3-Clause
url-loader:
name: MIT
uswds:
name: SEE LICENSE in LICENSE.md
webpack:
name: MIT
webpack-dev-server:
name: MIT
webpack-fail-plugin:
name: MIT
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void Register()
container.Register<IApplicationRepository, ApplicationRepository>(Lifestyle.Scoped);
container.Register<IApplicationService, ApplicationService>(Lifestyle.Scoped);
container.Register<IApplicationSummaryFactory, ApplicationSummaryFactory>(Lifestyle.Scoped);
container.Register<IStatusRepository, StatusRepository>(Lifestyle.Scoped);
container.Register<IStatusService, StatusService>(Lifestyle.Scoped);

// FluentValidation validators (make this singletons since the overhead of spinning up is high and they have no state)
container.Register<IApplicationSubmissionValidator, ApplicationSubmissionValidator>(Lifestyle.Singleton);
Expand Down
26 changes: 25 additions & 1 deletion DOL.WHD.Section14c.Api/Controllers/ApplicationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ public class ApplicationController : ApiController
private readonly IApplicationService _applicationService;
private readonly IApplicationSubmissionValidator _applicationSubmissionValidator;
private readonly IApplicationSummaryFactory _applicationSummaryFactory;
public ApplicationController(IIdentityService identityService, IApplicationService applicationService, IApplicationSubmissionValidator applicationSubmissionValidator, IApplicationSummaryFactory applicationSummaryFactory)
private readonly IStatusService _statusService;
public ApplicationController(IIdentityService identityService, IApplicationService applicationService, IApplicationSubmissionValidator applicationSubmissionValidator, IApplicationSummaryFactory applicationSummaryFactory, IStatusService statusService)
{
_identityService = identityService;
_applicationService = applicationService;
_applicationSubmissionValidator = applicationSubmissionValidator;
_applicationSummaryFactory = applicationSummaryFactory;
_statusService = statusService;
}

[HttpPost]
Expand Down Expand Up @@ -74,6 +76,28 @@ public HttpResponseMessage GetApplicationsSummary()
return Request.CreateResponse(HttpStatusCode.OK, applicationSummaries);
}

[HttpPost]
[Route("status")]
[AuthorizeClaims(ApplicationClaimTypes.ChangeApplicationStatus)]
public async Task<HttpResponseMessage> ChangeApplicationStatus(Guid id, int statusId)
{
var application = _applicationService.GetApplicationById(id);
if (application == null)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}

// check status id to make sure it is valid
var status = _statusService.GetStatus(statusId);
if (status == null)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, "Status Id is not valid");
}

await _applicationService.ChangeApplicationStatus(application, statusId);
return Request.CreateResponse(HttpStatusCode.OK, $"/api/application?id={id}");
}

[AllowAnonymous]
public HttpResponseMessage Options()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@
<Compile Include="IIdentityService.cs" />
<Compile Include="IResponseService.cs" />
<Compile Include="ISaveService.cs" />
<Compile Include="IStatusService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="IReCaptchaService.cs" />
<Compile Include="Services\ApplicationService.cs" />
<Compile Include="Services\IdentityService.cs" />
<Compile Include="Services\ReCaptchaService.cs" />
<Compile Include="Services\ResponseService.cs" />
<Compile Include="Services\SaveService.cs" />
<Compile Include="Services\StatusService.cs" />
<Compile Include="Validators\AddressValidatorNoCounty.cs" />
<Compile Include="Validators\AddressValidator.cs" />
<Compile Include="Validators\AlternateWageDataValidator.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public ApplicationSummary Build(ApplicationSubmission submission)
{
var obj = new ApplicationSummary
{
Id = submission.Id,
ApplicationType = submission.ApplicationType.Display,
CertificateEffectiveDate = submission.CertificateEffectiveDate,
CertificateExpirationDate = submission.CertificateExpirationDate,
Expand Down
1 change: 1 addition & 0 deletions DOL.WHD.Section14c.Business/IApplicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IApplicationService
Task<int> SubmitApplicationAsync(ApplicationSubmission submission);
ApplicationSubmission GetApplicationById(Guid id);
IEnumerable<ApplicationSubmission> GetAllApplications();
Task<int> ChangeApplicationStatus(ApplicationSubmission application, int newStatusId);
void ProcessModel(ApplicationSubmission vm);
}
}
10 changes: 10 additions & 0 deletions DOL.WHD.Section14c.Business/IStatusService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.Business
{
public interface IStatusService : IDisposable
{
Status GetStatus(int id);
}
}
10 changes: 8 additions & 2 deletions DOL.WHD.Section14c.Business/Services/ApplicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public ApplicationService(IApplicationRepository applicationRepository)
_applicationRepository = applicationRepository;
}

public Task<int> SubmitApplicationAsync(ApplicationSubmission submission)
public async Task<int> SubmitApplicationAsync(ApplicationSubmission submission)
{
return _applicationRepository.AddAsync(submission);
return await _applicationRepository.AddAsync(submission);
}

public ApplicationSubmission GetApplicationById(Guid id)
Expand All @@ -31,6 +31,12 @@ public IEnumerable<ApplicationSubmission> GetAllApplications()
return _applicationRepository.Get().ToList();
}

public async Task<int> ChangeApplicationStatus(ApplicationSubmission application, int newStatusId)
{
application.StatusId = newStatusId;
return await _applicationRepository.ModifyApplication(application);
}

public void ProcessModel(ApplicationSubmission vm)
{
CleanupModel(vm);
Expand Down
25 changes: 25 additions & 0 deletions DOL.WHD.Section14c.Business/Services/StatusService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq;
using DOL.WHD.Section14c.DataAccess;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.Business.Services
{
public class StatusService : IStatusService
{
private readonly IStatusRepository _repository;
public StatusService(IStatusRepository repository)
{
_repository = repository;
}

public Status GetStatus(int id)
{
return _repository.Get().SingleOrDefault(x => x.Id == id);
}

public void Dispose()
{
_repository.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="IFileRepository.cs" />
<Compile Include="ISaveRepository.cs" />
<Compile Include="IResponseRepository.cs" />
<Compile Include="IStatusRepository.cs" />
<Compile Include="Migrations\201609221644036_initial.cs" />
<Compile Include="Migrations\201609221644036_initial.Designer.cs">
<DependentUpon>201609221644036_initial.cs</DependentUpon>
Expand Down Expand Up @@ -240,6 +241,7 @@
<Compile Include="IApplicationRepository.cs" />
<Compile Include="Repositories\ResponseRepository.cs" />
<Compile Include="Repositories\SaveRepository.cs" />
<Compile Include="Repositories\StatusRepository.cs" />
<Compile Include="Validators\Section14cPasswordValidator.cs" />
<Compile Include="Validators\Section14cUserValidator.cs" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions DOL.WHD.Section14c.DataAccess/IApplicationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IApplicationRepository : IDisposable
{
IQueryable<ApplicationSubmission> Get();
Task<int> AddAsync(ApplicationSubmission submission);
Task<int> ModifyApplication(ApplicationSubmission submission);
Task<int> SaveChangesAsync();
}
}
1 change: 0 additions & 1 deletion DOL.WHD.Section14c.DataAccess/IResponseRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DOL.WHD.Section14c.Domain.Models.Submission;

Expand Down
11 changes: 11 additions & 0 deletions DOL.WHD.Section14c.DataAccess/IStatusRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Linq;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.DataAccess
{
public interface IStatusRepository : IDisposable
{
IQueryable<Status> Get();
}
}
2 changes: 2 additions & 0 deletions DOL.WHD.Section14c.DataAccess/Migrations/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ protected override void Seed(ApplicationDbContext context)
context.AddFeature(ApplicationClaimTypes.SubmitApplication, "Submit Application");
context.AddFeature(ApplicationClaimTypes.GetRoles, "Get list of Application Roles");
context.AddFeature(ApplicationClaimTypes.ViewAllApplications, "View All Submitted Applications");
context.AddFeature(ApplicationClaimTypes.ChangeApplicationStatus, "Change the Status of a Submitted Application");

context.SaveChanges();

Expand All @@ -144,6 +145,7 @@ protected override void Seed(ApplicationDbContext context)
context.AddRoleFeature(Roles.SystemAdministrator, ApplicationClaimTypes.ModifyAccount);
context.AddRoleFeature(Roles.SystemAdministrator, ApplicationClaimTypes.GetRoles);
context.AddRoleFeature(Roles.SystemAdministrator, ApplicationClaimTypes.ViewAllApplications);
context.AddRoleFeature(Roles.SystemAdministrator, ApplicationClaimTypes.ChangeApplicationStatus);

// seed application statuses
context.ApplicationStatuses.AddOrUpdate(new Status { Id = StatusIds.Pending, Name = "Pending", IsActive = true });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using DOL.WHD.Section14c.Domain.Models.Submission;

Expand All @@ -17,10 +18,16 @@ public IQueryable<ApplicationSubmission> Get()
return _dbContext.ApplicationSubmissions.AsQueryable();
}

public Task<int> AddAsync(ApplicationSubmission submission)
public async Task<int> AddAsync(ApplicationSubmission submission)
{
_dbContext.ApplicationSubmissions.Add(submission);
return SaveChangesAsync();
return await SaveChangesAsync();
}

public async Task<int> ModifyApplication(ApplicationSubmission submission)
{
_dbContext.Entry(submission).State = EntityState.Modified;
return await SaveChangesAsync();
}

public Task<int> SaveChangesAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.DataAccess.Repositories
Expand Down
24 changes: 24 additions & 0 deletions DOL.WHD.Section14c.DataAccess/Repositories/StatusRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Linq;
using DOL.WHD.Section14c.Domain.Models.Submission;

namespace DOL.WHD.Section14c.DataAccess.Repositories
{
public class StatusRepository: IStatusRepository
{
private readonly ApplicationDbContext _dbContext;
public StatusRepository()
{
_dbContext = new ApplicationDbContext();
}

public IQueryable<Status> Get()
{
return _dbContext.ApplicationStatuses.AsQueryable();
}

public void Dispose()
{
_dbContext.Dispose();
}
}
}
4 changes: 1 addition & 3 deletions DOL.WHD.Section14c.Domain/Models/ApplicationSummary.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DOL.WHD.Section14c.Domain.Models
{
public class ApplicationSummary
{
public Guid Id { get; set; }
public string StatusName { get; set; }
public DateTime? CertificateEffectiveDate { get; set; }
public DateTime? CertificateExpirationDate { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class ApplicationClaimTypes

// Application Management
public const string ViewAllApplications = ClaimPrefix + "Application.ViewAll";
public const string ChangeApplicationStatus = ClaimPrefix + "Application.ChangeStatus";

public const string Role = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role";
}
Expand Down
Loading

0 comments on commit 4c9b407

Please sign in to comment.