Esempio n. 1
0
        public async Task <ActionResult <Battery> > Post(int accountId, [FromBody] Battery newBattery)
        {
            try
            {
                Guard.AgainstAccountNumberMismatch(GetAccountIdClaim(), accountId.ToString(), "userClaim.accountId", "accountId");
                var result = await _batteryService.EnterNewBatteryAsync(accountId, newBattery);

                return(Ok(result));
            }
            catch (AccountConflictException)
            {
                return(Forbid());
            }
            catch (Exception)
            {
                return(BadRequest("Error adding battery"));
            }
        }