Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
537 B
1
Indexable
Never
        var repository = _context
            .Set<TEntity>();

        var entity = await repository
            .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken: cancellationToken);

        if (entity == null)
        {
            var notFound = new AppNotFoundException(typeof(TEntity).Name, $"no dataset with id '{request.Id}' found");
            return new Result<TEntity>(notFound);
        }

        _mapper.Map(request, entity);
        await _context.SaveChangesAsync(cancellationToken);
        return entity
Leave a Comment