Example #1
0
        public async Task <ActionResult> Delete(int accountId, int id)
        {
            try
            {
                Guard.AgainstAccountNumberMismatch(GetAccountIdClaim(), accountId.ToString(), "userClaim.accountId", "accountId");
                await _batteryService.DeleteBatteryAsync(accountId, id);

                return(Ok());
            }
            catch (BatteryNotFoundException)
            {
                return(NotFound($"Error finding battery {id} to delete"));
            }
            catch (AccountConflictException)
            {
                return(Forbid());
            }
            catch (Exception)
            {
                return(Conflict($"Error deleting battery {id}"));
            }
        }