Beispiel #1
0
        public async Task <ActionResult <Battery> > Put(int accountId, [FromBody] Battery battery)
        {
            try
            {
                Guard.AgainstAccountNumberMismatch(GetAccountIdClaim(), accountId.ToString(), "userClaim.accountId", "accountId");
                var result = await _batteryService.UpdateBatteryAsync(accountId, battery);

                return(Ok(result));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest("Error with input battery"));
            }
            catch (AccountConflictException)
            {
                return(Forbid());
            }
            catch (Exception)
            {
                return(BadRequest($"Error updating battery"));
            }
        }