public TaskViewModel GetTaskViewModel(string searchString = null, int pageNumber = 1) { var pageSize = 6; var role = HttpContext.Session.GetString("role"); IList <ToDoTask> temp = new List <ToDoTask>(); if (role.Equals("manager")) { temp = _unitOfWork.ToDoTasks.GetAll(); } else { temp = _unitOfWork.ToDoTasks.GetTasksForUser(HttpContext.Session.GetInt32("id").GetValueOrDefault()); } if (searchString == null || searchString.Equals("")) { tasks = PaginatedList <ToDoTask> .Create(temp, pageNumber, pageSize); } else { var searchResult = _service.Search(temp, searchString, null); tasks = PaginatedList <ToDoTask> .Create(searchResult, pageNumber, pageSize); } TaskViewModel taskView = new TaskViewModel(tasks); return(taskView); }
private void SearchItem() { var search = this.txtSearch.Text; var priceFrom = this.numberFrom.Value; var priceTo = this.numberTo.Value; var types = this.checkedTypeBox.CheckedItems.OfType <ItemType> ().Select(m => m.Type).ToList(); _itemSearch = _searchSortService.Search(_items, search, types, priceFrom, priceTo); }
public HomeViewModel GetViewModel(IList <EnumCheckBox> CheckBoxValues, int pageNumber = 1, string searchString = null) { var pageSize = 100; var itemSearch = items; var comboSearch = combos; var listTypes = CheckBoxValues.Where(m => m.IsSelected.Equals(true)).Select(m => m.types).ToList(); if (listTypes != null && listTypes.Count() > 0) { itemSearch = _service.Search(items, null, listTypes); comboSearch = _service.Search(combos, null, listTypes); ViewData["Title"] = ""; foreach (var type in listTypes) { if (!type.Equals(ITEM_TYPE.COMBO)) { if (listTypes.IndexOf(type).Equals(listTypes.Count() - 1)) { ViewData["Title"] += EnumConverter.Convert(type); } else { ViewData["Title"] += EnumConverter.Convert(type) + "/ "; } } } } if (searchString != null) { itemSearch = _service.Search(itemSearch, searchString); comboSearch = _service.Search(comboSearch, searchString); } item_paging = PaginatedList <Item> .Create(itemSearch, pageNumber, pageSize); combo_paging = PaginatedList <Item> .Create(comboSearch, pageNumber, pageSize); var result = new HomeViewModel(); result.items = item_paging; result.combos = combo_paging; result.CheckBoxValues = CheckBoxValues; return(result); }
private void SearchOrder() { DateTime dateFrom = dateStart.Value.Date; DateTime dateTo = dateEnd.Value.Date; var check = comboStatus.SelectedItem as OrderStatus?; ORDER_STATUS?status; if (check.HasValue) { status = check.Value.Status; } else { status = null; } _orderSearch = _searchSortService.Search(_orders, dateFrom, dateTo, status); }
public LogViewModel GetViewModel(int pageNumber = 1, string value = null, string action = null) { var pageSize = 10; LogViewModel result = new LogViewModel(); IList <DbLog> temp = new List <DbLog>(); logs = _unitOfWork.DbLogs.GetAll(); if (value == null || action == null) { logs = _service.Sort(logs, SORT_ORDER.DESCENDING); logPaging = PaginatedList <DbLog> .Create(logs, pageNumber, pageSize); } else { switch (action) { case "DateExec": var date = DateTime.ParseExact(value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); temp = _service.Search(logs, null, null, null, date, SEARCH_SORT_TYPE.EXEC_DATE); break; case "TaskName": temp = _service.Search(logs, value, null, null, DateTime.Now, SEARCH_SORT_TYPE.TASK_NAME); break; case "UserName": temp = _service.Search(logs, value, null, null, DateTime.Now, SEARCH_SORT_TYPE.EXEC_USER_NAME); break; case "TaskId": var id = Int32.Parse(value); temp = _service.Search(logs, null, id, null, DateTime.Now, SEARCH_SORT_TYPE.TASK_ID); break; case "UserId": var userId = Int32.Parse(value); temp = _service.Search(logs, null, userId, null, DateTime.Now, SEARCH_SORT_TYPE.EXEC_USER_ID); break; case "Action": var val_enum = Int32.Parse(value); if (val_enum.Equals(0)) { temp = _service.Search(logs, null, null, ACTION.ADD, DateTime.Now, SEARCH_SORT_TYPE.ACTION); } else { if (val_enum.Equals(1)) { temp = _service.Search(logs, null, null, ACTION.DELETE, DateTime.Now, SEARCH_SORT_TYPE.ACTION); } else { if (val_enum.Equals(2)) { temp = _service.Search(logs, null, null, ACTION.UPDATE, DateTime.Now, SEARCH_SORT_TYPE.ACTION); } else { if (val_enum.Equals(3)) { temp = _service.Search(logs, null, null, ACTION.CHANGE_STATUS, DateTime.Now, SEARCH_SORT_TYPE.ACTION); } else { if (val_enum.Equals(4)) { temp = _service.Search(logs, null, null, ACTION.CHANGE_SCOPE, DateTime.Now, SEARCH_SORT_TYPE.EXEC_DATE); } } } } } break; } temp = _service.Sort(temp, SORT_ORDER.DESCENDING); logPaging = PaginatedList <DbLog> .Create(temp, pageNumber, pageSize); // 1. Ngày thực hiện // 2.Tên công việc // 3. Người thực hiện // 4. ID công việc // 5. Id người thực hiện // 6. Hành động } result.Logs = logPaging; result.taskIds = taskIds; result.userIds = userIds; result.userNames = userNames; return(result); }