/// <summary> /// Delete a movement by Id /// </summary> /// <param name="id"></param> public async Task Delete(int id) { var movement = await GetById(id); await _repository.Remove(movement); if (movement.MovementStatus.Equals(MovementStatus.Launched)) { await _accountService.AdjustBalance(movement.AccountId); } }
public void Delete(int id) { var movement = Get(id); if (movement.CanEdit) { _repository.Remove(movement); if (IsLaunched(movement)) { _accountService.AdjustBalance(movement.AccountId); } } else { throw new Exceptions.InvalidOperationException("This movement was generated by another routine and can not be changed"); } }