namespace VECV_WebApi.Controllers.Vehicle
{
#region Namespaces
using LoggingHelper;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using VECV_WebApi.Models.Vehicle;
#endregion
///
/// This class contain apis releted to vehicle
///
public class VehicleController : 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"]);
///
/// making Vehicle Repository object available to this class
///
VehicleRepository objVehicleRepository;
///
/// making the Database connection string available to this class
///
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
#endregion
#region APIs
///
/// To get vehicle details
///
/// vehicle info
/// status and data
public VehicleModel Post([FromBody]VehicleModel model)
{
// writing data logs
objLog.AddLogFile("GetVehicleDetail", model, DateTime.Now.ToString(ConfigurationManager.AppSettings["DateTimeFormat"]), path, logtf);
VehicleModel objModel = new VehicleModel();
try
{
objVehicleRepository = new VehicleRepository(_connStr);
objModel = objVehicleRepository.GetVehicleDetail(model);
return objModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetVehicleDetail_Controller", Ex.Message, path, errorlogtf);
objModel.Status = "0";
objModel.Message = Ex.Message;
return objModel;
}
}
#endregion
}
}