Пример #1
0
        public ActionResult EditLibrarian(LibrarianEditModel model)
        {
            if (ModelState.IsValid)
            {
                LibrarianBs bs = new LibrarianBs();

                var result = bs.Update((LibrarianDataDTO)model);

                if (result.Code == BusinessLayer.OperationStatusEnum.Success)
                {
                    TempData["OperationStatus"] = true;
                    TempData["OpearionMessage"] = "Данные успешно обновлены";
                }
                else
                {
                    TempData["OperationStatus"] = false;
                    TempData["OpearionMessage"] = "Произошла ошибка при обновлении данных";
                }

                return(RedirectToAction("Librarians", "Admin"));
            }

            LibraryBs libbs = new LibraryBs();

            model.Libraries = libbs.GetList().Select(c => (LibraryModel)c).ToList();

            return(View(model));
        }
Пример #2
0
        public ActionResult DepartmentListByLib(int id = 0)
        {
            DepartmentBs bs = new DepartmentBs();

            if (id != 0)
            {
                List <DepartmentModel> model = bs.GetList().Where(c => c.LibraryId == id).Select(c => (DepartmentModel)c).ToList();

                return(PartialView("~/Views/Shared/_DepartmentDropdown.cshtml", model));
            }
            else
            {
                int       libId = 0;
                LibraryBs lbs   = new LibraryBs();
                var       lib   = lbs.GetList().FirstOrDefault();

                if (lib != null)
                {
                    libId = lib.Id;
                }

                List <DepartmentModel> model = bs.GetList().Where(c => c.LibraryId == id).Select(c => (DepartmentModel)c).ToList();
                return(PartialView("~/Views/Shared/_DepartmentDropdown.cshtml", model));
            }
        }
Пример #3
0
        public ActionResult EditDepartment(EditDepartmentModel model)
        {
            if (ModelState.IsValid)
            {
                DepartmentBs bs = new DepartmentBs();

                var result = bs.Update((DepartmentDTO)model);

                if (result.Code == BusinessLayer.OperationStatusEnum.Success)
                {
                    TempData["OperationStatus"] = true;
                    TempData["OpearionMessage"] = "Операция завершена упешно";
                }
                else
                {
                    TempData["OperationStatus"] = false;
                    TempData["OpearionMessage"] = "Ошибка при выполнении операции";
                }

                return(RedirectToAction("Departments", "Admin"));
            }

            LibraryBs libBs = new LibraryBs();

            model.Libraries = libBs.GetList().Select(c => (LibraryModel)c).ToList();
            return(View(model));
        }
Пример #4
0
        public ActionResult AddBook()
        {
            BookBs   bs       = new BookBs();
            AuthorBs authorBs = new AuthorBs();

            BookEditModel model = new BookEditModel();

            model.Book    = new BookModel();
            model.Authors = authorBs.GetList().Select(c => (AuthorModel)c).ToList();
            LibraryBs libraryBs = new LibraryBs();

            model.Libraries = libraryBs.GetList().Select(c => (LibraryModel)c).ToList();
            DepartmentBs departmentBs = new DepartmentBs();

            var lib = model.Libraries.FirstOrDefault();

            if (lib != null)
            {
                model.SelectedLib = lib.Id;
                var departments = departmentBs.GetList().Where(c => c.LibraryId == model.SelectedLib).ToList();

                if (departments != null)
                {
                    model.Departments = departments.Select(c => (DepartmentModel)c).ToList();
                }
            }

            return(View(model));
        }
Пример #5
0
        public ActionResult LibrariesList(string symbols = "")
        {
            LibraryBs           library = new LibraryBs();
            List <LibraryModel> model   = library.GetList().Where(c => c.Name.Contains(symbols)).Select(c => (LibraryModel)c).ToList();

            return(PartialView("~/Views/Admin/_LibrariesList.cshtml", model));
        }
Пример #6
0
        public ActionResult AddLibrarian()
        {
            LibrarianEditModel model = new LibrarianEditModel();

            LibraryBs libbs = new LibraryBs();

            model.Libraries = libbs.GetList().Select(c => (LibraryModel)c).ToList();

            return(View(model));
        }
Пример #7
0
        public ActionResult EditLibrarian(int id)
        {
            LibrarianBs librarianBs = new LibrarianBs();

            LibrarianEditModel model = (LibrarianEditModel)librarianBs.GetById(id);

            LibraryBs libbs = new LibraryBs();

            model.Libraries = libbs.GetList().Select(c => (LibraryModel)c).ToList();

            return(View(model));
        }
Пример #8
0
        public ActionResult AddDepartment()
        {
            LibraryBs libBs = new LibraryBs();

            EditDepartmentModel model = new EditDepartmentModel();

            model.Libraries = libBs.GetList().Select(c => (LibraryModel)c).ToList();

            if (model.Libraries != null && model.Libraries.Count > 0)
            {
                model.LibraryId = model.Libraries.FirstOrDefault().Id;
            }

            return(View(model));
        }
Пример #9
0
        public ActionResult EditBook(int id)
        {
            BookBs   bs       = new BookBs();
            AuthorBs authorBs = new AuthorBs();

            BookEditModel model = new BookEditModel();

            model.Book    = (BookModel)bs.GetById(id);
            model.Authors = authorBs.GetList().Select(c => (AuthorModel)c).ToList();
            LibraryBs libraryBs = new LibraryBs();

            model.Libraries = libraryBs.GetList().Select(c => (LibraryModel)c).ToList();

            if (model.Book.DepartmentId.HasValue && model.Book.DepartmentId.Value > 0)
            {
                DepartmentBs departmentBs = new DepartmentBs();
                if (model.SelectedLib == 0)
                {
                    model.SelectedLib = departmentBs.GetById(model.Book.DepartmentId.Value).LibraryId;
                }
                var departments = departmentBs.GetList().Where(c => c.LibraryId == model.SelectedLib).ToList();

                if (departments != null)
                {
                    model.Departments = departments.Select(c => (DepartmentModel)c).ToList();
                }
            }
            else
            {
                DepartmentBs departmentBs = new DepartmentBs();

                var lib = model.Libraries.FirstOrDefault();

                if (lib != null)
                {
                    model.SelectedLib = lib.Id;
                    var departments = departmentBs.GetList().Where(c => c.LibraryId == model.SelectedLib).ToList();

                    if (departments != null)
                    {
                        model.Departments = departments.Select(c => (DepartmentModel)c).ToList();
                    }
                }
            }

            return(View(model));
        }