namespace VECV_WebApi.Controllers.Dashboard
{
using ExcelHelper;
#region Namespaces
using LoggingHelper;
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.Dashboard;
#endregion
///
/// This controller contain APIs related to Dashboard
///
public class DashboardController : 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 the Database connection string available to this class
///
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
#endregion
#region APIs
///
/// To get tile dashboard KPIs
///
/// Date range and user information
/// Dashboard KPIs
public List Post([FromBody] DashboardModel model)
{
List objList = new List();
try
{
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
objList = ObjDashBoardRepository.GetTileDashboardDataSet(model);
}
catch (Exception Ex)
{
objList.Add(new DashboardModel
{
Status = "0",
Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message
});
// write error log into file
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
}
return objList;
}
public List Post([FromUri] string VECVUser,[FromBody] DashboardModel model)
{
List objList = new List();
try
{
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
objList = ObjDashBoardRepository.GetTileDashboardDataSetVECV(model);
}
catch (Exception Ex)
{
objList.Add(new DashboardModel
{
Status = "0",
Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message
});
// write error log into file
objLog.ErrorLogFile("DashboardController GetTileDashboardDataSet", Ex.Message, path, errorlogtf);
}
return objList;
}
///
/// To get closed/open ticket report.
///
/// extra param to idenify the api
/// ticket info
/// closed/open ticket report
public VECVTicketRequestModel Post([FromUri] string VECVUser,[FromUri] string TicketType, [FromBody] VECVTicketRequestModel model)
{
// write data log into file
VECVTicketRequestModel ObjModel = new VECVTicketRequestModel();
try
{
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
model.TicketType = TicketType;
ObjModel = ObjDashBoardRepository.GetOpenCloseTicketDetailVECV(model);
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetOpenCloseTicketDetail", Ex.Message, path, errorlogtf);
throw Ex;
}
return ObjModel;
}
///
/// To get open ticket detail of dealer
///
/// Dealer info
/// open ticket details of dealer
public VECVTicketRequestModel Post([FromUri] string VECVUser, [FromUri] string isdealer,[FromUri] string TicketType, [FromUri] string dealer,[FromBody] VECVTicketRequestModel model)
{ // write data log into file
VECVTicketRequestModel ObjModel = new VECVTicketRequestModel();
try
{
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
model.TicketType = TicketType;
ObjModel = ObjDashBoardRepository.GetDealerOpenTicketDetailVECV(model);
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetOpenCloseTicketDetail", Ex.Message, path, errorlogtf);
throw Ex;
}
return ObjModel;
// objList = objDealerRepository.GetDealerOpenTicketDetail(model);
}
public List Post([FromUri] string Sync, [FromUri] string VECVUser, [FromUri] string VECV, [FromBody] VECVSyncModel model)
{
VECVSyncModel objModel = new VECVSyncModel();
List objList = new List();
try
{
DashboardRepository ObjDashBoardRepository = new DashboardRepository(_connStr);
objList = ObjDashBoardRepository.GetSyncTicketDetail_VECV(model);
return objList;
}
catch (Exception Ex)
{
objList.Add(new VECVSyncModel
{
Status = "0",
Message = Ex.Message
});
return objList;
}
}
#endregion
}
}