public JObject getRacialBonus([FromBody] Dictionary <string, String> req)
        {
            DnD5eAPI dnd5eAPI  = new DnD5eAPI();
            JObject  raceBonus = new JObject();

            raceBonus = dnd5eAPI.getRacialBonus(req["races"]);

            //erase the retrieved data
            dnd5eAPI = null;

            return(raceBonus);
        }
        public JObject getClassInfo([FromBody] Dictionary <string, String> req)
        {
            DnD5eAPI dnd5eAPI  = new DnD5eAPI();
            JObject  classInfo = new JObject();

            classInfo = dnd5eAPI.getClassInfo(req["classes"]);

            //erase the retrieved data
            dnd5eAPI = null;

            return(classInfo);
        }
        public String updateHero([FromBody] Dictionary <string, Object> req)
        {
            DnD5eAPI dnd5eAPI = new DnD5eAPI();
            Races    races    = dnd5eAPI.getRaces();

            if (races == null)
            {
                return("Fail to get races list from dnd5eapi");
            }
            Classes classes = dnd5eAPI.getClasses();

            if (classes == null)
            {
                return("Fail to get classes list from dnd5eapi");
            }

            //erase the retieve data
            dnd5eAPI = null;

            String        json      = JsonConvert.SerializeObject(req, Newtonsoft.Json.Formatting.Indented);
            DataStructure inputData = new DataStructure();

            try
            {
                inputData = JsonConvert.DeserializeObject <DataStructure>(json);
            }
            catch (JsonSerializationException)
            {
                return("incorect input form");
            }

            Validation validation = new Validation();

            validation.setInputData(inputData);
            if (validation.run(races, classes, false) != null)
            {
                return(validation.getErrorMsg());
            }

            DBHandler dBHandler = new DBHandler();

            return(dBHandler.updateChar(inputData));
        }
        public String[] getClassList()
        {
            DnD5eAPI dnd5eAPI = new DnD5eAPI();
            Classes  classes  = dnd5eAPI.getClasses();

            if (classes == null)
            {
                return(null);
            }

            int i = 0;

            String[] classList = new String[classes.results.Count];
            foreach (var result in classes.results)
            {
                classList[i] = result.name;
                i++;
            }

            //erase the retieve data
            dnd5eAPI = null;

            return(classList);
        }
        public String[] getRaceList()
        {
            DnD5eAPI dnd5eAPI = new DnD5eAPI();
            Races    races    = dnd5eAPI.getRaces();

            if (races == null)
            {
                return(null);
            }

            int i = 0;

            String[] raceList = new String[races.results.Count];
            foreach (var result in races.results)
            {
                raceList[i] = result.name;
                i++;
            }

            //erase the retieve data
            dnd5eAPI = null;

            return(raceList);
        }