Skip to content

Commit 2b46cc2

Browse files
committed
Added more information to application queries
1 parent a45563b commit 2b46cc2

File tree

11 files changed

+63
-8
lines changed

11 files changed

+63
-8
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
using System.Text;
3+
using DotNetCqs;
4+
5+
namespace Coderr.Server.Api.Core.Accounts.Queries
6+
{
7+
public class ListAccounts : Query<ListAccountsResult>
8+
{
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Coderr.Server.Api.Core.Accounts.Queries
2+
{
3+
public class ListAccountsResult
4+
{
5+
public ListAccountsResultItem[] Accounts { get; set; }
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace Coderr.Server.Api.Core.Accounts.Queries
4+
{
5+
public class ListAccountsResultItem
6+
{
7+
public int AccountId { get; set; }
8+
public string UserName { get; set; }
9+
public string Email { get; set; }
10+
public DateTime CreatedAtUtc { get; set; }
11+
}
12+
}

src/Server/Coderr.Server.Api/Core/Applications/ApplicationListItem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@ protected ApplicationListItem()
4343
/// User that requested this list is the admin of the specified application.
4444
/// </summary>
4545
public bool IsAdmin { get; set; }
46+
47+
/// <summary>
48+
/// Number of full time developers.
49+
/// </summary>
50+
public decimal NumberOfDevelopers { get; set; }
4651
}
4752
}

src/Server/Coderr.Server.Api/Core/Incidents/Commands/AssignIncident.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,10 @@ public AssignIncident(int incidentId, int assignedTo, int assignedBy)
3939
/// Incident being assigned.
4040
/// </summary>
4141
public int IncidentId { get; private set; }
42+
43+
/// <summary>
44+
/// Optionally specify when the incident was assigned. Default = now.
45+
/// </summary>
46+
public DateTime? AssignedAtUtc { get; set; }
4247
}
4348
}

src/Server/Coderr.Server.Api/Core/Incidents/Commands/CloseIncident.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ protected CloseIncident()
6969
/// <para>Need to be named "UserId" so that the CQS mapper can add the logged in user id</para>
7070
/// </remarks>
7171
public int UserId { get; set; }
72+
73+
/// <summary>
74+
/// When incident was closed (optional, "now" will be used when not specified)
75+
/// </summary>
76+
public DateTime? ClosedAtUtc { get; set; }
7277
}
7378
}

src/Server/Coderr.Server.App/Core/Applications/QueryHandlers/GetMyApplications.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ public async Task<ApplicationListItem[]> HandleAsync(IMessageContext context, Ge
6060
var apps = await _applicationRepository.GetForUserAsync(query.AccountId);
6161
result = (
6262
from x in apps
63-
select new ApplicationListItem(x.ApplicationId, x.ApplicationName) { IsAdmin = x.IsAdmin }
63+
select new ApplicationListItem(x.ApplicationId, x.ApplicationName)
64+
{
65+
IsAdmin = x.IsAdmin,
66+
NumberOfDevelopers = x.NumberOfDevelopers
67+
}
6468
).ToArray();
6569
}
6670
else

src/Server/Coderr.Server.App/Core/Incidents/Commands/AssignIncidentHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task HandleAsync(IMessageContext context, AssignIncident message)
2828
assignedBy = context.Principal.GetAccountId();
2929

3030
var incident = await _repository.GetAsync(message.IncidentId);
31-
incident.Assign(message.AssignedTo);
31+
incident.Assign(message.AssignedTo, message.AssignedAtUtc);
3232
await _repository.UpdateAsync(incident);
3333

3434
var evt = new IncidentAssigned(message.IncidentId, assignedBy, message.AssignedTo);

src/Server/Coderr.Server.Domain/Core/Applications/UserApplication.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ public class UserApplication
1919
/// If the user that this app is requested for is the admin
2020
/// </summary>
2121
public bool IsAdmin { get; set; }
22+
23+
/// <summary>
24+
/// Number of full time developers.
25+
/// </summary>
26+
public decimal NumberOfDevelopers { get; set; }
2227
}
2328
}

src/Server/Coderr.Server.Domain/Core/Incidents/Incident.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ public string Description
154154
/// Assign this incident to someone.
155155
/// </summary>
156156
/// <param name="userId">User to assign to</param>
157-
public void Assign(int userId)
157+
public void Assign(int userId, DateTime? when = null)
158158
{
159159
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
160160
AssignedAtUtc = DateTime.UtcNow;
161161
AssignedToId = userId;
162-
UpdatedAtUtc = DateTime.UtcNow;
162+
UpdatedAtUtc = when ?? DateTime.UtcNow;
163163
State = IncidentState.Active;
164164
}
165165

@@ -168,16 +168,17 @@ public void Assign(int userId)
168168
/// </summary>
169169
/// <param name="solvedBy">AccountId for whoever wrote the solution</param>
170170
/// <param name="solution">Actual solution</param>
171+
/// <param name="when">When was the incident closed by the user?</param>
171172
/// <exception cref="ArgumentNullException">solution</exception>
172173
/// <exception cref="ArgumentOutOfRangeException">solvedBy</exception>
173-
public void Close(int solvedBy, string solution)
174+
public void Close(int solvedBy, string solution, DateTime? when = null)
174175
{
175176
if (solution == null) throw new ArgumentNullException("solution");
176177
if (solvedBy <= 0) throw new ArgumentOutOfRangeException("solvedBy");
177178

178179
Solution = new IncidentSolution(solvedBy, solution);
179180
UpdatedAtUtc = DateTime.UtcNow;
180-
SolvedAtUtc = DateTime.UtcNow;
181+
SolvedAtUtc = when ?? DateTime.UtcNow;
181182
State = IncidentState.Closed;
182183
}
183184

0 commit comments

Comments
 (0)