| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="NoOpCrudService.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Collections.Generic; |
| | | 8 | | using System.Threading; |
| | | 9 | | using System.Threading.Tasks; |
| | | 10 | | |
| | | 11 | | namespace MyNet.UI.ViewModels.List.Services; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Default no-op implementation for <see cref="ICrudService{T}"/>. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <typeparam name="T">The item type.</typeparam> |
| | | 17 | | public sealed class NoOpCrudService<T> : ICrudService<T> |
| | | 18 | | where T : notnull |
| | | 19 | | { |
| | | 20 | | /// <inheritdoc /> |
| | 0 | 21 | | public Task<T?> GetAsync(T item, CancellationToken cancellationToken = default) => Task.FromResult<T?>(item); |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | 0 | 24 | | public Task<T?> CreateAsync(CancellationToken cancellationToken = default) => Task.FromResult<T?>(default); |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | 0 | 27 | | public Task<bool> UpdateAsync(T item, CancellationToken cancellationToken = default) => Task.FromResult(true); |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | 0 | 30 | | public Task<bool> DeleteAsync(T item, CancellationToken cancellationToken = default) => Task.FromResult(true); |
| | | 31 | | |
| | | 32 | | /// <inheritdoc /> |
| | 0 | 33 | | public Task<bool> DeleteRangeAsync(IEnumerable<T> items, CancellationToken cancellationToken = default) => Task.From |
| | | 34 | | } |
| | | 35 | | |