public async Task <int> Handle(CreateElement request, CancellationToken cancellationToken)
        {
            request.Element.Id = 0;
            var entry = await _context.Elements.AddAsync(request.Element, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(entry.Entity.Id);
        }
Ejemplo n.º 2
0
 protected override async Task Handle(DeleteElement request, CancellationToken cancellationToken)
 {
     _context.Elements.Remove(await _context.Elements.FindAsync(request.ElementId));
     await _context.SaveChangesAsync(cancellationToken);
 }