/// <summary> /// This Function will Update alerts /// </summary> /// <param name="updateTo"></param> public void UpdateAlerts(bool updateTo) { try { using (var unitOfWork = new EFUnitOfWork()) { var boMAMAlertRepo = new BOMAMAlertRepository(new EFRepository <BOMAMAlert>(), unitOfWork); var context = ((CurrentDeskClientsEntities)boMAMAlertRepo.Repository.UnitOfWork.Context); var selectedAlert = context.BOMAMAlerts.FirstOrDefault(); //Check if the data has value if (selectedAlert != null) { //Update the database. selectedAlert.BOMAMIsAlert = updateTo; } context.SaveChanges(); } } catch (Exception exceptionMessage) { //Log Error and return false CommonErrorLogger.CommonErrorLog(exceptionMessage, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
/// <summary> /// This Function will help in getting alerts. /// </summary> /// <returns>boolean whether alert is available or not.</returns> public bool CheckAlerts() { try { using (var unitOfWork = new EFUnitOfWork()) { var boMAMAlertRepo = new BOMAMAlertRepository(new EFRepository <BOMAMAlert>(), unitOfWork); //return whether alerts is available or not. return(((CurrentDeskClientsEntities)boMAMAlertRepo.Repository.UnitOfWork.Context). BOMAMAlerts.Select(alert => alert.BOMAMIsAlert).FirstOrDefault() ?? false); } } catch (Exception exceptionMessage) { //Log Error and return false CommonErrorLogger.CommonErrorLog(exceptionMessage, System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }