127 lines
3.5 KiB
C#
127 lines
3.5 KiB
C#
|
|
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
|
|
|
|
/// <summary>
|
|
/// This controller contain ticket related api
|
|
/// </summary>
|
|
|
|
//[JwtAuthentication]
|
|
//[System.Web.Http.Authorize]
|
|
|
|
public class PreClosureController : 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"]);
|
|
|
|
string _appName = (ConfigurationManager.AppSettings["ApplicationName"]);
|
|
|
|
/// <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 customer details
|
|
/// </summary>
|
|
/// <param name="model">customer info</param>
|
|
/// <returns>customer details</returns>
|
|
///
|
|
|
|
[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<PreClosureModel> 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
|
|
}
|
|
} |