Exemplo n.º 1
0
        public ActionResult Categories(string submit)
        {
            action = submit.Split('.');

            switch (action[0])
            {
            case "New":
                return(RedirectToAction("NewCategory", "Category"));

            case "UpdCa":
                return(RedirectToAction("UpdCategory", "Category"));

            case "DelCa":
                using (var ef = new LibraryEntities())
                {
                    ef.DelCategory(Convert.ToInt32(action[1]));
                }
                return(RedirectToAction("Categories", "Category"));

            default:
                break;
            }

            return(RedirectToAction("Library", "Library"));
        }
Exemplo n.º 2
0
        public ActionResult Books(string submit)
        {
            action = submit.Split('.');

            switch (action[0])
            {
            case "New":
                return(RedirectToAction("NewBook", "Book"));

            case "UpdBk":
                return(RedirectToAction("UpdBook", "Book"));

            case "DelBk":
                using (var ef = new LibraryEntities())
                {
                    ef.DelCategory(Convert.ToInt32(action[1]));
                }
                return(RedirectToAction("Books", "Book"));

            case "Sort":
                switch (action[1])
                {
                case "id":
                    lstBooks = lstBooks.OrderBy(o => o.idBook).ToList();
                    break;

                case "name":
                    lstBooks = lstBooks.OrderBy(o => o.name).ToList();
                    break;

                case "author":
                    lstBooks = lstBooks.OrderBy(o => o.authors).ToList();
                    break;

                case "theme":
                    lstBooks = lstBooks.OrderBy(o => o.theme).ToList();
                    break;

                case "year":
                    lstBooks = lstBooks.OrderBy(o => o.year).ToList();
                    break;

                case "category":
                    lstBooks = lstBooks.OrderBy(o => o.catName).ToList();
                    break;

                default:
                    break;
                }
                return(View(lstBooks));

            default:
                break;
            }

            return(RedirectToAction("Library", "Library"));
        }