-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
217 new admin endpoints: search user (#233)
Create an endpoint to search for user(s) based on their id, name, or email. --------- Co-authored-by: Omid Marfavi <[email protected]> Co-authored-by: Jonas Anker Rasmussen <[email protected]>
- Loading branch information
1 parent
ee7d26c
commit 46a9e66
Showing
11 changed files
with
761 additions
and
5 deletions.
There are no files selected for viewing
574 changes: 574 additions & 0 deletions
574
coffeecard/CoffeeCard.Library/Migrations/20240111163619_NewIndexName.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
coffeecard/CoffeeCard.Library/Migrations/20240111163619_NewIndexName.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,44 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace CoffeeCard.Library.Migrations | ||
{ | ||
public partial class NewIndexName : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AlterColumn<string>( | ||
name: "Name", | ||
schema: "dbo", | ||
table: "Users", | ||
type: "nvarchar(450)", | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(max)"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Users_Name", | ||
schema: "dbo", | ||
table: "Users", | ||
column: "Name"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropIndex( | ||
name: "IX_Users_Name", | ||
schema: "dbo", | ||
table: "Users"); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "Name", | ||
schema: "dbo", | ||
table: "Users", | ||
type: "nvarchar(max)", | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)"); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ namespace CoffeeCard.Models.DataTransferObjects.v2.User | |
/// "name": "John Doe", | ||
/// "email": "[email protected]", | ||
/// "password": "[no example provided]", | ||
/// "programme": 1 | ||
/// "programmeId": 1 | ||
/// } | ||
/// </example> | ||
public class RegisterAccountRequest | ||
|
13 changes: 13 additions & 0 deletions
13
coffeecard/CoffeeCard.Models/DataTransferObjects/v2/User/SimpleUserResponse.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,13 @@ | ||
using CoffeeCard.Models.Entities; | ||
|
||
namespace CoffeeCard.Models.DataTransferObjects.v2.User | ||
{ | ||
public class SimpleUserResponse | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public string Email { get; set; } | ||
public UserGroup UserGroup { get; set; } | ||
public UserState State { get; set; } | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
coffeecard/CoffeeCard.Models/DataTransferObjects/v2/User/UserSearchResponse.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,50 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace CoffeeCard.Models.DataTransferObjects.v2.User; | ||
|
||
/// <summary> | ||
/// Represents a search result | ||
/// </summary> | ||
/// <example> | ||
/// { | ||
/// "users": [ | ||
/// { | ||
/// "id": 12232, | ||
/// "name": "John Doe", | ||
/// "email": "[email protected]", | ||
/// "userGroup": "Barista", | ||
/// "state": "Active" | ||
/// } | ||
/// ], | ||
/// "totalUsers": 1 | ||
/// } | ||
/// </example> | ||
public class UserSearchResponse | ||
{ | ||
/// <summary> | ||
/// The number of users that match the query | ||
/// </summary> | ||
/// <value> Users number </value> | ||
/// <example>1</example> | ||
[Required] | ||
public int TotalUsers { get; set; } | ||
|
||
/// <summary> | ||
/// The users that match the query | ||
/// </summary> | ||
/// <value> Users List </value> | ||
/// <example> | ||
/// [ | ||
/// { | ||
/// "id": 12232, | ||
/// "name": "John Doe", | ||
/// "email": "[email protected]", | ||
/// "userGroup": "Barista", | ||
/// "state": "Active" | ||
/// } | ||
/// ], | ||
/// </example> | ||
[Required] | ||
public IEnumerable<SimpleUserResponse> Users; | ||
Check warning on line 49 in coffeecard/CoffeeCard.Models/DataTransferObjects/v2/User/UserSearchResponse.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
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