public ActionResult LogOn(string UserName, string Password)
        {
            WASA_EMS_Entities ems_db = new WASA_EMS_Entities();

            if (UserName != null || Password != null)
            {
                User User = ems_db.Users.SingleOrDefault(item => item.UserName.Equals(UserName.Trim()));
                //IQueryable<User> user = from User in ems_db.Users where User.UserName.Equals(userName) select User;
                if (User != null)
                {
                    if (User.UserPassword.Trim().Equals(Password.Trim()))
                    {
                        var userLogged = (from u in ems_db.Users where u.UserName == UserName select u).FirstOrDefault();
                        int CompanyID  = Convert.ToInt32(userLogged.CompanyID);
                        Session["UserName"]  = User.UserName;
                        Session["CompanyID"] = CompanyID;
                        Session["UserID"]    = User.UserID;
                        return(RedirectToAction("Welcome", "Home"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
                ViewBag.Login       = false;
                ViewBag.message     = "The user name or password provided is incorrect.";
                ViewBag.messageType = "error";
                //return Content("false");
                return(View());
            }
            return(View());
        }
        //void sqlDep_OnChange(object sender, SqlNotificationEventArgs e)
        //{
        //    //or you can also check => if (e.Info == SqlNotificationInfo.Insert) , if you want notification only for inserted record
        //    if (e.Type == SqlNotificationType.Change)
        //    {
        //        SqlDependency sqlDep = sender as SqlDependency;
        //        sqlDep.OnChange -= sqlDep_OnChange;

        //        //from here we will send notification message to client
        //        var notificationHub = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
        //        notificationHub.Clients.All.notify("added");
        //        //re-register notification
        //        RegisterNotification(DateTime.Now);
        //    }
        //}

        public List <tblNotification> GetData(DateTime afterDate)
        {
            using (WASA_EMS_Entities dc = new WASA_EMS_Entities())
            {
                return(dc.tblNotifications.Where(a => a.notificationTime > afterDate).OrderByDescending(a => a.notificationTime).ToList());
            }
        }
        public ActionResult changePassword(FormCollection form)
        {
            string            username    = Session["UserName"].ToString().Trim();
            int               companyID   = Convert.ToInt32(Session["CompanyID"]);
            WASA_EMS_Entities db          = new WASA_EMS_Entities();
            User              u           = db.Users.Where(user => user.UserName == username).SingleOrDefault();
            string            currentPass = u.UserPassword.ToString().Trim();
            int               c_ID        = Convert.ToInt32(u.CompanyID);

            if (form["currentPassword"].ToString() == currentPass)
            {
                u.UserPassword = form["newPassword"];
                db.SaveChanges();
                return(RedirectToAction("LogOn"));
            }
            else
            {
                return(View());
            }
        }