public ActionResult Index(string dashboard) { var model = new HomeIndexModel(); model.Tab = "Home"; model.Dashboard = dashboard ?? "My"; model.StartDate = DateTime.Today.ToStartOfWeek(); model.EndDate = DateTime.Today.ToEndOfWeek(); if (model.Dashboard == "Team") { model.Tasks = TaskService.TaskFetchInfoList( new TaskCriteria { IsArchived = false }); model.Hours = HourService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = FeedService.FeedFetchInfoList(5); } else { model.Tasks = MyService.TaskFetchInfoList(); model.Hours = MyService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = MyService.FeedFetchInfoList(5); } return(this.View(model)); }
public void Hour_Fetch_List() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); HourService.HourSave(hour); hour = HourService.HourNew(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); HourService.HourSave(hour); var hours = HourService.HourFetchInfoList(); Assert.IsTrue(hours.Count > 1, "Hours should be greater than one"); }
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)); }
public void Hour_Fetch_List() { BusinessHelper.CreateHourAndLogon( HourTestsWithRoleReview.UserName, HourTestsWithRoleReview.UserPassword); BusinessHelper.CreateHourAndLogon( HourTestsWithRoleReview.UserName, HourTestsWithRoleReview.UserPassword); Exception exception = null; try { HourService.HourFetchInfoList(); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception == null, "Exception should be null"); }
private void MapToModel(Task task, TaskFormModel model, bool ignoreBrokenRules) { Csla.Data.DataMapper.Map(task, model, true, "Labels"); model.Tab = "Task"; model.Statuses = DataHelper.GetStatusList(); model.Categories = DataHelper.GetCategoryList(); model.Projects = DataHelper.GetProjectList(); model.Sprints = DataHelper.GetSprintList(task.ProjectId); model.Users = DataHelper.GetUserList(); if (!task.IsNew) { model.Hours = HourService.HourFetchInfoList(task) .OrderBy(row => row.Date) .AsQueryable(); model.Invoices = InvoiceService.InvoiceFetchInfoList(task) .OrderByDescending(row => row.Number) .AsQueryable(); model.NoteListModel = new NoteListModel { Source = task, Notes = NoteService.NoteFetchInfoList(task).AsQueryable() }; model.LabelListModel = new LabelListModel { Action = "Task", Labels = task.TaskLabels.Select(row => row.Name) }; model.AttachmentListModel = new AttachmentListModel { Source = task, Attachments = AttachmentService.AttachmentFetchInfoList(task).AsQueryable() }; } switch (SettingHelper.LabelMode) { case ConfigurationMode.Simple: model.Labels = task.Labels; break; case ConfigurationMode.Advanced: model.Labels = task.TaskLabels.ToString(); break; default: break; } model.IsNew = task.IsNew; model.IsValid = task.IsValid; if (ignoreBrokenRules) { return; } foreach (var brokenRule in task.BrokenRulesCollection) { this.ModelState.AddModelError(string.Empty, brokenRule.Description); } }
public ActionResult Index(int[] projectId, int[] categoryId, int[] statusId, int?sprintId, int[] assignedTo, string completedDate, string modifiedDate, string createdDate, int?isArchived, string label, string text, string sortBy, string sortOrder) { var model = new TaskIndexModel(); model.Tab = "Task"; 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.Categories = DataHelper.GetCategoryList(); model.CategoryId = categoryId ?? new int[0]; model.CategoryName = DataHelper.ToString(model.Categories, model.CategoryId, "any category"); model.CategoryDisplayName = DataHelper.Clip(model.CategoryName, 20); model.Statuses = DataHelper.GetStatusList(); model.StatusId = statusId ?? new int[0]; model.StatusName = DataHelper.ToString(model.Statuses, model.StatusId, "any status"); model.StatusDisplayName = DataHelper.Clip(model.StatusName, 20); model.AssignedToUsers = DataHelper.GetUserList(); model.AssignedTo = assignedTo ?? new int[0]; model.AssignedToName = DataHelper.ToString(model.AssignedToUsers, model.AssignedTo, "any user"); model.AssignedToDisplayName = DataHelper.Clip(model.AssignedToName, 20); model.Label = label; model.IsArchived = isArchived ?? 0; model.Filters = MyService.FilterFetchInfoList("Task"); model.SortBy = sortBy ?? "TaskId"; model.SortOrder = sortOrder ?? "ASC"; model.SortableColumns.Add("EstimatedCompletedDate", "Due"); model.SortableColumns.Add("ProjectName", "Project"); model.SortableColumns.Add("AssignedToName", "User"); model.SortableColumns.Add("StatusName", "Status"); model.SortableColumns.Add("TaskId", "No."); model.LabelByCountListModel = new LabelByCountListModel { Action = "Task", Label = label, Labels = DataHelper.GetTaskLabelByCountList() }; var criteria = new TaskCriteria() { ProjectId = projectId, SprintId = sprintId, CategoryId = categoryId, StatusId = statusId, AssignedTo = assignedTo, CompletedDate = new DateRangeCriteria(completedDate ?? string.Empty), ModifiedDate = new DateRangeCriteria(modifiedDate ?? string.Empty), CreatedDate = new DateRangeCriteria(createdDate ?? string.Empty), IsArchived = DataHelper.ToBoolean(isArchived), TaskLabels = string.IsNullOrEmpty(label) ? null : new[] { label }, Text = text }; var tasks = TaskService.TaskFetchInfoList(criteria) .AsQueryable(); tasks = tasks.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder)); model.Tasks = tasks; var hours = HourService.HourFetchInfoList(tasks.Cast <ITask>().ToArray()); model.Hours = hours; return(RespondTo(format => { format[RequestExtension.Html] = () => this.View(model); format[RequestExtension.Xml] = () => new XmlResult { Data = model.Tasks.ToList(), TableName = "Task" }; format[RequestExtension.Json] = () => new JsonResult { Data = model.Tasks, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; })); }