public async Task<Guid> Handle(UpdateFieldCommand request, CancellationToken cancellationToken)
 {
     var entity = await _context.Fields.FindAsync(request.Id);
     if (entity == null)
         throw new NotFoundException(nameof(Field), request.Id);
     var mappedEntity = _mapper.Map<UpdateFieldCommand, Field>(request);
     mappedEntity.CatalogId = entity.CatalogId;
     _context.UpdateEntity(entity, mappedEntity);
     await _context.SaveChangesAsync(cancellationToken);
     return entity.Id;
 }
예제 #2
0
        public async Task <Guid> Handle(UpdateCatalogCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Catalogs.FindAsync(request.Id);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Catalog), request.Id);
            }
            var mappedEntity = _mapper.Map <UpdateCatalogCommand, Catalog>(request);

            _context.UpdateEntity(entity, mappedEntity);
            await _context.SaveChangesAsync(cancellationToken);

            return(entity.Id);
        }