Untitled

 avatar
unknown
csharp
a year ago
537 B
4
Indexable
        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
Editor is loading...
Leave a Comment