402 lines
15 KiB
C#
402 lines
15 KiB
C#
namespace VECV_WebApi.Controllers.Dealer
|
|
{
|
|
#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.Authorization;
|
|
using VECV_WebApi.Models.Dealer;
|
|
using VECV_WebApi.Models.User;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// This cotroller contain apis releted to dealer
|
|
/// </summary>
|
|
public class DealerController : ApiController
|
|
{
|
|
#region Global References
|
|
|
|
/// <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 Dealer Repository object available to this class
|
|
/// </summary>
|
|
DealerRepository objDealerRepository;
|
|
|
|
/// <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 open ticket detail of dealer
|
|
/// </summary>
|
|
/// <param name="model">Dealer info</param>
|
|
/// <returns>open ticket details of dealer</returns>
|
|
public List<DealerOpenTicketDetailModel> Post([FromBody]DealerOpenTicketDetailModel model)
|
|
{
|
|
DealerOpenTicketDetailModel objModel = new DealerOpenTicketDetailModel();
|
|
List<DealerOpenTicketDetailModel> objList = new List<DealerOpenTicketDetailModel>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerOpenTicketDetail(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetDealerOpenTicketDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To get dealer list user-wise organization-wise
|
|
/// </summary>
|
|
/// <param name="obj">dealer info</param>
|
|
/// <param name="GetDealer">extra param to identify the api</param>
|
|
/// <returns>dealer list user-wise organization-wise</returns>
|
|
public List<DealerModelList> Post([FromBody]DealerModelList obj, [FromUri]string GetDealer)
|
|
{
|
|
|
|
List<DealerModelList> objList = new List<DealerModelList>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerListUserWiseOrgWise(obj);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerList", Ex.Message, path, errorlogtf);
|
|
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To get close ticket detail of dealer
|
|
/// </summary>
|
|
/// <param name="dealer">extra param to identify the api</param>
|
|
/// <param name="model">dealer info and date range</param>
|
|
/// <returns>close ticket detail of dealer</returns>
|
|
public List<DealerCloseTicketDetailModel> Post([FromUri] string dealer, [FromBody]DealerCloseTicketDetailModel model)
|
|
{
|
|
|
|
DealerCloseTicketDetailModel objModel = new DealerCloseTicketDetailModel();
|
|
List<DealerCloseTicketDetailModel> objList = new List<DealerCloseTicketDetailModel>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerCloseTicketDetail(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetDealerCloseTicketDetail_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To get notification of dealer
|
|
/// </summary>
|
|
/// <param name="notification">extra param to identify the api</param>
|
|
/// <param name="model">dealer information</param>
|
|
/// <returns>notification of dealer</returns>
|
|
public List<DealerNortificationModel> Post([FromUri] string notification, [FromBody]DealerNortificationModel model)
|
|
{
|
|
|
|
DealerNortificationModel objModel = new DealerNortificationModel();
|
|
List<DealerNortificationModel> objList = new List<DealerNortificationModel>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerNortification(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetDealerNortificationModel_Controller", Ex.Message, path, errorlogtf);
|
|
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To perform dealer related operations
|
|
/// </summary>
|
|
/// <param name="DealerDetail">extra param to identify the api</param>
|
|
/// <param name="model">dealer info</param>
|
|
/// <returns>status and data</returns>
|
|
public DealerDetailModel Post([FromUri]string DealerDetail, [FromBody]DealerDetailModel model)
|
|
{
|
|
|
|
DealerDetailModel objModel = new DealerDetailModel();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
|
|
// get Dealer details
|
|
if (DealerDetail.ToLower().Trim() == "get")
|
|
{
|
|
objModel = objDealerRepository.GetDealerDetailDealerIdWise(model);
|
|
}
|
|
// Get child dealers for a principal dealer
|
|
else if (DealerDetail.ToLower().Trim() == "getchilddealers")
|
|
{
|
|
objModel = objDealerRepository.GetChildDealerships(model);
|
|
}
|
|
// Get Principal dealership information
|
|
else if (DealerDetail.ToLower().Trim() == "getprincipaldealerdetails")
|
|
{
|
|
objModel = objDealerRepository.GetPrincipalDealershipDetails(model);
|
|
}
|
|
// Check Van exist or not by reg no.
|
|
else if (DealerDetail.ToLower().Trim() == "van")
|
|
{
|
|
objModel = objDealerRepository.CheckDealerOrVanStatusExistOrNot(model, DealerDetail);
|
|
}
|
|
// Check dealer exist or not by mob. no
|
|
else if (DealerDetail.ToLower().Trim() == "dealer")
|
|
{
|
|
objModel = objDealerRepository.CheckDealerOrVanStatusExistOrNot(model, DealerDetail);
|
|
}
|
|
// Adding principle dealership
|
|
else if (DealerDetail.ToLower().Trim() == "principledealer")
|
|
{
|
|
objModel = objDealerRepository.InsertOrUpdatePrincipleDealerDetail(model);
|
|
}
|
|
else
|
|
{
|
|
// insert or update dealer details
|
|
objModel = objDealerRepository.InsertOrUpdateDealerDetail(model);
|
|
}
|
|
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("controller InsertOrUpdateDealerDetail", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
public DealerOutputModel Post([FromUri]string Dealer, [FromUri]string DealerExistOrNot, [FromBody]DealerInputModel model)
|
|
{
|
|
// write data log into file
|
|
|
|
DealerOutputModel objModel = new DealerOutputModel();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objModel = objDealerRepository.GetDealerExistOrNot(model);
|
|
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetDealerExistOrNot", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// To get dealer postion detail with dealer detail
|
|
/// </summary>
|
|
/// <param name="model">dealer info</param>
|
|
/// <returns>status and data</returns>
|
|
public List<DealerPositionModel> Post([FromUri] int PositioningTool, [FromBody]GetDealerPositionModel model)
|
|
{
|
|
// write data log into file
|
|
|
|
List<DealerPositionModel> objList = new List<DealerPositionModel>();
|
|
DealerPositionModel objDealerModel = new DealerPositionModel();
|
|
try
|
|
{
|
|
DealerRepository objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerPositionDetail(model);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("DealerController post method no parameter", Ex.Message, path, errorlogtf);
|
|
|
|
objDealerModel.Status = "0";
|
|
objDealerModel.Message = Ex.Message;
|
|
objList.Add(objDealerModel);
|
|
}
|
|
return objList;
|
|
}
|
|
|
|
#region dealer list for dealer wise dashboard
|
|
|
|
/// <summary>
|
|
/// Get dealer list with user id of dealer for dealer wise dashboard
|
|
/// </summary>
|
|
/// <param name="obj">user model containing login user id</param>
|
|
/// <param name="dealerDashboard">extra param to identify the api</param>
|
|
/// <returns>dealer list with dealer's user id</returns>
|
|
public List<DealerUserIdList> Post([FromBody]UserModel obj, string dealerDashboard)
|
|
{
|
|
|
|
List<DealerUserIdList> objList = new List<DealerUserIdList>();
|
|
try
|
|
{
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objList = objDealerRepository.GetDealerListWithUserId(obj);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerListWithUserId", Ex.Message, path, errorlogtf);
|
|
|
|
return objList;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region reassign dealers own van
|
|
|
|
|
|
/// <summary>
|
|
/// To get van and dealer list state wise.
|
|
/// </summary>
|
|
/// <param name="ticket">extra param to identify the api</param>
|
|
/// <param name="ticket1">extra param to identify the api</param>
|
|
/// <param name="ticket2">extra param to identify the api</param>
|
|
/// <param name="ticket3">extra param to identify the api</param>
|
|
/// <param name="model">state info</param>
|
|
/// <returns>van and dealer list state wise</returns>
|
|
public List<DealerVanListStateWise> Post([FromUri]string ticket, [FromUri]string ticket1, [FromUri]string ticket2, [FromUri]string ticket3, [FromBody]DealerVanListStateWise model)
|
|
{
|
|
// write data log into file
|
|
try
|
|
{
|
|
|
|
List<DealerVanListStateWise> objList = new List<DealerVanListStateWise>();
|
|
DealerRepository objDealer = new DealerRepository(_connStr);
|
|
objList = objDealer.GetDealerVanListStateWise(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("DealerVanListStateWise_Controller", Ex.Message, path, errorlogtf);
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// To perform van contact number related operations
|
|
/// </summary>
|
|
/// <param name="DealerDetail">extra param to identify the api</param>
|
|
/// <param name="model">van info</param>
|
|
/// <returns>status and data</returns>
|
|
public DealerDetailModel Post([FromUri] string UserType,[FromUri] string UserType2, [FromBody]DealerDetailModel model)
|
|
{
|
|
// write data log into file
|
|
|
|
DealerDetailModel objModel = new DealerDetailModel();
|
|
try
|
|
{
|
|
string type = "van";
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
objModel = objDealerRepository.CheckVanContactDetailsExistOrNot(model, type);
|
|
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("controller CheckVanContactDetailsExistOrNot UserType2", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
public string Post([FromUri] string UserType, [FromUri] string UserType2, [FromUri] string Isdeleted, [FromBody] DealerDetailModel model)
|
|
{
|
|
// write data log into file
|
|
string msg = "";
|
|
DealerDetailModel objModel = new DealerDetailModel();
|
|
try
|
|
{
|
|
|
|
string type = "van";
|
|
objDealerRepository = new DealerRepository(_connStr);
|
|
msg = objDealerRepository.CheckVanContactDetailsExistOrNotIsdeleted(model, type);
|
|
|
|
return msg;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("contrller CheckVanContactDetailsExistOrNotIsdeleted", Ex.Message, path, errorlogtf);
|
|
return msg;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|