178 lines
6.2 KiB
C#
178 lines
6.2 KiB
C#
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
|
|
|
|
/// <summary>
|
|
/// making object of LoggingUtility class available to this class
|
|
/// </summary>
|
|
LoggingUtility objLog = new LoggingUtility();
|
|
|
|
/// <summary>
|
|
/// making the data-log file path available to this class
|
|
/// </summary>
|
|
string path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]);
|
|
|
|
/// <summary>
|
|
/// making data log file path available to this class
|
|
/// </summary>
|
|
string logtf = (ConfigurationManager.AppSettings["Log"]);
|
|
|
|
/// <summary>
|
|
/// making error log file path available to this class
|
|
/// </summary>
|
|
string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]);
|
|
|
|
string _appName = (ConfigurationManager.AppSettings["ApplicationName"]);
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
/// <summary>
|
|
/// making Global Repository object available to this class
|
|
/// </summary>
|
|
// GlobalRepository objGlobalRepository;
|
|
|
|
/// <summary>
|
|
/// making Customer Repository object available to this class
|
|
/// </summary>
|
|
// CustomerRepository objCustomerRepository;
|
|
|
|
/// <summary>
|
|
/// making Ticket Repository object available to this class
|
|
/// </summary>
|
|
// TicketRepository objTicketRepository;
|
|
|
|
|
|
#endregion
|
|
|
|
#region APIs
|
|
/// <summary>
|
|
/// To get customer details
|
|
/// </summary>
|
|
/// <param name="model">customer info</param>
|
|
/// <returns>customer details</returns>
|
|
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<VanDealerListStateWise> Post([FromUri] string getvans, [FromBody] VanDealerListStateWise model)
|
|
{
|
|
try
|
|
{
|
|
List<VanDealerListStateWise> objList = new List<VanDealerListStateWise>();
|
|
|
|
// 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<VanDealerListStateWise> 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<VanDealerListStateWise> objList = new List<VanDealerListStateWise>();
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// To get customer details
|
|
/// </summary>
|
|
/// <param name="model">customer info</param>
|
|
/// <returns>customer details</returns>
|
|
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
|
|
|
|
}
|
|
}
|