SES-148 Add Endpoint to add new weapon to character
This commit is contained in:
parent
8a7c50b307
commit
3ca90663b2
@ -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