Exemplo n.º 1
0
 public async Task <IActionResult> UpdateCard([FromBody] WordCard wordCard)
 {
     try
     {
         return(Ok(await _cardsService.UpdateCard(wordCard)));
     }
     catch (Exception ex)
     {
         var errorMessage = "There was an error while trying to list Word Cards from MongoDB";
         return(BadRequest(errorMessage + "\n" + ex));
     }
 }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Put([FromBody] CardUpdateDTO cardDTO)
        {
            if (cardDTO == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Card card = cardDTO.ToCard();

            CardUpdateResultEnum result = await _cardsService.UpdateCard(card);

            return(Ok(result));
        }
        public async Task <IActionResult> Put(int id, CardsDto cardDto)
        {
            if (!User.Identity.IsAuthenticated)
            {
                throw new AuthenticationException();
            }
            var card = _mapper.Map <Cards>(cardDto);

            card.Id = id;
            var result = await _cardsService.UpdateCard(card);

            var response = new ApiResponse <bool>(result);

            return(Ok(response));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> UpdateCard(Contracts.Cards.UpdateCardRequest card)
        {
            try
            {
                var domainCard = new Core.Domain.UpdateCardRequest
                {
                    Id         = card.Id,
                    Name       = card.Name,
                    Properties = card.Properties.Select(p => new Core.Domain.Property
                    {
                        Name  = p.Name,
                        Value = p.Value
                    })
                };

                await cardsService.UpdateCard(domainCard);
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }

            return(NoContent());
        }