Example #1
0
        public IActionResult EditCard([FromBody] EditCardDto editCardDto)
        {
            var result = _cardService.EditCard(editCardDto);

            if (!result)
            {
                return(BadRequest());
            }

            return(NoContent());
        }
Example #2
0
        public bool EditCard(EditCardDto editCardDto)
        {
            var card = GetCard(editCardDto.Id);

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

            card.Name = editCardDto.Name;
            _context.Entry(card).State = EntityState.Modified;

            var result = _context.SaveChanges();

            return(result > 0);
        }
        public ViewResult Edit(int CardId)
        {
            var crd = deckService.GetCard(CardId);
            var dck = deckService.GetDeck(crd.DeckId);
            var ec  = new EditCardDto
            {
                DeckId    = dck.DeckId,
                DeckTitle = dck.Title,
                Front     = crd.Front,
                Back      = crd.Back,
                Level     = crd.Level,
                CardId    = CardId
            };

            return(View(ec));
        }
 public ActionResult Edit(EditCardDto editCardDto)
 {
     try
     {
         var updatedCard = deckService.GetCard(editCardDto.CardId);
         updatedCard.Front = editCardDto.Front;
         updatedCard.Back  = editCardDto.Back;
         //updatedCard = CodeRenderHelper.DecodeCardForCode(updatedCard);
         updatedCard.Level = editCardDto.Level;
         deckService.EditCard(updatedCard);
         return(RedirectToAction(nameof(View), new { CardId = updatedCard.CardId }));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }