public ActionResult Index() { //instantiating enemy data access object List <EnemyPO> enemyList = new List <EnemyPO>(); //mapping enemydo list provided by dao to enemypo list try { enemyList = Mapper.Mapper.EnemyDOListToPO(eDAO.ViewAllEnemies()); } //catching any thrown sqlexceptions from the dao catch (SqlException sqlEx) { //checks to see if the exception has been logged if (!sqlEx.Data.Contains("Logged") || (bool)sqlEx.Data["Logged"] == false) { //if exception has not been logged, log it Logger.LogSqlException(sqlEx); } } //catches any non sql excepions that may be throw catch (Exception ex) { //checks to see if the exception has been logged if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false) { //logs unlogged exceptions Logger.LogException(ex); } } //returns the index View() with the list of enemies pulled from the database return(View(enemyList)); }
public JsonResult GetEnemyData() { List <EnemyDO> doList = eDAO.ViewAllEnemies(); List <EnemyPO> enemyList = Mapper.Mapper.EnemyDOListToPO(doList); List <string> locationList = new List <string>(); locationList = Mapper.BLLMapper.PullEnemyLocation(enemyList); Dictionary <string, int> locationOccurance = new Dictionary <string, int>(); locationOccurance = AnalyzeItemList.LocationCount(locationList); ChartData <string, int> chartData = new ChartData <string, int>(); chartData.Labels = new List <string>(); chartData.Values = new List <int>(); foreach (KeyValuePair <string, int> location in locationOccurance) { chartData.Labels.Add(location.Key); chartData.Values.Add(location.Value); } return(Json(chartData, JsonRequestBehavior.AllowGet)); }