270 lines
10 KiB
C#
270 lines
10 KiB
C#
namespace VECV_WebApi.Controllers.Customer
|
|
{
|
|
#region Namespces
|
|
|
|
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.Customer;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// This controller
|
|
/// apis related to customer
|
|
/// </summary>
|
|
public class CustomerController : 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 Customer Repository object available to this class
|
|
/// </summary>
|
|
CustomerRepository objCustomerRepository;
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
|
|
|
|
#endregion
|
|
|
|
|
|
#region APIs
|
|
|
|
/// <summary>
|
|
/// To Insert new customer
|
|
/// </summary>
|
|
/// <param name="model">Customer detail</param>
|
|
/// <returns>Status details</returns>
|
|
public CustomerModel Post([FromBody]NewCustomerModel model)
|
|
{
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objModel = objCustomerRepository.InsertNewCustomerDetail(model);
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("InsertNewCustomerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To insert get Owner detail
|
|
/// </summary>
|
|
/// <param name="customer">Extra parameter to identify the API</param>
|
|
/// <param name="model">Owner id detail</param>
|
|
/// <returns>Owner details</returns>
|
|
public CustomerModel Post([FromUri]string customer, [FromBody]CustomerModel model)
|
|
{
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objModel = objCustomerRepository.GetOwnerDetail(model);
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetOwnerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
public CustomerModel Get(string token, string KamUser, string CustomerId, string CustomerType,string CustomerCustomerName, string RegistrationNo,string CustomerMobileNumber1, string VehicleNumberPlate, string VehicleType, string modelnumber)
|
|
{
|
|
NewCustomerModel model = new NewCustomerModel();
|
|
model.Token = token;
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objModel = objCustomerRepository.InsertNewCustomerDetailDBMByPass(token, RegistrationNo, VehicleNumberPlate, CustomerMobileNumber1, modelnumber, KamUser, VehicleType, CustomerCustomerName);
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("InsertNewCustomerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// To get owner or customer complete detail
|
|
/// </summary>
|
|
/// <param name="owner">Extra parameter to identify the API</param>
|
|
/// <param name="model">Customer/Owner Id information</param>
|
|
/// <returns>Customer/Owner complete details</returns>
|
|
public List<CustomerModel> post([FromUri]string owner, [FromBody]CustomerModel model)
|
|
{
|
|
List<CustomerModel> objList = new List<CustomerModel>();
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objList = objCustomerRepository.GetOwnerCompleteDetails(model);
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("GetOwnerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
objList.Add(objModel);
|
|
return objList;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To check customer or vehicle exist or not
|
|
/// </summary>
|
|
/// <param name="owner">extra parameter to identify the API</param>
|
|
/// <param name="type">extra parameter to identify the API</param>
|
|
/// <param name="model">customer iformation</param>
|
|
/// <returns>customer details</returns>
|
|
public CustomerModel Post([FromUri]string owner,[FromUri]string type, [FromBody]CustomerModel model)
|
|
{
|
|
// write data log into file
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objModel = objCustomerRepository.CheckOwnerDetailExist(model);
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("CustomerController CheckOwnerDetailExist", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To insert new owner with multiple customer or vehicle
|
|
/// </summary>
|
|
/// <param name="customer">extra param to identify the api</param>
|
|
/// <param name="owner">extra param to identify the api</param>
|
|
/// <param name="vehicle">extra param to identify the api</param>
|
|
/// <param name="model">customer/vehicle details with owner info</param>
|
|
/// <returns>statas details</returns>
|
|
public CustomerModel Post([FromUri]string customer, [FromUri]string owner, [FromUri]string vehicle, [FromBody]NewCustomerModel model)
|
|
{
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
objModel = objCustomerRepository.InsertOwnerCustomerVehicle(model);
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("CustomerController InsertOwnerCustomerVehicle", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// To get owner or customer complete detail
|
|
/// </summary>
|
|
/// <param name="owner">Extra parameter to identify the API</param>
|
|
/// <param name="model">Customer/Owner Id information</param>
|
|
/// <returns>Customer/Owner complete details</returns>
|
|
public List<VehicleRegistrationInfo> post([FromUri]int regNos, [FromBody]CustomerModel model)
|
|
{
|
|
List<VehicleRegistrationInfo> oListVehicleRegNos = new List<VehicleRegistrationInfo>();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
oListVehicleRegNos = objCustomerRepository.GetVehicleRegNoListByCustomerId(model);
|
|
return oListVehicleRegNos;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
throw Ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// To update customer
|
|
/// </summary>
|
|
/// <param name="model">Customer detail</param>
|
|
/// <returns>Status details</returns>
|
|
public CustomerModel Post([FromUri]string updatecustomer, [FromBody]NewCustomerModel model)
|
|
{
|
|
CustomerModel objModel = new CustomerModel();
|
|
try
|
|
{
|
|
objCustomerRepository = new CustomerRepository(_connStr);
|
|
// objModel = objCustomerRepository.InsertNewCustomerDetail(model);
|
|
objModel = objCustomerRepository.UpdateCustomerDetail(model);
|
|
|
|
|
|
return objModel;
|
|
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objModel.Status = "0";
|
|
objModel.Message = Ex.Message;
|
|
objLog.ErrorLogFile("InsertNewCustomerDetail_Controller", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|