Drinks: models and boilerplate
This commit is contained in:
13
EstusShots.Shared/Dto/Drink.cs
Normal file
13
EstusShots.Shared/Dto/Drink.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace EstusShots.Shared.Dto
|
||||
{
|
||||
public class Drink
|
||||
{
|
||||
public Guid DrinkId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public double Vol { get; set; }
|
||||
}
|
||||
}
|
||||
30
EstusShots.Shared/Interfaces/IDrinksController.cs
Normal file
30
EstusShots.Shared/Interfaces/IDrinksController.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Threading.Tasks;
|
||||
using EstusShots.Shared.Models;
|
||||
using EstusShots.Shared.Models.Parameters;
|
||||
|
||||
namespace EstusShots.Shared.Interfaces
|
||||
{
|
||||
public interface IDrinksController
|
||||
{
|
||||
/// <summary>
|
||||
/// Load all drinks from the database
|
||||
/// </summary>
|
||||
/// <param name="parameter">An <see cref="GetDrinksParameter"/> instance</param>
|
||||
/// <returns>An ApiResponse instance of type <see cref="GetDrinksResponse"/></returns>
|
||||
Task<ApiResponse<GetDrinksResponse>> GetDrinks(GetDrinksParameter parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Load detailed information on a single drink
|
||||
/// </summary>
|
||||
/// <param name="parameter">An <see cref="GetDrinkDetailsParameter"/> instance</param>
|
||||
/// <returns>An ApiResponse instance of type <see cref="GetDrinkDetailsResponse"/></returns>
|
||||
Task<ApiResponse<GetDrinkDetailsResponse>> GetDrinkDetails(GetDrinkDetailsParameter parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Creates or Updates a drink object
|
||||
/// </summary>
|
||||
/// <param name="parameter">An <see cref="SaveDrinkParameter"/> instance</param>
|
||||
/// <returns>An ApiResponse instance of type <see cref="SaveDrinkResponse"/></returns>
|
||||
Task<ApiResponse<SaveDrinkResponse>> SaveDrink(SaveDrinkParameter parameter);
|
||||
}
|
||||
}
|
||||
129
EstusShots.Shared/Models/Parameters/DrinkParameters.cs
Normal file
129
EstusShots.Shared/Models/Parameters/DrinkParameters.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using EstusShots.Shared.Dto;
|
||||
using EstusShots.Shared.Interfaces;
|
||||
|
||||
namespace EstusShots.Shared.Models.Parameters
|
||||
{
|
||||
# region GetDrinks
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class for the GetDrinks API controller.
|
||||
/// </summary>
|
||||
public class GetDrinksParameter : IApiParameter
|
||||
{
|
||||
public GetDrinksParameter()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class returned from the GetDrinks API controller.
|
||||
/// </summary>
|
||||
public class GetDrinksResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// List of all drinks in the database
|
||||
/// </summary>
|
||||
public List<Drink> Drinks { get; set; }
|
||||
|
||||
public GetDrinksResponse(List<Drink> drinks)
|
||||
{
|
||||
Drinks = drinks;
|
||||
}
|
||||
|
||||
public GetDrinksResponse()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
# endregion
|
||||
|
||||
# region GetDrinkDetails
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class for the GetDrinkDetails API controller.
|
||||
/// </summary>
|
||||
public class GetDrinkDetailsParameter : IApiParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// ID of the drink for which to load details
|
||||
/// </summary>
|
||||
public Guid DrinkId { get; set; }
|
||||
|
||||
public GetDrinkDetailsParameter(Guid drinkId)
|
||||
{
|
||||
DrinkId = drinkId;
|
||||
}
|
||||
|
||||
public GetDrinkDetailsParameter()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class returned from the GetDrinkDetails API controller.
|
||||
/// </summary>
|
||||
public class GetDrinkDetailsResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Detailed information on a drink
|
||||
/// </summary>
|
||||
public Drink Drink { get; set; }
|
||||
|
||||
public GetDrinkDetailsResponse(Drink drink)
|
||||
{
|
||||
Drink = drink;
|
||||
}
|
||||
|
||||
public GetDrinkDetailsResponse()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
# endregion
|
||||
|
||||
# region SaveDrink
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class for the SaveDrink API controller.
|
||||
/// </summary>
|
||||
public class SaveDrinkParameter : IApiParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// The object to save in the database
|
||||
/// </summary>
|
||||
public Drink Drink { get; set; }
|
||||
|
||||
public SaveDrinkParameter(Drink drink)
|
||||
{
|
||||
Drink = drink;
|
||||
}
|
||||
|
||||
public SaveDrinkParameter()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter class returned from the SaveDrink API controller.
|
||||
/// </summary>
|
||||
public class SaveDrinkResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// ID of the created or updated drink object
|
||||
/// </summary>
|
||||
public Guid DrinkId { get; set; }
|
||||
|
||||
public SaveDrinkResponse(Guid drinkId)
|
||||
{
|
||||
DrinkId = drinkId;
|
||||
}
|
||||
|
||||
public SaveDrinkResponse()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
# endregion
|
||||
}
|
||||
Reference in New Issue
Block a user