672 lines
32 KiB
C#
672 lines
32 KiB
C#
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 GODATA.Models.Ticket;
|
|
using Kendo.Mvc.UI;
|
|
using Kendo.Mvc.Extensions;
|
|
using Microsoft.Practices.EnterpriseLibrary.Logging;
|
|
using GODATA.Models.UserInventory;
|
|
|
|
namespace GODATA.Controllers
|
|
{
|
|
[GODATA.MvcApplication.SessionExpire]
|
|
public class Ticket_CustomerInventoryController : Controller
|
|
{
|
|
#region Global Variables
|
|
|
|
/// <summary>
|
|
/// Global variable for Notifications repository.
|
|
/// </summary>
|
|
private TicketAdministrationRepository objTicketAdministrationRepository = null;
|
|
|
|
/// <summary>
|
|
/// Represent object of LoggingUtility class
|
|
/// </summary>
|
|
LoggingUtility objLog = new LoggingUtility();
|
|
|
|
/// <summary>
|
|
/// Represent string object contain log file path
|
|
/// </summary>
|
|
//string path = "~/Log/";
|
|
string path = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]);
|
|
|
|
/// <summary>
|
|
/// Represent string object contain log status
|
|
/// </summary>
|
|
string logtf = (ConfigurationManager.AppSettings["Log"]);
|
|
|
|
/// <summary>
|
|
/// Represent string object contain Error log status
|
|
/// </summary>
|
|
string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]);
|
|
|
|
/// <summary>
|
|
/// getting application name from AppSetting in web.config file
|
|
/// </summary>
|
|
private static string _appName = ConfigurationManager.AppSettings["ApplicationName"].ToString();
|
|
|
|
/// <summary>
|
|
/// getting web api token from AppSetting in web.config file
|
|
/// </summary>
|
|
private static string _securityToken = ConfigurationManager.AppSettings["RESTfulSecurityToken"].ToString();
|
|
|
|
/// <summary>
|
|
/// getting user's utc minutes from session
|
|
/// </summary>
|
|
private static string _timeOffSetMinutes = null;
|
|
|
|
/// <summary>
|
|
/// getting login user's id
|
|
/// </summary>
|
|
private static string _LoginUserId = null;
|
|
|
|
/// <summary>
|
|
/// getting time zone id from AppSetting in web.config file
|
|
/// </summary>
|
|
private static string _TimeZoneId = ConfigurationManager.AppSettings["TimeZoneId"].ToString();
|
|
|
|
/// <summary>
|
|
/// getting rest api url from AppSetting in web.config file
|
|
/// </summary>
|
|
private static string _RestClientUrl = ConfigurationManager.AppSettings["RestfulApiUrl"].ToString();
|
|
#endregion
|
|
|
|
#region Add New Customer
|
|
|
|
/// <summary>
|
|
/// Get view of new customer creation
|
|
/// </summary>
|
|
/// <param name="VRegistrationNo">Vehicle registration number</param>
|
|
/// <returns>returns form view</returns>
|
|
public ActionResult Create(string VRegistrationNo, string KamUser, string Chassis_Number)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_Create", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting State list
|
|
List<StateModel> oStateList = objTicketAdministrationRepository.GetStateList();
|
|
List<SelectListItem> oStateNameList = new List<SelectListItem>();
|
|
|
|
foreach (StateModel items in oStateList)
|
|
{
|
|
oStateNameList.Add(new SelectListItem { Text = items.StateAlias, Value = items.StateId });
|
|
}
|
|
ViewBag.StateList = oStateNameList.OrderBy(o => o.Text);
|
|
|
|
//Getting list of vehicle model no.
|
|
List<VehicleModelModel> oVehicleModelList = objTicketAdministrationRepository.GetVehicleModelList().Where(w => w.IsDeleted.Equals(false)).ToList();
|
|
List<SelectListItem> item1 = new List<SelectListItem>();
|
|
|
|
foreach (VehicleModelModel items in oVehicleModelList)
|
|
{
|
|
item1.Add(new SelectListItem { Text = items.VehicleTypeName, Value = items.VehicleTypeId });
|
|
}
|
|
ViewBag.VehicleModelNo = item1.OrderBy(o => o.Text);
|
|
|
|
//Getting list of vehicle type(truck or bus).
|
|
List<VehicleTypeModel> oVehicleTypeList = objTicketAdministrationRepository.GetVehicleTypeList();
|
|
List<SelectListItem> item11 = new List<SelectListItem>();
|
|
|
|
foreach (VehicleTypeModel items in oVehicleTypeList)
|
|
{
|
|
item11.Add(new SelectListItem { Text = items.ReasonName, Value = items.ReasonName });
|
|
}
|
|
ViewBag.VehicleType = item11.OrderBy(o => o.Text);
|
|
|
|
ViewBag.VRegNo = VRegistrationNo;
|
|
ViewBag.IsKamUser = KamUser;
|
|
ViewBag.ChassisNumber = Chassis_Number;
|
|
|
|
// dummy list for Product Variant
|
|
List<SelectListItem> serviceList1 = new List<SelectListItem>();
|
|
ViewBag.Service = serviceList1;
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return PartialView();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_Create", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public ActionResult CreateEPS(string VehicleRegistrationNumber, string KamUser, string Engine_number)
|
|
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_Create", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
if (VehicleRegistrationNumber == null)
|
|
VehicleRegistrationNumber = Engine_number;
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting State list
|
|
List<StateModel> oStateList = objTicketAdministrationRepository.GetStateList();
|
|
List<SelectListItem> oStateNameList = new List<SelectListItem>();
|
|
|
|
foreach (StateModel items in oStateList)
|
|
{
|
|
oStateNameList.Add(new SelectListItem { Text = items.StateAlias, Value = items.StateId });
|
|
}
|
|
ViewBag.StateList = oStateNameList.OrderBy(o => o.Text);
|
|
|
|
//Getting list of vehicle model no.
|
|
//List<VehicleModelModel> oVehicleModelList = objTicketAdministrationRepository.GetVehicleModelList().Where(w => w.IsDeleted.Equals(false)).ToList();
|
|
//List<SelectListItem> item1 = new List<SelectListItem>();
|
|
|
|
//foreach (VehicleModelModel items in oVehicleModelList)
|
|
//{
|
|
// item1.Add(new SelectListItem { Text = items.VehicleTypeName, Value = items.VehicleTypeId });
|
|
//}
|
|
ViewBag.VehicleModelNo = "EPS"; //item1.OrderBy(o => o.Text);
|
|
|
|
//Getting list of vehicle type(truck or bus).
|
|
//List<VehicleTypeModel> oVehicleTypeList = objTicketAdministrationRepository.GetVehicleTypeList();
|
|
//List<SelectListItem> item11 = new List<SelectListItem>();
|
|
|
|
//foreach (VehicleTypeModel items in oVehicleTypeList)
|
|
//{
|
|
// item11.Add(new SelectListItem { Text = items.ReasonName, Value = items.ReasonName });
|
|
//}
|
|
ViewBag.VehicleType = "EPS";// item11.OrderBy(o => o.Text);
|
|
if (Engine_number.Length >= 14)
|
|
{
|
|
string formatted = Engine_number.Substring(0, 1) +// "-" + // E
|
|
Engine_number.Substring(1, 2) + //"-" + // 61
|
|
Engine_number.Substring(3, 2) + //"-" + // 3C
|
|
Engine_number.Substring(7, 4); // 3418
|
|
ViewBag.VRegNo = formatted;
|
|
|
|
}
|
|
else
|
|
{
|
|
ViewBag.VRegNo = Engine_number.ToUpper();
|
|
}
|
|
|
|
ViewBag.IsKamUser = KamUser;
|
|
ViewBag.ChassisNumber = Engine_number.ToUpper();
|
|
|
|
// dummy list for Product Variant
|
|
List<SelectListItem> serviceList1 = new List<SelectListItem>();
|
|
ViewBag.Service = serviceList1;
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return PartialView();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_Create", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create new customer for a vehicle
|
|
/// </summary>
|
|
/// <param name="model">customer model</param>
|
|
/// <returns>return json success true or false and new customer's mobile no.</returns>
|
|
[HttpPost]
|
|
public ActionResult Create(CustomerModel model)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_Create_post", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Check model state
|
|
if (ModelState.IsValid)
|
|
{
|
|
CustomerModel oCustomerModel = new CustomerModel();
|
|
model.VehicleRegistrationNumber = model.VehicleRegistrationNumber.Replace("-", " ").Replace(" ", String.Empty).ToUpper();
|
|
//calling create customer web api
|
|
oCustomerModel = objTicketAdministrationRepository.Restful_AddNewCustomer(model);
|
|
objLog.AddLogFile("CustomerInventory_Create_post", oCustomerModel, DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
|
|
if (oCustomerModel.Status != "0")
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true, vRegistrationNo = model.VehicleRegistrationNumber });
|
|
}
|
|
else
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = false, message = oCustomerModel.Message });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ModelState.AddModelError("error", "Error in adding Customer.");
|
|
}
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return PartialView(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_Create_post", Ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Add New Customer for existing vehicle
|
|
|
|
/// <summary>
|
|
/// Get new customer creation form if vehicle and owner is already exist
|
|
/// </summary>
|
|
/// <param name="VRegistrationNo">vehicle's registration number</param>
|
|
/// <returns>returns form view</returns>
|
|
public ActionResult CreateNewCustomerForExistingVehicle(string VRegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting State list
|
|
List<StateModel> oStateList = objTicketAdministrationRepository.GetStateList();
|
|
List<SelectListItem> oStateNameList = new List<SelectListItem>();
|
|
|
|
foreach (StateModel items in oStateList)
|
|
{
|
|
oStateNameList.Add(new SelectListItem { Text = items.StateAlias, Value = items.StateId });
|
|
}
|
|
ViewBag.StateList = oStateNameList.OrderBy(o => o.Text);
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return PartialView();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create new customer creation form if vehicle and owner is already exist
|
|
/// </summary>
|
|
/// <param name="model">Customer model</param>
|
|
/// <param name="selection">selection</param>
|
|
/// <returns>returns json success true or false and new customer's contact no.</returns>
|
|
[HttpPost]
|
|
public ActionResult CreateNewCustomerForExistingVehicle(CustomerModel model)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle_post", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
string updateFor = model.selection;
|
|
|
|
if (updateFor == "radio_chassis") { model.CustomerStateName = ""; }
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
CustomerModel oCustomerModel = new CustomerModel();
|
|
model.VehicleRegistrationNumber = model.VehicleRegistrationNumber.Replace("-", " ").Replace(" ", String.Empty).ToUpper();
|
|
|
|
//Calling web api for new customer creation
|
|
oCustomerModel = objTicketAdministrationRepository.Restful_AddNewCustomer(model);
|
|
objLog.AddLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle_post", oCustomerModel, DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
|
|
if (oCustomerModel.Status == "1")
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true, vRegistationNo = model.VehicleRegistrationNumber, dataUpdatedFor = updateFor });
|
|
}
|
|
else
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = false, message = oCustomerModel.Message });
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle_post", Ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get customers list including new customer for existing vehicle
|
|
/// </summary>
|
|
/// <param name="VRegistrationNo">Vehicle's registration no.</param>
|
|
/// <returns>returns json of customers name</returns>
|
|
public ActionResult ShowCustomerList(string VRegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_ShowCustomerList", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting all customers details list for a vehicle
|
|
List<CustomerModel> oCustomerList = objTicketAdministrationRepository.GetCustomerDetails(VRegistrationNo);
|
|
|
|
//Creating new drop down list of all customers excluding vehicle's owner
|
|
List<SelectListItem> item = new List<SelectListItem>();
|
|
foreach (CustomerModel items in oCustomerList)
|
|
{
|
|
if (items.CustomerVehicleIsOwnwer == false)
|
|
{
|
|
item.Add(new SelectListItem { Text = items.CustomerName, Value = items.CustomerName });
|
|
}
|
|
}
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true, list = item.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_ShowCustomerList", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region common get API's
|
|
|
|
/// <summary>
|
|
/// Get city list based on state id
|
|
/// </summary>
|
|
/// <param name="stateVal">Integer type state id</param>
|
|
/// <returns>returns json of cities state wise</returns>
|
|
public ActionResult showCityStateWise(int stateVal)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_showCityStateWise", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
if (stateVal != 0)
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting City List
|
|
List<CityModel> oCityList = objTicketAdministrationRepository.GetCityList(stateVal);
|
|
List<SelectListItem> oCityNameList = new List<SelectListItem>();
|
|
|
|
foreach (CityModel items in oCityList)
|
|
{
|
|
oCityNameList.Add(new SelectListItem { Text = items.CityName, Value = items.CityName });
|
|
}
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true, list = oCityNameList.OrderBy(o => o.Text) }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
else
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_showCityStateWise", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get vehicle's details based on registration no.
|
|
/// </summary>
|
|
/// <param name="RegistrationNo">vehicle registration no.</param>
|
|
/// <returns>return json of vehicle's details list</returns>
|
|
public JsonResult GetVehicleDetailsBasedOnRegistrationNo(string RegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_GetVehicleDetailsBasedOnRegistrationNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
string VModelNo = ""; string VModelTagging = ""; string VModelTaggingName = "";
|
|
|
|
List<VehicleModel> oVehicleDetailsList = new List<VehicleModel>();
|
|
|
|
//Getting vehicle details based on registration no
|
|
oVehicleDetailsList = objTicketAdministrationRepository.GetVehicleDetailsRegistrationNoWise(RegistrationNo);
|
|
|
|
foreach (var item12 in oVehicleDetailsList)
|
|
{
|
|
VModelNo = item12.ModelNumber;
|
|
}
|
|
|
|
//Get vehicle's product variant(model tagging)
|
|
List<VehicleModelModel> oVehicleModelList = objTicketAdministrationRepository.GetVehicleModelList();
|
|
var oVModelTaggingList = oVehicleModelList.Where(w => w.VehicleTypeId.Equals(VModelNo));
|
|
foreach (var item13 in oVModelTaggingList)
|
|
{
|
|
VModelTagging = item13.VehicleTypeTagging;
|
|
VModelTaggingName = item13.VehicleTypeName;
|
|
}
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { VehicleDetails = oVehicleDetailsList, vehicleModelTagging = VModelTagging, vehicleModelTaggingName = VModelTaggingName }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_GetVehicleDetailsBasedOnRegistrationNo", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Get chasis number
|
|
/// </summary>
|
|
/// <param name="RegistrationNo">String type representation of Vehicle's registration no.</param>
|
|
/// <param name="OwnerMobileNo">String type representation of owner's mobile no.</param>
|
|
/// <returns>returns json of owner's details </returns>
|
|
public JsonResult GetChassisNo(string RegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_GetChassisNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
|
|
string lastdate = "";
|
|
Telematic_Model model = new Telematic_Model();
|
|
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
List<CustomerModel> oCustomerModelsList = new List<CustomerModel>();
|
|
oCustomerModelsList = objTicketAdministrationRepository.GetVehicleDetailsRegistrationNoWiseByThirdParty(RegistrationNo);
|
|
|
|
|
|
var chassis_no = oCustomerModelsList.Select(x => x.VehicleNumberPlate).FirstOrDefault();
|
|
|
|
List<Telematic_Model> Telematic_List = new List<Telematic_Model>();
|
|
Telematic_List = objTicketAdministrationRepository.GetChasis_Details(chassis_no);
|
|
|
|
var latitude = Telematic_List.Select(x => x.latitude).FirstOrDefault();
|
|
var longitude = Telematic_List.Select(x => x.longitude).FirstOrDefault();
|
|
var date1 = Telematic_List.Select(x => x.positionDateTime.Date).FirstOrDefault();
|
|
|
|
//List<Telematic_Model> Telematic_List_new = new List<Telematic_Model>();
|
|
//foreach (var item in Telematic_List)
|
|
//{
|
|
// item.positionDateTime=Convert.ToDateTime(date1) ;
|
|
// Telematic_List_new.Add(item);
|
|
//}
|
|
|
|
return Json(new { Chassis_Details = Telematic_List, lastdate = date1.ToShortDateString(), Status = Telematic_List[0].status }, JsonRequestBehavior.AllowGet);
|
|
|
|
////if ((RegistrationNo == "" || RegistrationNo == null) && RegistrationNo != "")
|
|
////{
|
|
// objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
// List<CHASSIS_SRCH_Model> oChassisList = new List<CHASSIS_SRCH_Model>();
|
|
// // oChassisList = objTicketAdministrationRepository.GetChassisNoByEOSApiSearch_regi(RegistrationNo);
|
|
|
|
|
|
//ViewBag.VehicleType = oChassisList.Select(s => s.VehicleType).FirstOrDefault();
|
|
// //ViewBag.VehicleType = a.Data
|
|
|
|
|
|
|
|
/////}
|
|
//return Json(new { Chasisnumber = oChassisList }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_GetChassisNo", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
public JsonResult GetVehicleDetailsBasedOnRegistrationNoThirdParty(string RegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_GetVehicleDetailsBasedOnRegistrationNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
|
|
//RegistrationNo = "0000005549";
|
|
string VModelNo = ""; string VModelTagging = ""; string VModelTaggingName = "";
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
List<CustomerModel> oCustomerModelsList = new List<CustomerModel>();
|
|
oCustomerModelsList = objTicketAdministrationRepository.GetVehicleDetailsRegistrationNoWiseByThirdParty(RegistrationNo);
|
|
if (oCustomerModelsList[0].Status != "0")
|
|
{
|
|
List<VehicleModelModel> oVehicleModelList = objTicketAdministrationRepository.GetVehicleModelList();
|
|
var oVModelTaggingList = oVehicleModelList.Where(w => w.udanVehicleProductName == oCustomerModelsList[0].VehicleModelNumber);
|
|
foreach (var item13 in oVModelTaggingList)
|
|
{
|
|
VModelTagging = item13.VehicleTypeTagging;
|
|
VModelTaggingName = item13.VehicleTypeName;
|
|
}
|
|
}
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { VehicleDetails = oCustomerModelsList, vehicleModelTagging = VModelTagging, vehicleModelTaggingName = VModelTaggingName, Status = oCustomerModelsList[0].Status }, JsonRequestBehavior.AllowGet);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_GetVehicleDetailsBasedOnRegistrationNo", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// Get vehicle's model tagging based on vehicle's model type id
|
|
/// </summary>
|
|
/// <param name="ModelTypeId">vehicle's model type id</param>
|
|
/// <returns>return json of vehicle's model tagging</returns>
|
|
public JsonResult GetVehicleModelTaggingBasedOnModelNo(string ModelTypeId)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_GetVehicleModelTaggingBasedOnModelNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
//Getting vehicles model type list
|
|
List<VehicleModelModel> oVehicleModelList = objTicketAdministrationRepository.GetVehicleModelList();
|
|
|
|
//Getting vehicle's model tagging based on vehicle's model type id
|
|
List<VehicleModelModel> VehicleModelTagging = oVehicleModelList.Where(w => w.VehicleTypeId.Equals(ModelTypeId)).ToList();
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { VehicleModelTagging = VehicleModelTagging }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_GetVehicleModelTaggingBasedOnModelNo", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get vehicle's owner details
|
|
/// </summary>
|
|
/// <param name="RegistrationNo">String type representation of Vehicle's registration no.</param>
|
|
/// <param name="OwnerMobileNo">String type representation of owner's mobile no.</param>
|
|
/// <returns>returns json of owner's details </returns>
|
|
public JsonResult GetOwnerDetailsBasedOnMobilenNo(string RegistrationNo, string OwnerMobileNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_GetOwnerDetailsBasedOnMobilenNo", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
|
|
List<CustomerOwnerModel> oCustomerOwnerDetailsList = objTicketAdministrationRepository.GetCustomerOwnerDetails(RegistrationNo, OwnerMobileNo);
|
|
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { CustomerOwnerDetails = oCustomerOwnerDetailsList }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_GetOwnerDetailsBasedOnMobilenNo", ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region UpdateCustomer
|
|
/// <summary>
|
|
/// Create new customer for a vehicle
|
|
/// </summary>
|
|
/// <param name="model">customer model</param>
|
|
/// <returns>return json success true or false and new customer's mobile no.</returns>
|
|
//[HttpPost]
|
|
public JsonResult UpdateCustomer(string CustomerId, string CustomerType, string RegistrationNo)
|
|
{
|
|
objLog.AddLogFile("CustomerInventory_UpdateCustomer_post", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
try
|
|
{
|
|
CustomerModel model = new CustomerModel();
|
|
model.CustomerId = CustomerId;
|
|
model.CustomerType = CustomerType;
|
|
model.VehicleRegistrationNumber = RegistrationNo;
|
|
|
|
|
|
objTicketAdministrationRepository = new TicketAdministrationRepository();
|
|
CustomerModel oCustomerModel = new CustomerModel();
|
|
//model.VehicleRegistrationNumber = model.VehicleRegistrationNumber.Replace("-", " ").Replace(" ", String.Empty).ToUpper();
|
|
|
|
//Calling web api for new customer creation
|
|
oCustomerModel = objTicketAdministrationRepository.Restful_UpdateCustomer(model);
|
|
objLog.AddLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle_post", oCustomerModel, DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
|
|
if (oCustomerModel.Status == "1")
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = true, vRegistationNo = model.VehicleRegistrationNumber });
|
|
}
|
|
else
|
|
{
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
return Json(new { success = false, message = oCustomerModel.Message });
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objLog.ErrorLogFile("CustomerInventory_CreateNewCustomerForExistingVehicle_post", Ex.Message, path, errorlogtf);
|
|
objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|