using LoggingHelper; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; using System.Web.Mvc; using GODATA.RoleServices; using GODATA.AuthenticationServices; using RestSharp; using Newtonsoft.Json; using Kendo.Mvc.UI; using Kendo.Mvc.Extensions; using GODATA.Models.Ticket; using GODATA.Models.UserInventory; using GODATA.Models.DropDownData; namespace GODATA.Controllers { [GODATA.MvcApplication.SessionExpire] public class DropDownDataController : Controller { /// /// Global variable for Notifications repository. /// private TicketAdministrationRepository objTicketAdministrationRepository = null; /// /// Global variable for Ticket administration repository. /// private DropDownDataRepository objDropDownDataRepository = null; #region Global Variables /// /// Represent object of LoggingUtility class /// LoggingUtility objLog = new LoggingUtility(); /// /// Represent string object contain log file path /// //string path = "~/Log/"; string path = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]); /// /// Represent string object contain log status /// string logtf = (ConfigurationManager.AppSettings["Log"]); /// /// Represent string object contain Error log status /// string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]); /// /// getting application name from AppSetting in web.config file /// private static string _appName = ConfigurationManager.AppSettings["ApplicationName"].ToString(); /// /// getting web api token from AppSetting in web.config file /// private static string _securityToken = ConfigurationManager.AppSettings["RESTfulSecurityToken"].ToString(); /// /// getting user's utc minutes from session /// private static string _timeOffSetMinutes = null; /// /// getting login user's id /// private static string _LoginUserId = null; /// /// getting login user's name /// private static string _LoginUserName = null; /// /// getting time zone id from AppSetting in web.config file /// private static string _TimeZoneId = ConfigurationManager.AppSettings["TimeZoneId"].ToString(); /// /// getting rest api url from AppSetting in web.config file /// private static string _RestClientUrl = ConfigurationManager.AppSettings["RestfulApiUrl"].ToString(); #endregion public ActionResult Index() { return View(); } /// /// Get all languages list /// /// returns json of language list public ActionResult GetAllLanguageList() { objLog.AddLogFile("DropDownData_GetAllLanguagesList", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { objDropDownDataRepository = new DropDownDataRepository(); //Get Languages List List oLanguageList = objDropDownDataRepository.GetLanguagesList(); List oLanguageNameList = new List(); foreach (LanguageModel items in oLanguageList) { oLanguageNameList.Add(new SelectListItem { Text = items.LanguageName, Value = items.LanguageName }); } objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oLanguageNameList.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_GetAllLanguagesList", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } /// /// Get source list of toll free no. /// /// returns json of source list< public ActionResult GetSourceListOfTollFreeNo() { objLog.AddLogFile("DropDownData_GetSourceListOfTollFreeNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { objDropDownDataRepository = new DropDownDataRepository(); //Get Source List List oTollFreeSourceList = objDropDownDataRepository.GetSourceListOfTollFreeNo(); List oTollFreeSourceNameList = new List(); foreach (TollFreeSourceModel items in oTollFreeSourceList) { oTollFreeSourceNameList.Add(new SelectListItem { Text = items.ReasonName, Value = items.ReasonName }); } objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oTollFreeSourceNameList.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_GetSourceListOfTollFreeNo", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } /// /// Get warrenty list of toll free no. /// /// return list public ActionResult GetWarrentyAmcList() { objLog.AddLogFile("DropDownData_GetWarrentyAmcList", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { objDropDownDataRepository = new DropDownDataRepository(); //Get warrenty List List oWarrentyAmcList = objDropDownDataRepository.GetWarrentyAmcList(); List oWarrentyAmcNameList = new List(); foreach (WarrentyModel items in oWarrentyAmcList) { oWarrentyAmcNameList.Add(new SelectListItem { Text = items.ReasonName, Value = items.ReasonName }); } objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oWarrentyAmcNameList.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_GetWarrentyAmcList", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } /// /// Get city list based on state id /// /// Integer type state id /// returns json of cities state wise public ActionResult showCityStateWise(int stateVal) { objLog.AddLogFile("DropDownData_showCityStateWise", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { if (stateVal != 0) { objTicketAdministrationRepository = new TicketAdministrationRepository(); //Getting City List List oCityList = objTicketAdministrationRepository.GetCityList(stateVal); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oCityList.OrderBy(o => o.CityName) }, JsonRequestBehavior.AllowGet); } else { objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = false }, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_showCityStateWise", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } #region get dealer ticket reasons /// /// Get all languages list /// /// returns json of language list public ActionResult GetReasonForDealerTicket() { objLog.AddLogFile("DropDownData_GetReasonForDealerTicket", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { objDropDownDataRepository = new DropDownDataRepository(); //Get Source List List oReasonForDealerTicketList = objDropDownDataRepository.GetReasonForDealerTicket(); List oReasonForDealerTicketNameList = new List(); foreach (TollFreeSourceModel items in oReasonForDealerTicketList) { oReasonForDealerTicketNameList.Add(new SelectListItem { Text = items.ReasonName, Value = items.ReasonName }); } objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oReasonForDealerTicketNameList.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_GetReasonForDealerTicket", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } #endregion #region get state list region wise /// /// /// /// /// public ActionResult showStateRegionWise(int regionVal) { objLog.AddLogFile("DropDownData_showCityStateWise", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); try { if (regionVal != 0) { objTicketAdministrationRepository = new TicketAdministrationRepository(); //Getting City List List oStateList = objTicketAdministrationRepository.GetStateListRegionWise(regionVal); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = true, list = oStateList.OrderBy(o => o.StateAlias) }, JsonRequestBehavior.AllowGet); } else { objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return Json(new { success = false }, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { objLog.ErrorLogFile("DropDownData_showCityStateWise", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); throw ex; } } #endregion } }