Пример #1
0
        public JsonResult GetTypeByCategoryID(int categoryID)
        {
            DictionaryRepository _repository = new DictionaryRepository();

            var data = _repository.GetTypes(categoryID).ToList();
            List <SelectListItem> list = new List <SelectListItem>();

            foreach (eArchiver.Models.Type type in data)
            {
                list.Add(new SelectListItem()
                {
                    Text  = type.Name,
                    Value = type.TypeID.ToString()
                });
            }

            return(Json(list));
        }
Пример #2
0
        public ActionResult AddType(FormCollection formValues)
        {
            string TypeName    = formValues["TypeName"];
            string sCategoryID = formValues["DictCategoryID"];

            int?DictCategoryID = null;
            int id;

            if (int.TryParse(sCategoryID, out id))
            {
                DictCategoryID = id;
            }

            List <eArchiver.Models.Type> types;

            if (DictCategoryID.HasValue)
            {
                int categoryID = DictCategoryID.Value;
                if (!string.IsNullOrEmpty(TypeName) && !_repository.TypeExists(TypeName, categoryID))
                {
                    _repository.CreateType(TypeName, categoryID);
                    _repository.SubmitChanges();
                }
                else
                {
                    TempData["Message"] = "Taki typ juz istnieje!";
                }
                types = _repository.GetTypes(DictCategoryID.Value).ToList();
            }
            else
            {
                types = new List <eArchiver.Models.Type>();
            }
            TypesDictViewModel viewModel = new TypesDictViewModel()
            {
                Categories       = _repository.GetCategories().ToList(),
                Types            = types,
                SelectedCategory = DictCategoryID
            };

            return(PartialView("TypesUserControl", viewModel));
        }
Пример #3
0
        public ActionResult Index(FormCollection formValues, int ItemsCount, int?p)
        {
            int?page        = p;
            int itemsOnPage = ItemsCount;

            if (formValues == null)
            {
                formValues = new FormCollection();
            }


            DocumentsSearchCriteria searchCriteria = new DocumentsSearchCriteria();

            if (!TryUpdateModel <DocumentsSearchCriteria>(searchCriteria, formValues.AllKeys))
            {
                searchCriteria = Session["doc_sc"] as DocumentsSearchCriteria;
            }
            if (searchCriteria == null)
            {
                searchCriteria = new DocumentsSearchCriteria();
            }

            DocumentsSortCriteria sortCriteria = new DocumentsSortCriteria();

            if (!TryUpdateModel <DocumentsSortCriteria>(sortCriteria, formValues.AllKeys))
            {
                sortCriteria = Session["doc_soc"] as DocumentsSortCriteria;
            }

            if (sortCriteria == null)
            {
                sortCriteria = new DocumentsSortCriteria();
            }

            DocumentsViewModel viewModel = new DocumentsViewModel()
            {
                DocumentSearchModel = new DocumentSearchViewModel()
                {
                    SearchCriteria    = searchCriteria,
                    SortCriteria      = sortCriteria,
                    SearchResults     = new PaginatedList <DocumentDetails>(_repository.SearchDocuments(searchCriteria).SortDocuments(sortCriteria).AsQueryable <DocumentDetails>(), page ?? 0, itemsOnPage),
                    IsSearchPerformed = true,
                    Categories        = _dictRepository.GetCategories().ToList(),
                    Senders           = _dictRepository.GetSenders().ToList(),
                    Types2            = _dictRepository.GetTypes2().ToList()
                }
            };


            Session["doc_sc"]  = searchCriteria;
            Session["doc_soc"] = sortCriteria;
            Session["doc_ic"]  = ItemsCount;
            Session["doc_p"]   = p;


            if (searchCriteria.CategoryID.HasValue)
            {
                viewModel.DocumentSearchModel.Types = _dictRepository.GetTypes(searchCriteria.CategoryID.Value).ToList();
            }

            return(View(viewModel));
        }