public async Task <CardViewModel> Handle(UpdateCardCommand request, CancellationToken cancellationToken)
        {
            var entity = new Card
            {
                Id          = request.Id,
                Description = request.Description,
                Synonmys    = request.Synonmys,
                Meaning     = request.Meaning,
                Chapter     = request.Chapter,
                Verse       = request.Verse
            };

            var card = await _genericRepository.GetByIdAsync(request.Id);

            if (card == null)
            {
                throw new NotFoundException(nameof(Card), request.Id);
            }

            await _genericRepository.UpdateAsync(entity);

            _genericRepository.SaveChanges();

            return(_mapper.Map <CardViewModel>(entity));
        }
Ejemplo n.º 2
0
        public async Task <GroupViewModel> Handle(UpdateGroupCommand request, CancellationToken cancellationToken)
        {
            var entity = new Group
            {
                Id          = request.Id,
                Description = request.Description,
                Name        = request.Name
            };

            var card = await _genericRepository.GetByIdAsync(request.Id);

            if (card == null)
            {
                throw new NotFoundException(nameof(Group), request.Id);
            }

            await _genericRepository.UpdateAsync(entity);

            _genericRepository.SaveChanges();

            return(_mapper.Map <GroupViewModel>(entity));
        }
Ejemplo n.º 3
0
 public async Task <T> UpdateAsync(T entity)
 {
     return(await _GenericRepositoryAsync.UpdateAsync(entity));
 }