SES-148 Endpointy dla Armor i Weapon #71

Merged
s426134 merged 11 commits from SES-148 into dev 2021-01-14 16:45:05 +01:00
Showing only changes of commit 3ca90663b2 - Show all commits

View File

@ -97,5 +97,26 @@ namespace SessionCompanion.Controllers
return new ErrorResponse() { StatusCode = 500, Message = e.Message }; 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 };
}
}
} }
} }