SES-148 Endpointy dla Armor i Weapon #71
@ -97,5 +97,26 @@ namespace SessionCompanion.Controllers
|
||||
return new ErrorResponse() { StatusCode = 500, Message = e.Message };
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Metoda dodaje Weapon do danej postaci
|
||||
/// </summary>
|
||||
/// <param name="characterWeaponViewModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("addWeapon")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||
try
|
||||
{
|
||||
await _characterWeaponService.Create(characterWeaponViewModel);
|
||||
await _characterWeaponService.SaveAsync();
|
||||
return new SuccessResponse("Weapon added to character") { SuccessCode = 200 };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse() { StatusCode = 500, Message = e.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user