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 #141 from AppliedIS/issue-92
endpoint to change application status
- Loading branch information
Showing
21 changed files
with
225 additions
and
9 deletions.
There are no files selected for viewing
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; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
|
||
namespace DOL.WHD.Section14c.Business | ||
{ | ||
public interface IStatusService : IDisposable | ||
{ | ||
Status GetStatus(int id); | ||
} | ||
} |
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,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(); | ||
} | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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
3 changes: 1 addition & 2 deletions
3
DOL.WHD.Section14c.DataAccess/Repositories/ResponseRepository.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
24 changes: 24 additions & 0 deletions
24
DOL.WHD.Section14c.DataAccess/Repositories/StatusRepository.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,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(); | ||
} | ||
} | ||
} |
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,39 @@ | ||
using DOL.WHD.Section14c.Business.Services; | ||
using DOL.WHD.Section14c.DataAccess; | ||
using DOL.WHD.Section14c.Test.RepositoryMocks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace DOL.WHD.Section14c.Test.Business | ||
{ | ||
[TestClass] | ||
public class StatusServiceTests | ||
{ | ||
private readonly IStatusRepository _statusRepositoryMock; | ||
|
||
public StatusServiceTests() | ||
{ | ||
_statusRepositoryMock = new StatusRepositoryMock(); | ||
} | ||
|
||
[TestMethod] | ||
public void ReturnsStatus() | ||
{ | ||
// Arrange | ||
var service = new StatusService(_statusRepositoryMock); | ||
|
||
// Act | ||
var statusObj = service.GetStatus(1); | ||
|
||
// Assert | ||
Assert.AreEqual("Pending", statusObj.Name); | ||
} | ||
|
||
[TestMethod] | ||
public void Dispose() | ||
{ | ||
var service = new StatusService(_statusRepositoryMock); | ||
service.Dispose(); | ||
Assert.IsTrue(((StatusRepositoryMock)_statusRepositoryMock).Disposed); | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
DOL.WHD.Section14c.Test/RepositoryMocks/StatusRepositoryMock.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,40 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using DOL.WHD.Section14c.DataAccess; | ||
using DOL.WHD.Section14c.Domain.Models; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
|
||
namespace DOL.WHD.Section14c.Test.RepositoryMocks | ||
{ | ||
public class StatusRepositoryMock : IStatusRepository | ||
{ | ||
private bool _disposed; | ||
private readonly List<Status> _data; | ||
|
||
public bool Disposed => _disposed; | ||
|
||
public StatusRepositoryMock() | ||
{ | ||
_data = new List<Status> | ||
{ | ||
new Status {Id = StatusIds.Pending, Name = "Pending", IsActive = true}, | ||
new Status {Id = StatusIds.Issued, Name = "Issued", IsActive = true}, | ||
new Status {Id = StatusIds.Withdrawn, Name = "Withdrawn", IsActive = true}, | ||
new Status {Id = StatusIds.Amending, Name = "Amending", IsActive = true}, | ||
new Status {Id = StatusIds.Denied, Name = "Denied", IsActive = true}, | ||
new Status {Id = StatusIds.Revoked, Name = "Revoked", IsActive = true}, | ||
new Status {Id = StatusIds.Expired, Name = "Expired", IsActive = true} | ||
}; | ||
} | ||
|
||
public IQueryable<Status> Get() | ||
{ | ||
return _data.AsQueryable(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_disposed = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.