Player models and interfaces

This commit is contained in:
2020-02-29 21:12:26 +01:00
parent 3f5eea9d47
commit 1d39ae9537
7 changed files with 276 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
using System;
namespace EstusShots.Shared.Dto
{
public class Player
{
public Guid PlayerId { get; set; }
public string HexId { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public bool Anonymous { get; set; }
public string DisplayName => Anonymous ? Alias : Name;
}
}

View File

@@ -0,0 +1,40 @@
using System.Threading.Tasks;
using EstusShots.Shared.Models;
using EstusShots.Shared.Models.Parameters;
namespace EstusShots.Shared.Interfaces
{
/// <summary>
/// Load and manipulate player objects
/// </summary>
public interface IPlayersController
{
/// <summary>
/// Loads a list of all players in the database
/// </summary>
/// <param name="parameter">An <see cref="GetPlayersParameter"/> instance</param>
/// <returns>An ApiResponse instance of type <see cref="GetPlayersResponse"/></returns>
Task<ApiResponse<GetPlayersResponse>> GetPlayers(GetPlayersParameter parameter);
/// <summary>
/// Loads detailed information on a single player
/// </summary>
/// <param name="parameter">An <see cref="GetPlayerDetailsParameter"/> instance</param>
/// <returns>An ApiResponse instance of type <see cref="GetPlayerDetailsResponse"/></returns>
Task<ApiResponse<GetPlayerDetailsResponse>> GetPlayerDetails(GetPlayerDetailsParameter parameter);
/// <summary>
/// Creates or updates a player object
/// </summary>
/// <param name="parameter">An <see cref="SavePlayerParameter"/> instance</param>
/// <returns>An ApiResponse instance of type <see cref="SavePlayerResponse"/></returns>
Task<ApiResponse<SavePlayerResponse>> SavePlayer(SavePlayerParameter parameter);
/// <summary>
/// Deletes a player
/// </summary>
/// <param name="parameter">An <see cref="DeletePlayerParameter"/> instance</param>
/// <returns>An ApiResponse instance of type <see cref="DeletePlayerResponse"/></returns>
Task<ApiResponse<DeletePlayerResponse>> DeletePlayers(DeletePlayerParameter parameter);
}
}

View File

@@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using EstusShots.Shared.Dto;
using EstusShots.Shared.Interfaces;
namespace EstusShots.Shared.Models.Parameters
{
# region GetPlayers
/// <summary>
/// Parameter class for the GetPlayers API controller.
/// </summary>
public class GetPlayersParameter : IApiParameter
{
public GetPlayersParameter()
{
}
}
/// <summary>
/// Parameter class returned from the GetPlayers API controller.
/// </summary>
public class GetPlayersResponse : IApiResponse
{
/// <summary>
/// All players in the database
/// </summary>
public List<Player> Players { get; set; }
public GetPlayersResponse(List<Player> players)
{
Players = players;
}
public GetPlayersResponse()
{
}
}
# endregion
# region GetPlayerDetails
/// <summary>
/// Parameter class for the GetPlayerDetails API controller.
/// </summary>
public class GetPlayerDetailsParameter : IApiParameter
{
/// <summary>
/// ID of the player that should be loaded
/// </summary>
public Guid PlayerId { get; set; }
public GetPlayerDetailsParameter(Guid playerId)
{
PlayerId = playerId;
}
public GetPlayerDetailsParameter()
{
}
}
/// <summary>
/// Parameter class returned from the GetPlayerDetails API controller.
/// </summary>
public class GetPlayerDetailsResponse : IApiResponse
{
/// <summary>
/// The loaded player
/// </summary>
public Player Player { get; set; }
public GetPlayerDetailsResponse(Player player)
{
Player = player;
}
public GetPlayerDetailsResponse()
{
}
}
# endregion
# region SavePlayer
/// <summary>
/// Parameter class for the SavePlayer API controller.
/// </summary>
public class SavePlayerParameter : IApiParameter
{
/// <summary>
/// The player to save
/// </summary>
public Player Player { get; set; }
public SavePlayerParameter(Player player)
{
Player = player;
}
public SavePlayerParameter()
{
}
}
/// <summary>
/// Parameter class returned from the SavePlayer API controller.
/// </summary>
public class SavePlayerResponse : IApiResponse
{
/// <summary>
/// ID of the newly created or updated player
/// </summary>
public Guid PlayerId { get; set; }
public SavePlayerResponse(Guid playerId)
{
PlayerId = playerId;
}
public SavePlayerResponse()
{
}
}
# endregion
# region DeletePlayer
/// <summary>
/// Parameter class for the DeletePlayer API controller.
/// </summary>
public class DeletePlayerParameter : IApiParameter
{
/// <summary>
/// ID of the player that should be deleted
/// </summary>
public Guid PlayerId { get; set; }
public DeletePlayerParameter(Guid playerId)
{
PlayerId = playerId;
}
public DeletePlayerParameter()
{
}
}
/// <summary>
/// Parameter class returned from the DeletePlayer API controller.
/// </summary>
public class DeletePlayerResponse : IApiResponse
{
public DeletePlayerResponse()
{
}
}
# endregion
}