/// <summary> /// Office文档 /// </summary> /// <param name="page"></param> /// <returns></returns> public ActionResult Office(int?page) { _logger.Info("Office文档列表"); if (page == null || page == 0) { page = 1; } var documents = _documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId, f => f.DocumentCategory == DocumentCategory.Office); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection( documents.Take(page.Value * PageService.PageShowCount).Skip((page.Value - 1) * PageService.PageShowCount).ToList(), _contextService.UserId), ActiveMenuType = MenuType.Office, PageCode = PageService.GetPageCode(documents.Count, page.Value, "Document/Office") }; CurrentMenu = MenuType.Office; return(View(model)); }
// GET: Documents public ActionResult Index(int?type, int?executor, DateTime?firstDate, DateTime?secondDate, int page = 1) { var user = db.Users.FirstOrDefault(item => item.Login == User.Identity.Name); var documents = db.Documents.Include(d => d.Class).Include(d => d.Executor).Include(d => d.User); var role = db.Roles.FirstOrDefault(item => item.Id == user.RoleId); if (role.Name == "user" || role.Name == "employee") { documents = documents.Where(item => item.User.Id == user.Id || item.Executor.Id == user.Id); } if (role.Name == "manager") { documents = documents.Where(item => (item.User.DepartmentId == user.DepartmentId || item.Executor.DepartmentId == user.DepartmentId)); } if (executor != null && executor != 0) { documents = documents.Where(item => item.ExecutorId == executor); } if (type != null && type != 0) { documents = documents.Where(item => item.ClassId == type); } if (firstDate != null) { documents = documents.Where(item => item.CreationTime >= firstDate); } if (secondDate != null) { documents = documents.Where(item => item.CreationTime <= secondDate); } var types = db.Classes.ToList(); types.Insert(0, new Class { Name = "Все", Id = 0 }); var executors = db.Users.ToList(); executors.Insert(0, new User { Name = "Все", Id = 0 }); int pageSize = 5; IEnumerable <Document> documentsPerPages = documents.ToList().Skip((page - 1) * pageSize).Take(pageSize); PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = documents.Count() }; DocumentViewModel dvm = new DocumentViewModel { Classes = new SelectList(types, "Id", "Name"), Executors = new SelectList(executors, "Id", "Name"), Documents = documentsPerPages.ToList() }; DocumentIndexViewModel ivm = new DocumentIndexViewModel { PageInfo = pageInfo, Documents = dvm }; return(View(ivm)); }
public ActionResult Index(DocumentIndexViewModel documentIndexViewModel) { ViewBag.Title = "Home"; var getDoc = ListAllDocuments(db); SelectList list = new SelectList(getDoc, "Tag", "Tag"); ViewBag.Document = ListAllDocuments(db); documentIndexViewModel.DocumentViewModels = Mapper.Map<IEnumerable<Document>, IEnumerable<DocumentViewModel>>(SearchDocument(documentIndexViewModel, db).ToList()); _document = SearchDocument(documentIndexViewModel, db).ToList(); return View(documentIndexViewModel); }
public ActionResult Index() { ViewBag.Title = "Home"; DocumentIndexViewModel documentIndexViewModel = new DocumentIndexViewModel(); documentIndexViewModel.DocumentViewModels = Mapper.Map<IEnumerable<Document>, IEnumerable<DocumentViewModel>>(ListAllDocuments(db)); var getDoc = ListAllDocuments(db); _document = getDoc; SelectList list = new SelectList(getDoc, "Tag", "Tag"); ViewBag.docListName = list; return View(documentIndexViewModel); }
/// <summary> /// 最近的文档 /// </summary> /// <returns></returns> public ActionResult Recent() { _logger.Info("最近的文档"); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection(_documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId), _contextService.UserId), ActiveMenuType = MenuType.Recent, }; CurrentMenu = MenuType.Recent; return(View(model)); }
/// <summary> /// Search by Filter Date and Keyword /// </summary> /// <param name="documentIndexViewModel"></param> /// <param name="db"></param> /// <returns>DocumentList</returns> public static List <Document> SearchDocument(DocumentIndexViewModel documentIndexViewModel, ApplicationDbContext db) { var documents = from s in db.Documents select s; if (!documentIndexViewModel.FromDate.Equals(null) && !documentIndexViewModel.ToDate.Equals(null) && String.IsNullOrEmpty(documentIndexViewModel.Search)) { documents = db.Documents.Where(x => x.CreateDate >= documentIndexViewModel.FromDate && x.CreateDate <= documentIndexViewModel.ToDate); } else if (!documentIndexViewModel.FromDate.Equals(null) && !documentIndexViewModel.ToDate.Equals(null) && !String.IsNullOrEmpty(documentIndexViewModel.Search)) { documents = db.Documents.Where(x => x.CreateDate >= documentIndexViewModel.FromDate && x.CreateDate <= documentIndexViewModel.ToDate && x.Tag.Contains(documentIndexViewModel.Search)); } else if (!string.IsNullOrEmpty(documentIndexViewModel.Search)) { documents = documents.Where(s => s.Tag.Contains(documentIndexViewModel.Search)); } return(documents.ToList()); }
/// <summary> /// 图片 /// </summary> /// <param name="page"></param> /// <returns></returns> public ActionResult Image(int?page) { _logger.Info("图片列表"); if (page == null || page == 0) { page = 1; } var documents = _documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId, f => f.DocumentCategory == DocumentCategory.Image); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection( documents, _contextService.UserId), ActiveMenuType = MenuType.Image, PageCode = PageService.GetPageCode(documents.Count, page.Value, "Document/Image") }; CurrentMenu = MenuType.Image; return(View(model)); }
/// <summary> /// 最近的文档 /// </summary> /// <returns></returns> public ActionResult Recent() { _logger.Info("最近的文档"); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection(_documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId),_contextService.UserId), ActiveMenuType = MenuType.Recent, }; CurrentMenu = MenuType.Recent; return View(model); }
/// <summary> /// Office文档 /// </summary> /// <param name="page"></param> /// <returns></returns> public ActionResult Office(int? page) { _logger.Info("Office文档列表"); if (page == null || page == 0) { page = 1; } var documents = _documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId, f=>f.DocumentCategory == DocumentCategory.Office); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection( documents.Take(page.Value * PageService.PageShowCount).Skip((page.Value - 1) * PageService.PageShowCount).ToList(), _contextService.UserId), ActiveMenuType = MenuType.Office, PageCode = PageService.GetPageCode(documents.Count, page.Value, "Document/Office") }; CurrentMenu = MenuType.Office; return View(model); }
/// <summary> /// 图片 /// </summary> /// <param name="page"></param> /// <returns></returns> public ActionResult Image(int? page) { _logger.Info("图片列表"); if (page == null || page == 0) page = 1; var documents = _documentService.GetVisibleDocuments(_contextService.UserId, _contextService.DepId, f=>f.DocumentCategory == DocumentCategory.Image); var model = new DocumentIndexViewModel { DocumentModels = new DocumentViewModelCollection( documents, _contextService.UserId), ActiveMenuType = MenuType.Image, PageCode = PageService.GetPageCode(documents.Count, page.Value, "Document/Image") }; CurrentMenu = MenuType.Image; return View(model); }