Exemplo n.º 1
0
        public IActionResult DeleteNotification(Models.Notifications obj)
        {
            int uid = Convert.ToInt32(HttpContext.Session.GetString("uid"));


            if (uid == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (repObj.GetRoleId(uid) != "F")
            {
                if (repObj.GetRoleId(uid) == "E")
                {
                    return(RedirectToAction("EmployeeHome", "User"));
                }
                if (repObj.GetRoleId(uid) == "C")
                {
                    return(RedirectToAction("CustomerHome", "User"));
                }
            }
            int  cidn  = Convert.ToInt32(HttpContext.Session.GetString("uid"));
            int  nid   = obj.Nid;
            bool query = repObj.DeleteNotification(nid);

            if (query)
            {
                return(RedirectToAction("GetNotifications", "Farmer"));
            }
            return(View("Error"));
        }
Exemplo n.º 2
0
        // GET: Notifications
        public ActionResult Index()
        {
            if (Session["User"] != null)
            {
                Session["CurrentController"] = "Notifications";
                User user = (User)Session["User"];
                var  sl   = new SortedList <string, object>()
                {
                    { "SiteID", Convert.ToInt32(Session["SiteId"]) },
                    { "UserID", user.UserID }
                };
                var loDataTable = DataRepositoryControl.ExecuteTable("VMS_GetAllNotificationsDotNet", sl);
                Models.Notifications ViewModel = new Models.Notifications();
                ViewModel.Notification_Tables = loDataTable;

                int SiteID = Convert.ToInt32(Session["SiteId"]);
                var result = db.Database
                             .SqlQuery <AllNotificationsVM>("VMS_GetAllNotificationsDotNet @SiteID, @UserID",
                                                            new SqlParameter("@SiteID", SiteID),
                                                            new SqlParameter("@UserID", user.UserID)
                                                            ).ToList();


                Session["Notifications"] = result;

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public Models.Notifications Get()
        {
            Models.Notifications notifications;

            using (var db = new EntiTreesEntities())
            {
                var query = db.SelectAdminHomeNotifications().FirstOrDefault();
                notifications = new Models.Notifications
                {
                    activeItems    = query.ActiveItems.HasValue ? query.ActiveItems.Value : 0,
                    allItems       = query.AllItems.HasValue ? query.AllItems.Value : 0,
                    allContacts    = query.AllContacts.HasValue ? query.AllContacts.Value : 0,
                    openContacts   = query.OpenContacts.HasValue ? query.OpenContacts.Value : 0,
                    openOrders     = query.OpenOrders.HasValue ? query.OpenOrders.Value : 0,
                    allOrders      = query.AllOrders.HasValue ? query.AllOrders.Value : 0,
                    customersCount = query.CustomersCount.HasValue ? query.CustomersCount.Value : 0
                };

                return(notifications);
            }
        }