public JavaScriptResult UpdateUsers(ForumItemModel model, string[] users, long id)
        {
            string result = "";
            if (users != null)
            {
                if (users.Length > 0)
                {
                    result = string.Join(",", users);
                    //return Redirect("/ForumItems/");
                }
            }



            ForumItem forumTarget = GetSession.Get<ForumItem>(id);

            forumTarget.ForumUsers = result;

            GetSession.Save(forumTarget);

            #region ado.net
            //string theTitle = Request.Form["Title"];
            //long theAdmin = Convert.ToInt32(Request.Form["Admin"]);
            //long theId = Convert.ToInt32(Request.Form["Id"]);
            //bool theActive = (Request.Form["Active"] == "on") ? true : false;
            //SqlConnection sqlConnection1 = new SqlConnection(cs);
            //SqlCommand cmd = new SqlCommand();
            //Int32 rowsAffected;
            //cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "', ForumUsers = '" + result + "' WHERE Id = " + theId + "";
            ////cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "' WHERE Id = "+theId+"";
            //cmd.CommandType = CommandType.Text;
            //cmd.Connection = sqlConnection1;
            //sqlConnection1.Open();
            //rowsAffected = cmd.ExecuteNonQuery();
            //sqlConnection1.Close(); 
            #endregion
            //return RedirectToAction("index");
            string js = @"alert('עודכן בהצלחה')";
            return JavaScript(js);
        }
        public ActionResult Create(ForumItemModel model)
        {
            
            var results = Request.Form["ForumUsers[]"];
            long adminId;

            if (!string.IsNullOrEmpty(Request.Form["Admin"]))
            {
                adminId = Convert.ToInt64(Request.Form["Admin"]);
            }
            else
            {
                adminId = GetEmployeeId;
            }

            ForumItem newForum = new ForumItem()
            {

                Title = !string.IsNullOrEmpty(Request.Form["Title"]) ? Request.Form["Title"] : " פורום חדש",
                Active = (Request.Form["Active"] == "on") ? true : false,
                ForumUsers = Request.Form["ForumUsers[]"],



                Admin = GetSession.Get<Employee>(adminId)



            };

            GetSession.Save(newForum);
            #region ado.net



            //string theTitle = Request.Form["Title"];
            //long theAdmin = Convert.ToInt32(Request.Form["Admin"]);
            //bool theActive = (Request.Form["Active"] == "on") ? true : false;
            //SqlConnection sqlConnection1 = new SqlConnection(cs);
            //SqlCommand cmd = new SqlCommand();
            //Int32 rowsAffected;
            //cmd.CommandText = "INSERT into portal_ForumItem(Title,Active,Admin_id,ForumUsers) values ('" + theTitle + "', '" + theActive + "', " + theAdmin + ", '" + results + "')";
            //cmd.CommandType = CommandType.Text;
            //cmd.Connection = sqlConnection1;
            //sqlConnection1.Open();
            //rowsAffected = cmd.ExecuteNonQuery();
            //sqlConnection1.Close(); 
            #endregion
            return Redirect("/ForumItems/");
        }
        public ActionResult Update(ForumItemModel model)
        {




            ForumItem forumTarget = GetSession.Get<ForumItem>(Convert.ToInt64(Request.Form["Id"]));

            forumTarget.Admin = GetSession.Get<Employee>(Convert.ToInt64(Request.Form["Admin"]));
            forumTarget.Title = Request.Form["Title"];
            forumTarget.Active = (Request.Form["Active"] == "on") ? true : false;

            GetSession.Update(forumTarget);


            #region ADO.NET
            //string theTitle = Request.Form["Title"];
            //long theAdmin = Convert.ToInt32(Request.Form["Admin"]);
            //long theId = Convert.ToInt32(Request.Form["Id"]);
            //bool theActive = (Request.Form["Active"] == "on") ? true : false;
            //SqlConnection sqlConnection1 = new SqlConnection(cs);
            //SqlCommand cmd = new SqlCommand();
            //Int32 rowsAffected;
            //cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "' WHERE Id = " + theId + "";
            ////cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "' WHERE Id = "+theId+"";
            //cmd.CommandType = CommandType.Text;
            //cmd.Connection = sqlConnection1;
            //sqlConnection1.Open();
            //rowsAffected = cmd.ExecuteNonQuery();
            //sqlConnection1.Close();

            #endregion

            return Redirect("/ForumItems/");
        }
        public ActionResult Create()
        {
            var users = GetSession.QueryOver<Employee>().List();
            ViewBag.users = users;
            var model = new ForumItemModel();
            return View(model);

            ViewBag.list = GetSession.QueryOver<ForumItem>().List();
        }