public async Task <IActionResult> CreateCard([FromRoute] string tableID, [FromRoute] string listID, [FromBody] CreateCardData data) { if (string.IsNullOrEmpty(data.Title)) { return(BadRequest()); } Card newCard = new Card() { Title = data.Title, Description = data.Description }; if (!CardListCollection.AddCardToTable(new ObjectId(tableID), new ObjectId(listID), newCard)) { return(BadRequest()); } return(Ok(CardListCollection.FindOneList(new ObjectId(tableID), new ObjectId(listID)))); }
public async Task <IActionResult> DeleteCard([FromRoute] string tableID, [FromRoute] string listID, [FromRoute] int cardIndex) { if (cardIndex < 0 || cardIndex < 0) { return(BadRequest()); } CardList fromList = CardListCollection.FindListByTableAndId(new ObjectId(tableID), new ObjectId(listID)); if (fromList == null || fromList.Content.Count <= cardIndex) { return(BadRequest()); } fromList.Content.RemoveAt(cardIndex); if (!CardListCollection.UpdateContent(fromList)) { return(BadRequest()); } return(Ok(CardListCollection.FindOneList(new ObjectId(tableID), new ObjectId(listID)))); }