89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
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
|
|
|
|
/// <summary>
|
|
/// This class contain apis releted to vehicle
|
|
/// </summary>
|
|
public class VehicleController : 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"]);
|
|
|
|
/// <summary>
|
|
/// making Vehicle Repository object available to this class
|
|
/// </summary>
|
|
VehicleRepository objVehicleRepository;
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
#endregion
|
|
|
|
|
|
#region APIs
|
|
|
|
/// <summary>
|
|
/// To get vehicle details
|
|
/// </summary>
|
|
/// <param name="model">vehicle info</param>
|
|
/// <returns>status and data</returns>
|
|
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
|
|
}
|
|
}
|