Skip to content

Commit 343597a

Browse files
committed
converting into a record struct
1 parent 985df9a commit 343597a

File tree

7 files changed

+8
-37
lines changed

7 files changed

+8
-37
lines changed

Intersect.Server/Web/RestApi/Routes/V1/UserController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public IActionResult ChangePassword(LookupKey lookupKey, [FromBody] AdminChangeR
416416
return BadRequest(lookupKey.IsIdInvalid ? @"Invalid user id." : @"Invalid username.");
417417
}
418418

419-
if (!authorizedChange.IsValid)
419+
if (!string.IsNullOrEmpty(authorizedChange.New))
420420
{
421421
return BadRequest(@"Invalid payload");
422422
}
@@ -447,7 +447,7 @@ public IActionResult UserChangePassword(LookupKey lookupKey, [FromBody] Authoriz
447447
return BadRequest(lookupKey.IsIdInvalid ? @"Invalid user id." : @"Invalid username.");
448448
}
449449

450-
if (!authorizedChange.IsValid)
450+
if (!string.IsNullOrWhiteSpace(authorizedChange.Authorization) && !string.IsNullOrWhiteSpace(authorizedChange.New))
451451
{
452452
return BadRequest(@"Invalid payload");
453453
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
namespace Intersect.Server.Web.RestApi.Types;
22

3-
public partial struct IdPayload(Guid id)
4-
{
5-
public Guid Id { get; set; } = id;
6-
}
3+
public record struct IdPayload(Guid Id);

Intersect.Server/Web/RestApi/Types/Logs/IpAddressResponseBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ public partial class IpAddressResponseBody
66

77
public DateTime LastUsed { get; set; }
88

9-
public Dictionary<Guid, string> OtherUsers { get; set; } = new Dictionary<Guid, string>();
9+
public Dictionary<Guid, string> OtherUsers { get; set; } = [];
1010
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
namespace Intersect.Server.Web.RestApi.Types.Player;
22

3-
public partial struct LevelChangeRequestBody
4-
{
5-
public int Level { get; set; }
6-
}
3+
public record struct LevelChangeRequestBody(int Level);
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
using System.ComponentModel.DataAnnotations.Schema;
2-
using Newtonsoft.Json;
3-
41
namespace Intersect.Server.Web.RestApi.Types.User;
52

6-
public partial struct AdminChangeRequestBody
7-
{
8-
[JsonIgnore, NotMapped]
9-
public bool IsValid => !string.IsNullOrWhiteSpace(New);
10-
11-
public string New { get; set; }
12-
}
3+
public record struct AdminChangeRequestBody(string New);
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
using System.ComponentModel.DataAnnotations.Schema;
2-
using Newtonsoft.Json;
3-
41
namespace Intersect.Server.Web.RestApi.Types.User;
52

6-
public partial struct AuthorizedChangeRequestBody
7-
{
8-
[JsonIgnore, NotMapped]
9-
public bool IsValid => !string.IsNullOrWhiteSpace(Authorization) && !string.IsNullOrWhiteSpace(New);
10-
11-
public string Authorization { get; set; }
12-
13-
public string New { get; set; }
14-
}
3+
public record struct AuthorizedChangeRequestBody(string Authorization, string New);
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
namespace Intersect.Server.Web.RestApi.Types.User;
22

3-
public partial struct PasswordValidationRequestBody(string password)
4-
{
5-
public string Password { get; set; } = password;
6-
}
3+
public record struct PasswordValidationRequestBody(string Password);

0 commit comments

Comments
 (0)