SES-154 Add Reqired fields in EquiplmentController

This commit is contained in:
Karol Górzyński 2021-01-20 19:57:41 +01:00
parent 0b29aca44d
commit f7dc48b008

View File

@ -12,6 +12,7 @@ namespace SessionCompanion.Controllers
using SessionCompanion.ViewModels.CharacterArmorViewModels;
using SessionCompanion.ViewModels.CharacterOtherEquipmentViewModels;
using SessionCompanion.ViewModels.CharacterWeaponViewModels;
using System.ComponentModel.DataAnnotations;
[Route("api/character/equipment")]
[ApiController]
@ -38,7 +39,7 @@ namespace SessionCompanion.Controllers
/// <param name="characterId"> Id postaci </param>
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
[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);
}
@ -49,7 +50,7 @@ namespace SessionCompanion.Controllers
/// <param name="characterId"> Id postaci </param>
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
[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);
}
@ -60,7 +61,7 @@ namespace SessionCompanion.Controllers
/// <param name="characterId"> Id postaci </param>
/// <returns> Lista broni lub błąd </returns>
[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);
}
@ -72,7 +73,7 @@ namespace SessionCompanion.Controllers
/// <param name="newArmorId"> Id nowej zbroi </param>
/// <returns>SuccessResponse/ErrorResponse</returns>
[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);
return response;
@ -84,7 +85,7 @@ namespace SessionCompanion.Controllers
/// <param name="characterArmorViewModel"> View model z odpowiednimi parameterami </param>
/// <returns>SuccessResponse/ErrorResponse</returns>
[HttpPut("addArmor")]
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor(CharacterArmorViewModel characterArmorViewModel)
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor([Required] CharacterArmorViewModel characterArmorViewModel)
{
if (!ModelState.IsValid)
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
@ -106,7 +107,7 @@ namespace SessionCompanion.Controllers
/// <param name="characterWeaponViewModel"> View model z odpowiednimi parameterami </param>
/// <returns>SuccessResponse/ErrorResponse</returns>
[HttpPut("addWeapon")]
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
{
if (!ModelState.IsValid)
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
@ -127,7 +128,7 @@ namespace SessionCompanion.Controllers
/// <param name=characterWeaponViewModel> View model z odpowiednimi parameterami </param>
/// <returns>SuccessResponse/ErrorResponse</returns>
[HttpPut("changeWeapon")]
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
{
if (!ModelState.IsValid)
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };