コード例 #1
0
        public async Task DeleteModelAsync(int accountId, int id)
        {
            try
            {
                var modelToDelete = _modelRepository.GetById(id);
                Guard.AgainstNull(modelToDelete, "modelToDelete");
                Guard.AgainstAccountNumberMismatch(accountId, modelToDelete.AccountId, "accountId", "modelToDelete.AccountId");

                await _modelRepository.DeleteAsync(modelToDelete);

                _logger.LogInformation($"Deleted model with Id: {id}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error deleting model with Id: {id}");
                throw;
            }
        }
コード例 #2
0
        public async Task <IActionResult> Delete(int id)
        {
            Model existing = await modelRepository.FindByIdAsync(id);

            if (existing == null)
            {
                return(NotFound());
            }

            bool deleted = await modelRepository.DeleteAsync(existing);

            if (deleted)
            {
                return(new OkResult());
            }

            return(BadRequest());
        }
コード例 #3
0
        public override async void Execute(object parameter)
        {
            if (parameter is not PlaylistDto playlist)
            {
                return;
            }
            if (ShowConfirmDialog(playlist.Name) != MessageBoxResult.Yes)
            {
                return;
            }

            await _playlistRepository.DeleteAsync(playlist.Id);

            _playlistHolder.Playlists.Remove(playlist);
            if (_playlistHolder.SoundPlaylist == playlist)
            {
                _playlistHolder.SoundPlaylist = null;
            }
            if (_playlistHolder.UIPlaylist == playlist)
            {
                _playlistHolder.UIPlaylist = _playlistHolder.SoundPlaylist; // can be null. either there's no ui playlist or ui playlist = sound playlist
            }
        }
コード例 #4
0
 public async Task <int> DeleteAsync(int id)
 {
     return(await VehicleModelRepository.DeleteAsync(id));
 }
コード例 #5
0
        public async Task DeleteModelAsync(int id)
        {
            var vehicle = await _modelRepository.GetModelByIdAsync(id);

            await _modelRepository.DeleteAsync(vehicle);
        }
コード例 #6
0
 public Task DeleteModelAsync(VehicleModel model)
 {
     return(_modelRepository.DeleteAsync(model));
 }
コード例 #7
0
 public Task DeleteAsync(TDto dto) =>
 _repository.DeleteAsync(_mapper.Map <TModel>(dto), m => m.Id.Equals(dto.Id));