EOS-WebAPI/Controllers/Notification/NotificationController.cs
Nidhi Bhargava d0ac8a7790 Code Commit
2025-09-04 17:30:22 +05:30

172 lines
5.9 KiB
C#

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
/// <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"]);
/// <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 kam notifications
/// </summary>
/// <param name="model">notification info</param>
/// <returns>status and data</returns>
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;
}
}
/// <summary>
/// To get kam notifications
/// </summary>
/// <param name="model">notification info</param>
/// <returns>status and data</returns>
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
/// <summary>
/// To get notification of ticket
/// </summary>
/// <param name="model">ticket info</param>
/// <returns>notification of ticket</returns>
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;
}
}
/// <summary>
/// To get notification of ticket
/// </summary>
/// <param name="model">ticket info</param>
/// <returns>notification of ticket</returns>
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
}
}