Esempio n. 1
0
        // GET: GLaccounts/Create
        public ActionResult Create(int?page, string ipp)
        {
            var mae = Session["itemSelecionado"] as String;
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);

            if (!hs.RootExists())
            {
                ViewBag.mensagem = "As root account";
            }
            else
            {
                try
                {
                    GLaccounts r = db.GLaccounts.Find(long.Parse(mae));
                    ViewBag.mensagem = "As last child of account " + mae + " (" + r.Name + ")";
                }
                catch (Exception)
                {
                    mae = "";
                }
                if (string.IsNullOrEmpty(mae))
                {
                    ModelState.AddModelError("", "Root exists. Please select parent account.");
                    ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
                    string    wc         = hs.WhereClause(recolhidas);
                    var       result     = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
                    //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
                    int pageNumber = (page ?? 1);
                    ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
                    return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
                }
            }
            return(View());
        }