Example #1
0
        private async Task <ISingleResultDto <EntityDto> > MapeamentoClasseMonstro(CompleteCardInformationDto dto)
        {
            ISingleResult <Card> result;

            switch (dto.MonsterCardClass)
            {
            case MonsterCardClassEnum.Fusion:
                result = await _service.Incluir(Mapper.Map <FusionMonster>(dto));

                break;

            case MonsterCardClassEnum.Link:
                result = await _service.Incluir(Mapper.Map <LinkMonster>(dto));

                break;

            case MonsterCardClassEnum.Synchro:
                result = await _service.Incluir(Mapper.Map <SynchroMonster>(dto));

                break;

            case MonsterCardClassEnum.Xyz:
                result = await _service.Incluir(Mapper.Map <XyzMonster>(dto));

                break;

            default:
                result = await _service.Incluir(Mapper.Map <Card>(dto));

                break;
            }

            return(SingleResultDto(result));
        }
Example #2
0
        private async Task <ISingleResultDto <EntityDto> > MapeamentoTipoCartaTrap(CompleteCardInformationDto dto)
        {
            var evento = Mapper.Map <TrapCard>(dto);
            var result = await _service.Incluir(evento);

            var resultDto = new SingleResultDto <EntityDto>(result);

            resultDto.SetData(result, Mapper);
            return(resultDto);
        }
Example #3
0
        public async Task <ISingleResultDto <EntityDto> > Create(CompleteCardInformationDto dto)
        {
            var cardTypeOperation = dto.CardType switch
            {
                CardTypeEnum.Monster => await MapeamentoClasseMonstro(dto),
                CardTypeEnum.Spell => await MapeamentoTipoCartaSpell(dto),
                CardTypeEnum.Trap => await MapeamentoTipoCartaTrap(dto),
                _ => throw new NotImplementedException()
            };

            return(cardTypeOperation);
        }
Example #4
0
        public async Task <ISingleResultDto <EntityDto> > Update(string id, CompleteCardInformationDto dto)
        {
            var evento = Mapper.Map <Card>(dto);

            var result = await _service.Editar(id, evento);

            var resultDto = new SingleResultDto <EntityDto>(result);

            resultDto.SetData(result, Mapper);

            return(resultDto);
        }
Example #5
0
        public async Task <IActionResult> Update(string id, CompleteCardInformationDto cardIn)
        {
            var card = _cardService.Get(id);

            if (card == null)
            {
                return(NotFound());
            }

            var teste = await _cardService.Update(id, cardIn);

            return(Ok(teste));
        }
Example #6
0
        public async Task <ISingleResultDto <CompleteCardInformationDto> > GetById(string id)
        {
            var entity = await _service.GetById(id);

            try
            {
                CompleteCardInformationDto dto = Mapper.Map <CompleteCardInformation, CompleteCardInformationDto>(entity.Data);
                return(new SingleResultDto <CompleteCardInformationDto>(dto));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #7
0
        public async Task <IActionResult> Create(CompleteCardInformationDto card)
        {
            try
            {
                card.Id = "";
                var teste = await _cardService.Create(card);

                return(Ok(teste));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }