Example #1
0
        public IActionResult Upload([FromForm] IFormFile image, [FromForm] string predictionText, [FromForm] int difficulty)
        {
            // TODO: Santitize input from client

            // TODO: check if board does not exist, do not hardcode new board
            var board = boardsRepository.AddWithObjectReturn(new Board
            {
                Seed      = shortenerService.GenerateUniqueShortPhrase(),
                CreatedBy = "Test User" // TODO: Implement this
            });

            var prediction = new Prediction
            {
                PredictionText = predictionText,
                Difficulty     = difficulty,
                ImageUri       = Upload(image),
                CreatedBy      = "Test User", // TODO: implement this
                BoardId        = board.Id,
                CardId         = null         // explicit, not assigned to a card until a card is generated with it
            };

            if (predictionsRepository.Add(prediction))
            {
                return(Ok(prediction));
            }

            // on this create page (without a board id) first, create the board
            // then, add the prediction to the board

            return(BadRequest());
        }
Example #2
0
 public void TestShortener()
 {
     Shortener.GenerateUniqueShortPhrase();
     Assert.Pass();
 }