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> CreateCard([FromRoute] string tableID, [FromRoute] string listID, [FromRoute] int cardIndex, [FromBody] CreateCardData data) { if (string.IsNullOrEmpty(data.Title)) { return(BadRequest()); } CardList list = CardListCollection.FindListByTableAndId(new ObjectId(tableID), new ObjectId(listID)); list.Content[cardIndex] = new Card() { Title = data.Title, Description = data.Description }; if (!CardListCollection.UpdateContent(list)) { return(BadRequest()); } return(Ok(list)); }