namespace VECV_WebApi.Controllers
{
#region Namespaces
using LoggingHelper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using VECV_WebApi.Models.Customer;
using VECV_WebApi.Models.EmailServices;
using VECV_WebApi.Models.Ticket;
using VECV_WebApi.Models.Vehicle;
#endregion
public class CogentAPIController : 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 Global Repository object available to this class
///
// GlobalRepository objGlobalRepository;
///
/// making Customer Repository object available to this class
///
// CustomerRepository objCustomerRepository;
///
/// making Ticket Repository object available to this class
///
// TicketRepository objTicketRepository;
#endregion
#region APIs
///
/// To get customer details
///
/// customer info
/// customer details
public TicketOpenModelCogentAPI Post([FromBody] CustomerVehicleModelDBM model)
{
TicketOpenModelCogentAPI objTicketOpenModel = new TicketOpenModelCogentAPI();
try
{
TicketRepository objTicket = new TicketRepository(_connStr);
objTicketOpenModel = objTicket.GetOpenTicketHistoryForCogent(model.CustomerMobile1);
return objTicketOpenModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetCustomerDetails_Controller", Ex.Message, path, errorlogtf);
objTicketOpenModel = new TicketOpenModelCogentAPI();
objTicketOpenModel.Status = "0";
objTicketOpenModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
return objTicketOpenModel;
}
}
public List Post([FromUri] string getvans, [FromBody] VanDealerListStateWise model)
{
try
{
List objList = new List();
// model.Fuel_type = model.Limit;
model.Limit = "100";
TicketRepository objTicket = new TicketRepository(_connStr);
objList = objTicket.GetVanListStateWise(model);
return objList;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetVanDealerListStateWise_Controller COGENT API getvans", Ex.Message, path, errorlogtf);
throw Ex;
}
}
public List Post([FromUri] string getvans, [FromUri] string dealerCode, VanDealerListStateWise model)
{
//VanDealerListStateWise model = new VanDealerListStateWise();
//model.DealerSCode = dealer_1sCode;
//model.UserId = Convert.ToInt32(UserId);
//model.Limit = limit;// Convert.ToInt32(limit);
//model.StateName = StateName;
//model.Token = token;
// write to log into file
List objList = new List();
try
{
TicketRepository objTicket = new TicketRepository(_connStr);
objList = objTicket.GetVanListDealerWise(dealerCode, model);
return objList;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetVanDealerListStateWise_Controller Cogent api getvans dealerCode", Ex.Message, path, errorlogtf);
throw Ex;
}
}
///
/// To get customer details
///
/// customer info
/// customer details
public TicketOpenModelCogentAPI Get([FromUri] string MobileNo)
{
TicketOpenModelCogentAPI objTicketOpenModel = new TicketOpenModelCogentAPI();
try
{
TicketRepository objTicket = new TicketRepository(_connStr);
objTicketOpenModel = objTicket.GetOpenTicketHistoryForCogent(MobileNo);
return objTicketOpenModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetCustomerDetails_Controller", Ex.Message, path, errorlogtf);
objTicketOpenModel = new TicketOpenModelCogentAPI();
objTicketOpenModel.Status = "0";
objTicketOpenModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
return objTicketOpenModel;
}
}
#endregion
}
}