#region Namespaces using LoggingHelper; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; using System.Web.Http; using System.Web.Mvc; using VECV_WebApi.Models.Dashboard; #endregion namespace VECV_WebApi.Controllers.NewDashboard { public class NewDashboardController : ApiController { #region Global Variable /// /// making object of LoggingUtility class available to this class /// LoggingUtility objLog = new LoggingUtility(); /// /// making the data-log file path available to this class /// string path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]); /// /// making data log file path available to this class /// string logtf = (ConfigurationManager.AppSettings["Log"]); /// /// making error log file path available to this class /// string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]); /// /// making the Database connection string available to this class /// private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString(); #endregion #region APIs public List post(string region) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetAllRegionListDataSet(); return objList; } catch (Exception Ex) { // writing error logs objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public NewDashboardModel Post([FromBody] NewDashboardDataModel model) { NewDashboardModel objList = new NewDashboardModel(); string startdate = model.StartDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["startTimeFormat"]); string enddate = model.EndDate + " " + DateTime.Now.ToString(ConfigurationManager.AppSettings["endTimeFormat"]); string _dateTimeFormat = ConfigurationManager.AppSettings["dateTimeFormat"].ToString(); model.FromDate = Convert.ToDateTime(startdate); model.ToDate = Convert.ToDateTime(enddate); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetTileNewDashboardDataSet(model); } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("NewDashboardController GetTileNewDashboardDataSet", Ex.Message, path, errorlogtf); } return objList; } public List post(string dealer,[FromBody] NewDashboardDataModel model) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetDealerDetails(model); return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List post(string dtc,string dtccount, [FromBody] NewDashboardDataModel model) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetDTCDetails(model); return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List post(string graph, string graph1, string graph2, [FromBody] NewDashboardDataModel model) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetGraphDetails(model); return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List Get() { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); objList = ObjDashBoardRepository.GetVerticleListDataSet(); return objList; } catch (Exception Ex) { // writing error logs objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List get(string emission) { List objList = new List(); try { DashboardRepository objDashboardRepository = new DashboardRepository(_connStr); objList = objDashboardRepository.GetAllEmissionList(); return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllEmissionList_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List Get(string dealer, string dealer1) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); if(dealer == null) { int[] intarr = null; objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr); } else if (dealer.ToLower() == "dealer" ) { int[] intarr = null; objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr); } else { //int[] Arr = new int[dealer.Length];//int array for string console values //for (int i = 0; i < dealer.Length; i++)//goes true all elements and converts them into Int32 //{ // Arr[i] = Convert.ToInt32(dealer[i].ToString()); //} // string[] strings = new string[] { dealer }; string[] strings = dealer.Split(','); int[] ints = Array.ConvertAll(strings, s => int.Parse(s)); objList = ObjDashBoardRepository.GetAllDealerListDataSet(ints); } return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List Get(string dtcdata, string dtcdatareport,string dtclist ) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); if (dtcdata == null) { int[] intarr = null; objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr); } else if (dtcdata.ToLower() == "dtc") { int[] intarr = null; objList = ObjDashBoardRepository.GetAllDealerListDataSet(intarr); } else { //int[] Arr = new int[dealer.Length];//int array for string console values //for (int i = 0; i < dealer.Length; i++)//goes true all elements and converts them into Int32 //{ // Arr[i] = Convert.ToInt32(dealer[i].ToString()); //} // string[] strings = new string[] { dealer }; string[] strings = dtcdata.Split(','); int[] ints = Array.ConvertAll(strings, s => int.Parse(s)); objList = ObjDashBoardRepository.GetAllDealerListDataSet(ints); } return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetAllCityListStateIdWise_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public List Get(string vehicleModel, string fueltype, string vehicleTagging,string modellist) { List objList = new List(); try { DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr); if (vehicleTagging == null) { string[] intarr = null; objList = ObjDashBoardRepository.GetVehicleModelFilter(fueltype, intarr); } else { string[] strings = vehicleTagging.Split(','); // string[] ints = Array.ConvertAll(strings); objList = ObjDashBoardRepository.GetVehicleModelFilter(fueltype, strings); } return objList; } catch (Exception Ex) { // writing error logs objLog.ErrorLogFile("GetAllRegionList_Controller", Ex.Message, path, errorlogtf); throw Ex; } } #endregion } }