public async Task <IActionResult> Insert([FromBody] System.Text.Json.JsonElement value) { try { Deck deck = JsonConvert.DeserializeObject <Deck>(value.GetRawText()); await deckRepository.Insert(deck); await userDeckRepository.Insert( new UserDeck { User_Id = Guid.Parse(deck.Author), Deck_Id = deck.Deck_Id }); deckRepository.Save(); logger.LogInformation("------------> Deck/s have been added <------------"); return(Ok()); } catch (Exception ex) { logger.LogWarning("------------> An error has occurred <------------ \n" + ex.Message); return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Subscribe(string deckId, string userId) { try { var content = new UserDeck { Deck_Id = Guid.Parse(deckId), User_Id = Guid.Parse(userId), }; await db.Insert(content); db.Save(); logger.LogInformation("------------> Userdeck/s have been added <------------"); return(Ok()); } catch (Exception ex) { logger.LogWarning("------------> An error has occurred <------------ \n" + ex.Message); return(BadRequest(ex.Message)); } }