Beispiel #1
0
        public ActionResult _EditAlertItem(int id)
        {
            try
            {
                ViewBag.Error        = "";
                ViewBag.SessionError = "";
                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();
                if (userData.UserId < 1)
                {
                    ViewBag.SessionError = "Your session has expired! Please re-login";
                    return(View(new AlertItemObj()));
                }
                if (id < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(View(new AlertItemObj()));
                }

                if (!(Session["_AlertItemList_"] is List <AlertItemObj> AlertItemList) || AlertItemList.Count < 1)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new AlertItemObj()));
                }

                var AlertItem = AlertItemList.Find(m => m.AlertItemId == id);
                if (AlertItem == null || AlertItem.AlertItemId < 1)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new AlertItemObj()));
                }

                Session["_CurrentSelAlertItem_"] = AlertItem;

                AlertItem.StatusVal = AlertItem.Status == 1;
                return(View(AlertItem));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error Occurred! Please try again later";
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new AlertItemObj()));
            }
        }