Skip to content

Commit 07ca30f

Browse files
authored
Add AppointmentFieldValue (#173)
1 parent cbf5ddf commit 07ca30f

File tree

8 files changed

+119
-13
lines changed

8 files changed

+119
-13
lines changed

src/core/Dime.Scheduler.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
<Description>The official .NET SDK for Dime.Scheduler.</Description>
2020
<Summary>A developer toolkit that connects any system to Dime.Scheduler in .NET</Summary>
2121
<PackageId>Dime.Scheduler</PackageId>
22-
<VersionPrefix>1.0.3</VersionPrefix>
23-
<AssemblyVersion>1.0.0.0</AssemblyVersion>
24-
<FileVersion>1.0.0.0</FileVersion>
22+
<VersionPrefix>1.0.4</VersionPrefix>
23+
<AssemblyVersion>1.0.4.0</AssemblyVersion>
24+
<FileVersion>1.0.4.0</FileVersion>
2525
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2626
<NoWarn>$(NoWarn);1591</NoWarn>
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="RestSharp" Version="110.2.0" />
30+
<PackageReference Include="RestSharp" Version="111.3.0" />
3131
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
32-
<PackageReference Include="System.Text.Json" Version="8.0.0" />
32+
<PackageReference Include="System.Text.Json" Version="8.0.4" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

src/core/Import/ImportProcedures.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ internal static class Uri
7979
internal static readonly string Append = $"{_base}{_append}{_entity}";
8080
internal static readonly string Delete = $"{_base}{_delete}{_entity}";
8181
}
82+
83+
internal static class FieldValue
84+
{
85+
private static readonly string _entity = "AppointmentFieldValues";
86+
87+
internal static readonly string Append = $"{_base}{_update}{_entity}";
88+
internal static readonly string Delete = $"{_base}{_delete}{_entity}";
89+
}
8290
}
8391

8492
internal static class Assignment
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace Dime.Scheduler.Entities
5+
{
6+
public class AppointmentFieldValue : IAppointmentIdentifier, IImportRequestable
7+
{
8+
/// <include file='docs.xml' path='docs/members[@name="TrackedEntity"]/SourceApp/*'/>
9+
[ImportParameter(nameof(SourceApp))]
10+
[MaxLength(30)]
11+
public string SourceApp { get; set; }
12+
13+
/// <include file='docs.xml' path='docs/members[@name="TrackedEntity"]/SourceType/*'/>
14+
[ImportParameter(nameof(SourceType))]
15+
[MaxLength(10)]
16+
public string SourceType { get; set; }
17+
18+
/// <include file='docs.xml' path='docs/members[@name="Appointment"]/AppointmentNo/*'/>
19+
public string AppointmentNo { get; set; }
20+
21+
/// <include file='docs.xml' path='docs/members[@name="Appointment"]/AppointmentGuid/*'/>
22+
[ImportParameter(nameof(AppointmentGuid))]
23+
public Guid? AppointmentGuid { get; set; }
24+
25+
/// <include file='docs.xml' path='docs/members[@name="Appointment"]/AppointmentId/*'/>
26+
[ImportParameter(nameof(AppointmentId))]
27+
public long? AppointmentId { get; set; }
28+
29+
[ImportParameter(nameof(FieldCode))]
30+
[MaxLength(100)]
31+
[Required]
32+
public string FieldCode { get; set; }
33+
34+
[ImportParameter(nameof(FieldValue))]
35+
[Required]
36+
public string FieldValue { get; set; }
37+
38+
[ImportParameter(nameof(SentFromBackOffice))]
39+
public bool SentFromBackOffice { get; set; } = true;
40+
41+
ImportRequest IImportRequestable.ToImportRequest(TransactionType transactionType)
42+
=> transactionType switch
43+
{
44+
TransactionType.Append => CreateAppendRequest(),
45+
TransactionType.Delete => CreateDeleteRequest(),
46+
_ => throw new ArgumentOutOfRangeException(nameof(transactionType), transactionType, null)
47+
};
48+
49+
private ImportRequest CreateAppendRequest()
50+
=> new(ImportProcedures.Appointment.FieldValue.Append, this.CreateParameters(TransactionType.Append));
51+
52+
private ImportRequest CreateDeleteRequest()
53+
=> throw new NotImplementedException("Action does not exist in Dime.Scheduler");
54+
}
55+
}

src/core/docs.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@
4545
The external identifier for this appointment.
4646
</summary>
4747
</AppointmentNo>
48-
</members>
48+
<AppointmentGuid>
49+
<summary>
50+
The identifier for this appointment.
51+
</summary>
52+
</AppointmentGuid>
53+
</members>
4954
<members name="Work">
5055
<JobNo>
5156
<summary>

src/test/Dime.Scheduler.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="coverlet.collector" Version="6.0.0">
9+
<PackageReference Include="coverlet.collector" Version="6.0.2">
1010
<PrivateAssets>all</PrivateAssets>
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
</PackageReference>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
14-
<PackageReference Include="xunit" Version="2.6.2" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
14+
<PackageReference Include="xunit" Version="2.9.0" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>

src/test/Import/ActionUriTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void ActionUri_ToImportRequest_Append_AllShouldMapParameters()
2222

2323
importRequest.AssertStoredProcedureName("mboc_upsertActionUrl");
2424
importRequest.AssertEqualParameterCollectionCount();
25-
importRequest.AssertParameterCount(6);
25+
importRequest.AssertParameterCount(7);
2626
}
2727

2828
[Fact]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using Dime.Scheduler.Entities;
3+
using Xunit;
4+
5+
namespace Dime.Scheduler.Tests.Import
6+
{
7+
public partial class AppointmentFieldValueTests
8+
{
9+
private static AppointmentFieldValue CreateModel()
10+
=> new()
11+
{
12+
AppointmentGuid = Guid.NewGuid(),
13+
AppointmentId = 1,
14+
SentFromBackOffice = true,
15+
SourceApp = "APP",
16+
SourceType = "TYPE",
17+
FieldCode = "ISCOMPLETE",
18+
FieldValue = "true"
19+
};
20+
21+
[Fact]
22+
public void AppointmentFieldValue_ToImportRequest_Append_AllShouldMapParameters()
23+
{
24+
AppointmentFieldValue model = CreateModel();
25+
26+
ImportRequest importRequest = model.ToImportRequest(TransactionType.Append);
27+
importRequest.AssertEqualParameterCollectionCount();
28+
}
29+
30+
[Fact]
31+
public void AppointmentFieldValue_ToImportRequest_Delete_ShouldThrowException()
32+
{
33+
AppointmentFieldValue model = CreateModel();
34+
35+
model.ShouldNotCreateImportRequest(TransactionType.Delete);
36+
}
37+
}
38+
}

src/test/Import/AppointmentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public void Appointment_ToImportRequest_Append_ShouldMapRequiredParameters()
9898

9999
ImportRequest importRequest = model.ToImportRequest(TransactionType.Append);
100100
importRequest.AssertEqualParameterCollectionCount();
101-
Assert.True(importRequest.ParameterNames.Length == 7);
102-
Assert.True(importRequest.ParameterValues.Length == 7);
101+
Assert.True(importRequest.ParameterNames.Length == 8);
102+
Assert.True(importRequest.ParameterValues.Length == 8);
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)