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



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

            forumTarget.Units = result;

            GetSession.Save(forumTarget);
            string js = @"alert('עודכן בהצלחה')";
            return JavaScript(js);
        }
        public ActionResult Create(DocFormModel model, HttpPostedFileBase upload_file,FormCollection coll)
        {
            string tt = Request.Form["upload_text"];

            if (upload_file != null)
            {
                var uploaded_file = Guid.NewGuid();
                var u_file = upload_file.InputStream;
                int index = upload_file.FileName.IndexOf('.');
                string new_name = uploaded_file + "." + upload_file.FileName.Substring(index + 1);

                var path = Path.Combine(Server.MapPath("~/Public/userfiles/docs"), new_name);
                upload_file.SaveAs(path);
                model.Url = new_name;
            }
            else
            {
                model.Url = Request.Form["upload_text"];
            }


            var item = Mapper.Map<DocFormModel, Doc>(model);





            if (Request.Form["userSS"] != null)
            {
                item.UsersAllowed = Request.Form["userSS"].ToString();
            }


            if (Request.Form["Units[]"] != null)
            {
                item.Units = Request.Form["Units[]"].ToString();
            }
            if (string.IsNullOrEmpty(Request.Form["Units[]"]))
            {
                item.Units = "0";
            }

            if (coll["isAvailable2All"] == "on")
            {
                item.isAvailable2All = true;
            }
            else
            {
                item.isAvailable2All = false;
            }

            item.NotSubmited = GetSession.QueryOver<Employee>().RowCount().ToString();

            item.Submited = "0";
           

          
            GetSession.Save(item);

            return RedirectToAction("Index");
        }
        public ActionResult Edit(DocFormModel model, HttpPostedFileBase upload_file)
        {
            if (ModelState.IsValid)
            {
                var item = GetSession.Get<Doc>(model.Id);

                if (upload_file != null)
                {
                    var uploaded_file = Guid.NewGuid();
                    var u_file = upload_file.InputStream;
                    int index = upload_file.FileName.IndexOf('.');
                    string new_name = uploaded_file + "." + upload_file.FileName.Substring(index + 1);

                    var path = Path.Combine(Server.MapPath("~/Public/userfiles/docs"), new_name);
                    upload_file.SaveAs(path);
                    model.Url = new_name;
                }


                Mapper.Map<DocFormModel, Doc>(model, item);


                if (Request.Form["UsersListEdit"] != null)
                {
                    item.UsersAllowed = Request.Form["UsersListEdit"].ToString();
                }


                if (Request.Form["Units[]"] != null)
                {
                    item.Units = Request.Form["Units[]"].ToString();
                }
                if (string.IsNullOrEmpty(Request.Form["Units[]"]))
                {
                    item.Units = "0";
                }


                GetSession.Update(item);

                return RedirectToAction("Index");
            }
            return View(model);
        }
        public ActionResult Create()
        {
            //var myCustomerList = GetSession.QueryOver<Employee>().Select(x => x.Department.Id).List<Int64>().Distinct().ToArray();
            ViewBag.deps = new MultiSelectList(GetSession.QueryOver<Department>().List(), "Id", "Name");
            ViewBag.depsIds = GetSession.QueryOver<Department>().Select(x => x.Id);


           // IList<Employee> empsa = (IList<Employee>)Session["ViewBagusers"];

        

            //if (string.IsNullOrEmpty(Session["ids"].ToString()))
            //{

            //    Debug.WriteLine(Session["ids"]);
            //    string[] ids = Session["ids"].ToString().Split(',');
            //    ViewBag.users = new MultiSelectList(GetSession.QueryOver<Employee>().List().
            //         Where(x => x.Department.Id == Convert.ToInt64(ids[0])), "Id", "FirstName");
            //}

            var units = GetSession.QueryOver<Department>()
                      .OrderBy(x => x.Name).Asc
                      .List();
            ViewBag.alex = units.ToList();
            

            var model = new DocFormModel();
            return View(model);
        }