Пример #1
0
        public ActionResult Index(int[] projectId, int[] userId, int[] taskId, string date, int?isArchived, string label, string text, string sortBy, string sortOrder)
        {
            var model = new HourIndexModel();

            model.Tab          = "Hour";
            model.FindText     = text;
            model.FindCategory = "Hour";

            model.Projects           = DataHelper.GetProjectList();
            model.ProjectId          = projectId ?? new int[0];
            model.ProjectName        = DataHelper.ToString(model.Projects, model.ProjectId, "any project");
            model.ProjectDisplayName = DataHelper.Clip(model.ProjectName, 40);

            model.Users           = DataHelper.GetUserList();
            model.UserId          = userId ?? new int[0];
            model.UserName        = DataHelper.ToString(model.Users, model.UserId, "any user");
            model.UserDisplayName = DataHelper.Clip(model.UserName, 20);

            model.Label      = label;
            model.Date       = date ?? string.Empty;
            model.IsArchived = isArchived ?? 1;

            model.Filters = MyService.FilterFetchInfoList("Hour");

            model.SortBy    = sortBy ?? "Date";
            model.SortOrder = sortOrder ?? "DESC";
            model.SortableColumns.Add("Date", "Date");
            model.SortableColumns.Add("ProjectName", "Project");
            model.SortableColumns.Add("UserName", "User");

            model.LabelByCountListModel =
                new LabelByCountListModel
            {
                Action = "Hour",
                Label  = label,
                Labels = DataHelper.GetTaskLabelByCountList()
            };

            var criteria = new HourCriteria()
            {
                ProjectId  = projectId,
                UserId     = userId,
                TaskId     = taskId,
                Date       = new DateRangeCriteria(model.Date),
                IsArchived = DataHelper.ToBoolean(isArchived, false),
                TaskLabels = string.IsNullOrEmpty(label) ? null : new[] { label },
                Text       = text
            };

            var hours = HourService.HourFetchInfoList(criteria)
                        .AsQueryable();

            hours = hours.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder));

            model.Hours = hours;

            return(this.View(model));
        }
Пример #2
0
 public static HourInfoList HourFetchInfoList(HourCriteria criteria)
 {
     return(HourInfoList.FetchHourInfoList(criteria));
 }