namespace VECV_WebApi.Controllers.Ticket
{
using DocumentFormat.OpenXml.EMMA;
using ExcelHelper;
#region Namespaces
using LoggingHelper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using System.Web.Http;
using System.Web.Mvc;
using VECV_WebApi.Common;
using VECV_WebApi.CommonAuthorization;
using VECV_WebApi.Models.Customer;
using VECV_WebApi.Models.EmailServices;
using VECV_WebApi.Models.PreClosure;
using VECV_WebApi.Models.Ticket;
using VECV_WebApi.Models.Vehicle;
#endregion
///
/// This controller contain ticket related api
///
//[JwtAuthentication]
//[System.Web.Http.Authorize]
public class PreClosureController : 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"]);
string _appName = (ConfigurationManager.AppSettings["ApplicationName"]);
///
/// making the Database connection string available to this class
///
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
#endregion
#region APIs
///
/// To get customer details
///
/// customer info
/// customer details
///
[JwtAuthentication]
[System.Web.Http.Authorize]
public string Post([FromBody] CogentDataModel model)
{
string json = "";
try
{
objLog.ErrorLogFile("Cogent Hit", model.ticket_number, path, errorlogtf);
PreClosureRepository objPreClosureRepository = new PreClosureRepository(_connStr);
string strscucess = objPreClosureRepository.InsertCogentComment(model);
//var response = new { success = true };
//json = JsonConvert.SerializeObject(response);
return "Added Successfully";
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("PreClosure cogent API", Ex.Message, path, errorlogtf);
var response = new { success = false, Error = Ex.Message };
json = JsonConvert.SerializeObject(response);
return "Not added";
}
}
[System.Web.Http.HttpPost]
[Route("api/save")]
public IHttpActionResult SaveRecords([FromBody] List records)
{
PreClosureRepository objPreClosureRepository = new PreClosureRepository(_connStr);
string strscucess = objPreClosureRepository.InserKAMData(records);
//using (var db = new YourDbContext())
//{
// db.MyRecords.AddRange(records);
// db.SaveChanges();
//}
return Ok(new { message = "Records received", count = records?.Count ?? 0 });
}
#endregion
}
}