107 lines
3.1 KiB
C#
107 lines
3.1 KiB
C#
namespace VECV_WebApi.Models.Route
|
|
{
|
|
#region Namespaces
|
|
|
|
using DBHelper;
|
|
using LoggingHelper;
|
|
using Npgsql;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using VECV_WebApi.Models.Authorization;
|
|
|
|
#endregion
|
|
|
|
#region Repository Class
|
|
|
|
/// <summary>
|
|
/// This class cotnain method releted to route management
|
|
/// </summary>
|
|
public class RouteRepository
|
|
{
|
|
#region Global Variables
|
|
|
|
/// <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 error log file path available to this class
|
|
/// </summary>
|
|
string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]);
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr;
|
|
|
|
/// <summary>
|
|
/// making Authentication Repository object available to this class
|
|
/// </summary>
|
|
AuthenticationRepository objAuthorization;
|
|
|
|
#endregion
|
|
|
|
#region Contructors
|
|
|
|
/// <summary>
|
|
/// Default constructor intialize connection string of vecv_godata database
|
|
/// </summary>
|
|
public RouteRepository(string connString)
|
|
{
|
|
this._connStr = connString;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region API Methods
|
|
|
|
/// <summary>
|
|
/// To get Routes detail list
|
|
/// </summary>
|
|
/// <returns>status and Routes detail list</returns>
|
|
public List<RouteModel> GetRouteDetail()
|
|
{
|
|
RouteModel objModel = new RouteModel();
|
|
List<RouteModel> objList = new List<RouteModel>();
|
|
try
|
|
{
|
|
DataSet ds = new DataSet();
|
|
objAuthorization = new AuthenticationRepository();
|
|
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_routes"]);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
objList = ds.Tables[0].AsEnumerable().Select(s => new RouteModel
|
|
{
|
|
Id = s.Field<int?>("id"),
|
|
Name = s.Field<string>("name"),
|
|
Alias = s.Field<string>("alias"),
|
|
Tagging = s.Field<string>("tagging"),
|
|
SlaTime = s.Field<int?>("sla_time")
|
|
}).ToList();
|
|
}
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetRouteDetail", Ex.Message, path, errorlogtf);
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |