private void CreateBoggleBoxInDb(BoggleBox boggleBox) { var board = new Board() { BoggleBoxId = boggleBox.BoggleBoxId, Letters = boggleBox.Dice.GetLetters() }; using (var context = new BoggleDbContext()) { // Checks if board already exist if (context.Board.Count(b => b.BoggleBoxId == boggleBox.BoggleBoxId) != 0) { return; } try { context.Board.Add(board); context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public BoggleBox GetBoggleBox(string boggleBoxId) { BoggleBox foundBox = RegisteredBoggleBoxes.Find(x => x.BoggleBoxID.ToString() == boggleBoxId); if (foundBox == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(foundBox); }
public BoggleBox GetBoggleBox() { BoggleBox newBox = new BoggleBox(); newBox.BoggleBoxID = Guid.NewGuid(); newBox.Dies = randomDices(); RegisteredBoggleBoxes.Add(newBox); return(newBox); }
public BoggleBox GetBoggleBox(Guid boggleBoxId) { var board = GetBoardById(boggleBoxId); var boggleBox = new BoggleBox { BoggleBoxId = board.BoggleBoxId, Dice = board.Letters.ConvertLettersToDice() }; return(boggleBox); }
public BoggleBox CreateBoggleBox() { var boggleBox = new BoggleBox { BoggleBoxId = Guid.NewGuid(), Dice = GetDice() }; CreateBoggleBoxInDb(boggleBox); return(boggleBox); }
public bool IsValidWord(string boggleBoxId, string word) { BoggleBox foundBox = RegisteredBoggleBoxes.Find(x => x.BoggleBoxID.ToString() == boggleBoxId); if (foundBox == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (WordList.Contains(word.ToLower())) { return(true); } return(false); }