Skip to content

Commit a7c2aeb

Browse files
authored
Merge pull request #61 from GarageGroup/feature/task8431-update-timesheet
update timesheet
2 parents eac4920 + 5e2842e commit a7c2aeb

File tree

20 files changed

+104
-20
lines changed

20 files changed

+104
-20
lines changed

src/endpoint/Timesheet.Create/Flow/Flow.Run.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal static async ValueTask<Unit> RunAsync(
5454
}
5555

5656
var timesheet = GetWebAppUpdateResponseJson(context);
57-
if (timesheet is not null && timesheet.Command?.Equals("updatetimesheet") is true)
57+
if (string.Equals(timesheet?.Command, "updatetimesheet", StringComparison.InvariantCultureIgnoreCase))
5858
{
5959
await context.TurnContext.DeleteActivityAsync(context.TurnContext.Activity.Id, cancellationToken).ConfigureAwait(false);
6060
return starter;

src/endpoint/Timesheet.Create/Flow/TimesheetCreateChatFlow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static ChatFlow<TimesheetCreateFlowState> RunFlow(
1616
() => new()
1717
{
1818
TimesheetId = data?.Id,
19-
Description = data is null ? null : new(data.Description),
19+
Description = data is null ? null : data.Description is null ? null : new(data.Description),
2020
ValueHours = data?.Duration,
2121
Project = data?.Project,
2222
Date = data?.Date,

src/endpoint/Timesheet.Create/FlowStep/Step.ConfirmTimesheet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private static string BuildWebAppUrl(this TimesheetCreateFlowState state)
105105
{
106106
var timesheet = new WebAppDataTimesheetCreateJson
107107
{
108+
Id = state.TimesheetId,
108109
Description = state.Description?.Value.OrEmpty(),
109110
Duration = state.ValueHours.GetValueOrDefault(),
110111
Project = state.Project

src/endpoint/Timesheet.Create/Internal.Json/WebAppDataTimesheetCreateJson.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using Newtonsoft.Json;
2+
using System;
23

34
namespace GarageGroup.Internal.Timesheet;
45

56
internal readonly record struct WebAppDataTimesheetCreateJson
67
{
8+
[JsonProperty("id")]
9+
public Guid? Id { get; init; }
10+
711
[JsonProperty("duration")]
812
public decimal Duration { get; init; }
913

src/endpoint/Timesheet.Create/Internal.Json/WebAppDataTimesheetUpdateJson.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace GarageGroup.Internal.Timesheet;
77
internal sealed record class WebAppDataTimesheetUpdateJson
88
{
99
[JsonProperty("id")]
10-
public Guid Id { get; init; }
10+
public Guid? Id { get; init; }
1111

1212
[JsonProperty("duration")]
13-
public decimal Duration { get; init; }
13+
public decimal? Duration { get; init; }
1414

1515
[JsonProperty("project")]
1616
public TimesheetProjectState? Project { get; init; }

src/endpoint/Timesheet.Get/FlowState/TimesheetJson.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ internal sealed record class TimesheetJson
1616

1717
[JsonProperty("description")]
1818
public string? Description { get; init; }
19+
20+
[JsonProperty("incidentStateCode")]
21+
public StateCode? IncidentStateCode { get; init; }
22+
23+
[JsonProperty("timesheetStateCode")]
24+
public StateCode TimesheetStateCode { get; init; }
1925
}

src/service/CrmProject/Api/Api/Api.GetLast.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public ValueTask<Result<LastProjectSetGetOut, Failure<ProjectSetGetFailureCode>>
2222
[
2323
DbTimesheetProject.BuildOwnerFilter(@in.UserId),
2424
DbTimesheetProject.BuildMinDateFilter(@in.MinDate),
25-
AllowedProjectTypeSetFilter
25+
AllowedProjectTypeSetFilter,
26+
IncidentStateCodeFilter
2627
]
2728
},
2829
Orders = DbTimesheetProject.DefaultOrders

src/service/CrmProject/Api/Api/Api.Search.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public ValueTask<Result<ProjectSetSearchOut, Failure<ProjectSetGetFailureCode>>>
1717
static @in => new($"*{@in.SearchText}*")
1818
{
1919
Top = @in.Top,
20-
Entities = DataverseProjectSearch.EntityNames
20+
Entities = DataverseProjectSearch.EntityNames,
21+
Filter = DataverseProjectSearch.Filter
2122
})
2223
.PipeValue(
2324
dataverseApi.Impersonate(input.UserId).SearchAsync)

src/service/CrmProject/Api/Api/CrmProjectApi.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ namespace GarageGroup.Internal.Timesheet;
77

88
internal sealed partial class CrmProjectApi(TDataverseApi dataverseApi, TSqlApi sqlApi) : ICrmProjectApi
99
{
10-
private static readonly IDbFilter AllowedProjectTypeSetFilter;
10+
private static readonly DbParameterArrayFilter AllowedProjectTypeSetFilter;
11+
12+
private static readonly DbRawFilter IncidentStateCodeFilter;
1113

1214
static CrmProjectApi()
13-
=>
15+
{
1416
AllowedProjectTypeSetFilter = DbTimesheetProject.BuildAllowedProjectTypeSetFilter();
17+
IncidentStateCodeFilter = DbTimesheetProject.BuildIncidentStateCodeFilter();
18+
}
1519
}

src/service/CrmProject/Api/Internal.DataverseProjectSearch/DataverseProjectSearch.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
internal static partial class DataverseProjectSearch
44
{
5+
internal static readonly string Filter
6+
=
7+
$"objecttypecode ne {TimesheetProjectType.Incident:D} or statecode eq 0";
8+
59
private const string ProjectEntityName = "gg_project";
610

711
private const string LeadEntityName = "lead";

0 commit comments

Comments
 (0)