using LoggingHelper; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using VECV_WebApi.Models.EmailServices; using VECV_WebApi.Models.Ticket; namespace VECV_WebApi.Controllers.Global { public class GetAllVanController : 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"]); string _appName = (ConfigurationManager.AppSettings["ApplicationName"]); /// /// making the Database connection string available to this class /// private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString(); /// /// making Ticket Repository object available to this class /// TicketRepository objTicketRepository; #endregion #region APIs public List Post([FromBody] VanDealerListStateWise model) { List objList = new List(); try { if (model.Fuel_type == "Diesel/CNG") { model.Fuel_type = "diesel,cng"; } else if (model.Fuel_type == "Diesel/CNG/Electric") { model.Fuel_type = "diesel,cng,electric"; } else if (model.Fuel_type == "Electric") { model.Fuel_type = "electric"; } TicketRepository objTicket = new TicketRepository(_connStr); objList = objTicket.GetVanDealerListLatLngWise(model); return objList; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetVanDealerListStateWise_Controller Ticket controller ticket3", Ex.Message, path, errorlogtf); throw Ex; } } public EscalationLevelOutputModel Post([FromUri] string operation, [FromBody] EscalationLevelInputModel model) { // write data log into file EscalationLevelOutputModel oEscalationLevelOutputModel = new EscalationLevelOutputModel(); try { if (operation.ToLower() == "getescalationlevels") { TicketRepository objTicket = new TicketRepository(_connStr); oEscalationLevelOutputModel = objTicket.GetEscalationLevelsByDealerId(model); return oEscalationLevelOutputModel; } oEscalationLevelOutputModel.Status = "0"; return oEscalationLevelOutputModel; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetEscalationLevels_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public bool Post([FromUri] string send, [FromUri] string sendmessage,[FromBody] sendSMSInputModel model) { // write data log into file EscalationLevelOutputModel oEscalationLevelOutputModel = new EscalationLevelOutputModel(); try { string url = System.Web.Configuration.WebConfigurationManager.AppSettings["SmsUrl"].ToString(); GlobalRepository objGlobalRepository = new GlobalRepository(_connStr); string breakdownLocation = objGlobalRepository.getdealerlatlong(model.DelerId); string LocationLikn = "https://www.google.com/maps/search/?api=1%26query=" + breakdownLocation; string msgForEscalationForUser = System.Web.Configuration.WebConfigurationManager.AppSettings["msgForEscalation"].ToString(); string msgforEscalation = string.Format(msgForEscalationForUser, model.DealerName , LocationLikn,model.ManagerName, model.ManagerNo); //Please contact to(Name Arman / Mohit & Number 9818945971 / 9558820990) at our nearest dealership NONACTIVE - EOS by clicking on following link https://www.google.com/maps?q=23.5391281,87.3047335 Regards, Eicher string CSMsms = string.Format(url, model.MobileNumber, msgforEscalation); objGlobalRepository.SendMessageEscalation(CSMsms); return true; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetEscalationLevels_Controller", Ex.Message, path, errorlogtf); throw Ex; } } public bool Post([FromUri] string sendservicelocation,[FromUri] string send, [FromUri] string sendmessage, [FromBody] ElectricServiceStationModel model) { // write data log into file EscalationLevelOutputModel oEscalationLevelOutputModel = new EscalationLevelOutputModel(); try { string url = System.Web.Configuration.WebConfigurationManager.AppSettings["SmsUrl"].ToString(); GlobalRepository objGlobalRepository = new GlobalRepository(_connStr); string breakdownLocation = model.lattitude + ',' + model.longitude; string LocationLikn = "https://www.google.com/maps/search/?api=1%26query=" + breakdownLocation; string msgForEscalationForUser = System.Web.Configuration.WebConfigurationManager.AppSettings["msgForServiceLocation"].ToString(); string msgforEscalation = string.Format(msgForEscalationForUser, model.name, LocationLikn); //Please contact to(Name Arman / Mohit & Number 9818945971 / 9558820990) at our nearest dealership NONACTIVE - EOS by clicking on following link https://www.google.com/maps?q=23.5391281,87.3047335 Regards, Eicher string CSMsms = string.Format(url, model.MobileNumber, msgforEscalation); objGlobalRepository.SendMessageEscalation(CSMsms); return true; } catch (Exception Ex) { // write error log into file objLog.ErrorLogFile("GetEscalationLevels_Controller", Ex.Message, path, errorlogtf); throw Ex; } } #endregion } }