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; } }
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()); }
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 } }
public async Task <int> DeleteAsync(int id) { return(await VehicleModelRepository.DeleteAsync(id)); }
public async Task DeleteModelAsync(int id) { var vehicle = await _modelRepository.GetModelByIdAsync(id); await _modelRepository.DeleteAsync(vehicle); }
public Task DeleteModelAsync(VehicleModel model) { return(_modelRepository.DeleteAsync(model)); }
public Task DeleteAsync(TDto dto) => _repository.DeleteAsync(_mapper.Map <TModel>(dto), m => m.Id.Equals(dto.Id));