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.EscalationMatrix;
namespace VECV_WebApi.Controllers.EscalationMatrix
{
public class EscalationMatrixController : ApiController
{
#region Global References
///
/// 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 EscalationMatrix Repository object available to this class
///
EscalationMatrixRepository objEscalationMatrixRepository;
///
/// making the Database connection string available to this class
///
/// To Insert, Update and get Escalation Matrix
///
/// escalation matrix info
/// status and data
public EscalationMatrixModel Post([FromBody]EscalationMatrixModel model)
{
// write data log into file
EscalationMatrixModel objModel = new EscalationMatrixModel();
try
{
objEscalationMatrixRepository = new EscalationMatrixRepository(_connStr);
if (model.Action.Trim().ToUpper() == "INSERT" || model.Action.Trim().ToUpper() == "UPDATE" || model.Action.Trim().ToUpper() == "DELETE" || model.Action.Trim().ToUpper() == "GET")
{
objModel = objEscalationMatrixRepository.InserUpdateGetEscalationMatrix(model);
}
else
{
objModel = objEscalationMatrixRepository.GetEscalationMatrix(model);
}
return objModel;
}
catch (Exception Ex)
{
// write error log into file
objModel.Status = "0";
objModel.Message = Ex.Message;
objLog.ErrorLogFile("GetDealerOpenTicketDetail_Controller", Ex.Message, path, errorlogtf);
return objModel;
}
}
public EscalationMatrixModel post([FromUri]string phone, [FromBody]EscalationPhoneNumber model)
{
EscalationMatrixModel objModel = new EscalationMatrixModel();
try
{
objEscalationMatrixRepository = new EscalationMatrixRepository(_connStr);
objModel = objEscalationMatrixRepository.UpdateEscalationPhoneNUmber(model);
return objModel;
}
catch (Exception Ex)
{
// write error log into file
objModel.Status = "0";
objModel.Message = Ex.Message;
objLog.ErrorLogFile("UpdateEscalationPhoneNumber", Ex.Message, path, errorlogtf);
return objModel;
}
}
#endregion
}
}