namespace VECV_WebApi.Controllers.Ticket
{
#region Namespaces
using LoggingHelper;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using VECV_WebApi.Common;
using VECV_WebApi.Models.Customer;
using VECV_WebApi.Models.Dealer;
using VECV_WebApi.Models.EmailServices;
//using VECV_WebApi.Models.Sync;
using VECV_WebApi.Models.Ticket;
using VECV_WebApi.Models.Vehicle;
#endregion
///
/// This controller contain apis related to open ticket
/// ticketid
public class EPSNonHarvesterController : 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 Ticket Repository object available to this class
///
TicketRepository objTicketRepository;
///
/// making Ticket Repository object available to this class
///
GlobalRepository objGlobalRepository;
///
/// making the Database connection string available to this class
///
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
#endregion
#region APIs
public InsertOpenTicket Post([FromUri] string Ticket, [FromBody] InsertOpenTicket model)
{
try
{
InsertOpenTicket objModel = new InsertOpenTicket();
InsertOpenTicket objModel1 = new InsertOpenTicket();
DealerRepository obj = new DealerRepository(_connStr);
objModel1 = obj.getDelaerIdByState(model.StateName);
model.AssignedToUserId = objModel1.AssignedToUserId;
model.AssignedToUserLattitude = objModel1.AssignedToUserLattitude;
model.AssignedToUserLongitude = objModel1.AssignedToUserLongitude;
objTicketRepository = new TicketRepository(_connStr);
objModel = objTicketRepository.InsertOpenTicketNonHarvester(model);
//sending email to mulitiple people when ticket got created
// string isSend = objTicketRepository.sendEPSNewTicketmail(objModel.TicketId);
//if (isSend.ToLower().Trim() == "true")
//{
// objModel.Status = "1";
//}
//else
//{
// objModel.Status = "0";
//}
return objModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("EPSNonHarvester_Controller", Ex.Message, path, errorlogtf);
throw Ex;
}
}
#endregion
}
}