public AlertAndNotificationModel GetAlertAndNotificationDetail(int AlertNotificationId)
        {
            if (ClientSessionData.UserClientId != 0)
            {
                try
                {
                    var AlertAndNotifications = _context.tblAlertAndNotifications.Where(x => x.Status == 1 && x.AlertNotificationId == AlertNotificationId).FirstOrDefault();
                    AlertAndNotificationModel alertAndNotificationModel = new AlertAndNotificationModel();
                    alertAndNotificationModel.AlertNotificationId = AlertAndNotifications.AlertNotificationId;
                    alertAndNotificationModel.MessageType         = AlertAndNotifications.MessageType;
                    alertAndNotificationModel.MessageTypeName     = AlertAndNotifications.MessageType == 1 ? "Emergency Alert" : AlertAndNotifications.MessageType == 2 ? "Broadcast Notification" : "N/A";
                    alertAndNotificationModel.Title     = AlertAndNotifications.Title;
                    alertAndNotificationModel.Message   = AlertAndNotifications.Message;
                    alertAndNotificationModel.CreatedOn = AlertAndNotifications.CreatedOn != null?AlertAndNotifications.CreatedOn.Value.ToString("dd MMM, yyyy") : "N/A";

                    return(alertAndNotificationModel);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
        public List <AlertAndNotificationModel> GetAllAlertAndNotification(int BlockNumber, int BlockSize)
        {
            if (ClientSessionData.UserClientId != 0)
            {
                int startIndex = (BlockNumber - 1) * BlockSize;
                List <AlertAndNotificationModel> alertAndNotificationModelList = new List <AlertAndNotificationModel>();
                try
                {
                    var AlertAndNotifications = _context.tblAlertAndNotifications.Where(x => x.StratasBoardId == ClientSessionData.ClientStrataBoardId && x.Status == 1).OrderByDescending(x => x.CreatedOn).ToList();
                    foreach (var item in AlertAndNotifications)
                    {
                        AlertAndNotificationModel alertAndNotificationModel = new AlertAndNotificationModel();
                        alertAndNotificationModel.AlertNotificationId = item.AlertNotificationId;
                        alertAndNotificationModel.MessageType         = item.MessageType;
                        alertAndNotificationModel.MessageTypeName     = item.MessageType == 1 ? "Emergency Alert" : item.MessageType == 2 ? "Broadcast Notification" : "N/A";
                        alertAndNotificationModel.Title     = item.Title;
                        alertAndNotificationModel.Message   = item.Message;
                        alertAndNotificationModel.CreatedOn = item.CreatedOn != null?item.CreatedOn.Value.ToString("dd MMM, yyyy") : "N/A";

                        alertAndNotificationModelList.Add(alertAndNotificationModel);
                    }
                }
                catch
                {
                }
                alertAndNotificationModelList = alertAndNotificationModelList.Skip(startIndex).Take(BlockSize).ToList();
                return(alertAndNotificationModelList);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        public ActionResult ViewLatestAlert(int AlertNotificationId)
        {
            AlertAndNotificationModel alertAndNotificationModel = new AlertAndNotificationModel();

            if (ClientSessionData.UserClientId != 0)
            {
                alertAndNotificationModel = noticeBoardHelper.GetAlertAndNotificationDetail(AlertNotificationId);
            }
            return(PartialView("ViewLatestAlert", alertAndNotificationModel));
        }
        public JsonResult ResendAlertAndNotification(int AlertAndNotificationId)
        {
            string strMsg = string.Empty;
            AlertAndNotificationModel model = noticeBoardHelper.GetAlertAndNotificationDetail(AlertAndNotificationId);
            int result = noticeBoardHelper.ResendAlertAndNotification(model);

            if (result == 1)
            {
                strMsg = "Alert has been sent successfully to Strata owners";
            }
            else
            {
                strMsg = "Alert has not been sent";
            }
            return(Json(new { result = result, Msg = strMsg }, JsonRequestBehavior.AllowGet));
        }
        public int AddUpdateAlertAndNotification(AlertAndNotificationModel alertAndNotificationModel)
        {
            int result = 0;

            try
            {
                tblAlertAndNotification tblAlertAndNotificationDb = new tblAlertAndNotification();
                tblAlertAndNotificationDb.Title       = alertAndNotificationModel.Title;
                tblAlertAndNotificationDb.Message     = alertAndNotificationModel.Message;
                tblAlertAndNotificationDb.MessageType = alertAndNotificationModel.MessageType;
                tblAlertAndNotificationDb.Status      = 1;

                tblAlertAndNotificationDb.CreatedBy      = ClientSessionData.UserClientId;
                tblAlertAndNotificationDb.CreatedOn      = DateTime.UtcNow;
                tblAlertAndNotificationDb.CreatedFromIP  = HttpContext.Current.Request.UserHostAddress;
                tblAlertAndNotificationDb.ModifiedBy     = ClientSessionData.UserClientId;
                tblAlertAndNotificationDb.ModifiedOn     = DateTime.UtcNow;
                tblAlertAndNotificationDb.ModifiedFromIP = HttpContext.Current.Request.UserHostAddress;
                tblAlertAndNotificationDb.StratasBoardId = ClientSessionData.ClientStrataBoardId;



                if (alertAndNotificationModel.AlertNotificationId > 0)
                {
                    tblAlertAndNotificationDb.AlertNotificationId = alertAndNotificationModel.AlertNotificationId;
                    _context.tblAlertAndNotifications.Attach(tblAlertAndNotificationDb);
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.Title).IsModified          = true;
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.Message).IsModified        = true;
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.MessageType).IsModified    = true;
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.ModifiedBy).IsModified     = true;
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.ModifiedOn).IsModified     = true;
                    _context.Entry(tblAlertAndNotificationDb).Property(x => x.ModifiedFromIP).IsModified = true;
                    result = _context.SaveChanges();
                }
                else
                {
                    _context.tblAlertAndNotifications.Add(tblAlertAndNotificationDb);
                    result = _context.SaveChanges();
                }
            }
            catch
            {
            }
            return(result);
        }
        public int ResendAlertAndNotification(AlertAndNotificationModel alertAndNotificationModel)
        {
            int result = 0;

            try
            {
                var StrataOwners = _context.tblUserClients.Where(x => x.StratasBoardId == ClientSessionData.ClientStrataBoardId && x.Status == 1 && x.RoleName == "O").ToList();
                if (StrataOwners != null && StrataOwners.Count > 0)
                {
                    foreach (var item in StrataOwners)
                    {
                        EmailSender.FncSendAlertAndNotification_ToStrataOwner(item.UserClientId, alertAndNotificationModel.MessageTypeName, alertAndNotificationModel.Title, alertAndNotificationModel.Message);
                    }
                    result = 1;
                }
            }
            catch
            {
            }
            return(result);
        }
        public ActionResult AddAlertAndNotification(AlertAndNotificationModel model)
        {
            int    result = 0;
            string strMsg = "";

            if (ModelState.IsValid)
            {
                result = noticeBoardHelper.AddUpdateAlertAndNotification(model);
                if (result == -1)
                {
                    strMsg = "Alert already exists for Common Area with given date";
                }
                else if (result == 1)
                {
                    strMsg = "Alert created successfully.";
                }
                else
                {
                    strMsg = "Alert creation failed.";
                }
            }
            return(Json(new { result = result, Msg = strMsg }));
        }
        public ActionResult EditAlertAndNotification(int AlertAndNotificationId)
        {
            AlertAndNotificationModel model = noticeBoardHelper.GetAlertAndNotificationDetail(AlertAndNotificationId);

            return(PartialView("EditAlertAndNotification", model));
        }
        public ActionResult AddAlertAndNotification()
        {
            AlertAndNotificationModel model = new AlertAndNotificationModel();

            return(PartialView("AddAlertAndNotification", model));
        }