/// <summary> /// To delete existing card /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <bool> DeleteCard(DeleteCardDto dto) { var service = new CardService(); var res = await service.DeleteAsync(dto.CustomerId, dto.CardId); return(res.Deleted); }
public int DeleteCard(DeleteCardDto dto) { using (var db = new PGSBoardContext()) { var cardToRemove = db.Cards.Single(card => card.Id == dto.CardId); db.Cards.Remove(cardToRemove); return(db.SaveChanges() == 1 ? dto.CardId : 0); } }
public JsonResult DeleteCard(int cardId) { var deleteCardDto = new DeleteCardDto() { CardId = cardId }; var result = _boardsService.DeleteCard(deleteCardDto); return(new JsonResult() { Data = result }); }
public IActionResult DeleteCard([FromBody] DeleteCardDto deleteCardDto) { var userId = User.GetUserId(); var deletedCard = _cardService.DeleteCard(deleteCardDto, userId); if (deletedCard == null) { return(NotFound()); } return(Ok(deletedCard.Id)); }
public void ChangePositionCardBeforeDelete(DeleteCardDto dto) // reduce position cards after delete { using (var db = new PGSBoardContext()) { var cards = db.Cards.Where(card => card.ListId == dto.ListId || card.Id == dto.CardId).ToList(); var cardToDelete = cards.Single(card => card.Id == dto.CardId); var cardToUpdate = cards.Where(card => card.Id != dto.CardId && card.PositionCardId > cardToDelete.PositionCardId).ToList(); foreach (var card in cardToUpdate) { card.PositionCardId = card.PositionCardId - 1; } db.SaveChanges(); } }
public CardDto DeleteCard(DeleteCardDto deleteCardDto, string userId) { if (!_listRepository.IsOwner(deleteCardDto.ListId, userId)) { return(null); } var card = _cardRepository.GetCard(deleteCardDto.CardId); if (card == null) { return(null); } var deletedCard = _cardRepository.DeleteCard(card); var cardsWithPositionToUpdate = GetCardsWithPositionToDecrease(deletedCard.ListId, deletedCard.Position); _cardRepository.UpdateCardsPosition(cardsWithPositionToUpdate); var result = _mapper.Map <CardDto>(deletedCard); return(result); }
public int DeleteCard(DeleteCardDto dto) { this.boardsRepository.ChangePositionCardBeforeDelete(dto); return(this.boardsRepository.DeleteCard(dto)); }
public int DeleteCard(DeleteCardDto dto) { return(this.boardsRepository.DeleteCard(dto)); }