SES-154 Add Reqired fields in EquiplmentController
This commit is contained in:
parent
0b29aca44d
commit
f7dc48b008
@ -12,6 +12,7 @@ namespace SessionCompanion.Controllers
|
|||||||
using SessionCompanion.ViewModels.CharacterArmorViewModels;
|
using SessionCompanion.ViewModels.CharacterArmorViewModels;
|
||||||
using SessionCompanion.ViewModels.CharacterOtherEquipmentViewModels;
|
using SessionCompanion.ViewModels.CharacterOtherEquipmentViewModels;
|
||||||
using SessionCompanion.ViewModels.CharacterWeaponViewModels;
|
using SessionCompanion.ViewModels.CharacterWeaponViewModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
[Route("api/character/equipment")]
|
[Route("api/character/equipment")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@ -38,7 +39,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="characterId"> Id postaci </param>
|
/// <param name="characterId"> Id postaci </param>
|
||||||
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
||||||
[HttpGet("getOtherEquipment")]
|
[HttpGet("getOtherEquipment")]
|
||||||
public async Task<Either<List<CharacterOtherEquipmentWithDetailsViewModel>, ErrorResponse>> GetCharacterOtherEquipment(int characterId)
|
public async Task<Either<List<CharacterOtherEquipmentWithDetailsViewModel>, ErrorResponse>> GetCharacterOtherEquipment([Required] int characterId)
|
||||||
{
|
{
|
||||||
return await this._characterOtherEquipmentService.GetCharacterOtherEquipmentList(characterId);
|
return await this._characterOtherEquipmentService.GetCharacterOtherEquipmentList(characterId);
|
||||||
}
|
}
|
||||||
@ -49,7 +50,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="characterId"> Id postaci </param>
|
/// <param name="characterId"> Id postaci </param>
|
||||||
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
||||||
[HttpGet("getArmors")]
|
[HttpGet("getArmors")]
|
||||||
public async Task<Either<List<CharacterArmorViewModelDetails>, ErrorResponse>> GetCharacterArmors(int characterId)
|
public async Task<Either<List<CharacterArmorViewModelDetails>, ErrorResponse>> GetCharacterArmors([Required] int characterId)
|
||||||
{
|
{
|
||||||
return await this._characterArmorService.GetCharacterArmorsTaskList(characterId);
|
return await this._characterArmorService.GetCharacterArmorsTaskList(characterId);
|
||||||
}
|
}
|
||||||
@ -60,7 +61,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="characterId"> Id postaci </param>
|
/// <param name="characterId"> Id postaci </param>
|
||||||
/// <returns> Lista broni lub błąd </returns>
|
/// <returns> Lista broni lub błąd </returns>
|
||||||
[HttpGet("getWeapons")]
|
[HttpGet("getWeapons")]
|
||||||
public async Task<Either<List<CharacterWeaponWithWeaponDetailsViewModel>, ErrorResponse>> GetCharacterWeapons(int characterId)
|
public async Task<Either<List<CharacterWeaponWithWeaponDetailsViewModel>, ErrorResponse>> GetCharacterWeapons([Required] int characterId)
|
||||||
{
|
{
|
||||||
return await this._characterWeaponService.GetCharacterWeaponsList(characterId);
|
return await this._characterWeaponService.GetCharacterWeaponsList(characterId);
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="newArmorId"> Id nowej zbroi </param>
|
/// <param name="newArmorId"> Id nowej zbroi </param>
|
||||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||||
[HttpPut("changeArmor")]
|
[HttpPut("changeArmor")]
|
||||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterArmor(int characterId, int newArmorId)
|
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterArmor([Required] int characterId, [Required] int newArmorId)
|
||||||
{
|
{
|
||||||
var response = await _characterArmorService.ChangeCharacterArmor(characterId, newArmorId);
|
var response = await _characterArmorService.ChangeCharacterArmor(characterId, newArmorId);
|
||||||
return response;
|
return response;
|
||||||
@ -84,7 +85,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="characterArmorViewModel"> View model z odpowiednimi parameterami </param>
|
/// <param name="characterArmorViewModel"> View model z odpowiednimi parameterami </param>
|
||||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||||
[HttpPut("addArmor")]
|
[HttpPut("addArmor")]
|
||||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor(CharacterArmorViewModel characterArmorViewModel)
|
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor([Required] CharacterArmorViewModel characterArmorViewModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||||
@ -106,7 +107,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name="characterWeaponViewModel"> View model z odpowiednimi parameterami </param>
|
/// <param name="characterWeaponViewModel"> View model z odpowiednimi parameterami </param>
|
||||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||||
[HttpPut("addWeapon")]
|
[HttpPut("addWeapon")]
|
||||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
|
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||||
@ -127,7 +128,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// <param name=characterWeaponViewModel> View model z odpowiednimi parameterami </param>
|
/// <param name=characterWeaponViewModel> View model z odpowiednimi parameterami </param>
|
||||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||||
[HttpPut("changeWeapon")]
|
[HttpPut("changeWeapon")]
|
||||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
|
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||||
|
Loading…
Reference in New Issue
Block a user