public object PersonPost(Person row) { var puzzlePass = false; WorkContext.NeedsSession(); if (WorkContext.Session!=null && row.Puzzle!=null) { var pk = WorkContext.Session["PersonPuzzle"] as PuzzleKeypad; if (pk!=null) { var answer = row.Puzzle["Answer"] as JSONDataArray; if (answer!=null) puzzlePass = pk.DecipherCoordinates(answer)==pk.Code; } } Exception error = null; if (puzzlePass) { row.YearsInService++; error = row.Validate(); } else error= new CRUDFieldValidationException("Person", "Puzzle", "Please answer the question correctly"); if (row.Puzzle!=null) row.Puzzle.Remove("Answer"); makePuzzle(); return new ClientRecord(row, error); }
public object PersonGet(JSONDataMap req) { makePuzzle(); var row = new Person{ ID = req!=null ? req["PersonID"].AsString("500") : null, FirstName = "Yuriy", LastName = "Gagarin", DOB = new DateTime(1980, 07, 05), Puzzle = new JSONDataMap{ {"Image", "/mvc/tester/captcha?key=PersonPuzzle"}, {"Question", "Enter the current Year"}} }; return new ClientRecord(row, null); }