using LoggingHelper;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using VECV_WebApi.Models.Notification;
namespace VECV_WebApi.Controllers.Notification
{
public class NotificationController : 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 the Database connection string available to this class
///
private string _connStr = ConfigurationManager.ConnectionStrings["Vecv_GoData"].ToString();
#endregion
#region APIs
///
/// To get kam notifications
///
/// notification info
/// status and data
public NotificationOutputModel Post([FromBody]NotificationInputModel model)
{
NotificationOutputModel oNotificationOutputModel = new NotificationOutputModel();
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
try
{
oNotificationOutputModel = oNotificationRepository.GetKamNotification(model);
return oNotificationOutputModel;
}
catch (Exception Ex)
{
oNotificationOutputModel.Status = "0";
oNotificationOutputModel.Message = Ex.Message;
return oNotificationOutputModel;
}
}
///
/// To get kam notifications
///
/// notification info
/// status and data
public NotificationOutputModel Post([FromUri]string deleteKamNotification,[FromBody]NotificationInputModel model)
{
NotificationOutputModel oNotificationOutputModel = new NotificationOutputModel();
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
try
{
oNotificationOutputModel = oNotificationRepository.DeleteKamNotification(model);
return oNotificationOutputModel;
}
catch (Exception Ex)
{
oNotificationOutputModel.Status = "0";
oNotificationOutputModel.Message = Ex.Message;
return oNotificationOutputModel;
}
}
// added by priya 20-04-2022
///
/// To get notification of ticket
///
/// ticket info
/// notification of ticket
public TicketWhatsupAPIModel Get([FromUri] string ticketId)
{
TicketWhatsupAPIModel objTicketWhatsupAPIModel = new TicketWhatsupAPIModel();
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
try
{
objTicketWhatsupAPIModel = oNotificationRepository.GetTicketStatusByTicketId(ticketId.Trim());
return objTicketWhatsupAPIModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetTicketNotification_Controller", Ex.Message, path, errorlogtf);
return objTicketWhatsupAPIModel;
}
}
public string Get([FromUri] string ticketId, [FromUri] string ticketdetails, [FromUri] string issearch)
{
TicketWhatsupAPIModel objTicketWhatsupAPIModel = new TicketWhatsupAPIModel();
string status = "";
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
try
{
status = oNotificationRepository.GetTicketStatusOpenCloseByTicketId(ticketId.Trim());
return status;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetTicketNotification_Controller", Ex.Message, path, errorlogtf);
return status;
}
}
///
/// To get notification of ticket
///
/// ticket info
/// notification of ticket
public TicketWhatsupAPIModel Get(Boolean ISVehicleRegisterNumber, [FromUri] string VehicleRegisterNumber)
{
TicketWhatsupAPIModel objTicketWhatsupAPIModel = new TicketWhatsupAPIModel();
NotificationRepository oNotificationRepository = new NotificationRepository(_connStr);
try
{
objTicketWhatsupAPIModel = oNotificationRepository.GetTicketStatusByRegistrationNumber(VehicleRegisterNumber.Trim());
return objTicketWhatsupAPIModel;
}
catch (Exception Ex)
{
// write error log into file
objLog.ErrorLogFile("GetTicketNotification_Controller", Ex.Message, path, errorlogtf);
return objTicketWhatsupAPIModel;
}
}
#endregion
}
}