private void AddIssueToTimesheets(Issue issue) { //Created Timesheet Row based on Assigned and Favorites Issues var timesheetRow = new TimesheetRow { Timesheet = mTimesheet, IssueId = issue.Id, Issue = issue, TimesheetValues = new List<TimesheetValue>() }; //Add hours for next 7 days for (int i = 0; i < 7; i++) { TimesheetValue timesheetValue = new TimesheetValue { Date = mTimesheet.StartDate.AddDays(i), TimesheetRow = timesheetRow, Hours = 0 }; timesheetRow.TimesheetValues.Add(timesheetValue); } var timesheetRowModel = new IssueTimesheetRowModel(mView, timesheetRow, QuickIssues, mAdminCodes); mIssueTimesheetRowModels.Add(timesheetRowModel); mTimesheet.TimesheetRows.Add(timesheetRow); }
/// <summary> /// This will add Assigned and Favorited Issues and all codes under Timesheet Admin /// </summary> private void PopulateDefaultTimesheetRows() { mIssueTimesheetRowModels.Clear(); var getDefaultIssuesForTimesheet = DatabaseLoader.GetDefaultIssuesForTimesheet(mTimesheet.UserId); var getPreviousTimesheetReferences = DatabaseLoader.GetPreviousTimesheetReferences(mTimesheet.UserId, mTimesheet.StartDate); List<Task> tasks = new List<Task>(); tasks.Add(getDefaultIssuesForTimesheet); tasks.Add(getPreviousTimesheetReferences); Task.Factory.ContinueWhenAll(tasks.ToArray(), x => { //Add Admin Codes timesheets foreach (var adminCode in mAdminCodes) { //Created Timesheet Row based on Assigned and Favorites Issues var timesheetRow = new TimesheetRow { Timesheet = mTimesheet, TimesheetCodeId = adminCode.Id, TimesheetValues = new List<TimesheetValue>() }; //Add hours for next 7 days for (int i = 0; i < 7; i++) { TimesheetValue timesheetValue = new TimesheetValue { Date = mTimesheet.StartDate.AddDays(i), TimesheetRow = timesheetRow, Hours = 0 }; timesheetRow.TimesheetValues.Add(timesheetValue); } var timesheetRowModel = new IssueTimesheetRowModel(mView, timesheetRow, QuickIssues, mAdminCodes); mIssueTimesheetRowModels.Add(timesheetRowModel); mTimesheet.TimesheetRows.Add(timesheetRow); } foreach (var issue in getDefaultIssuesForTimesheet.Result) { AddIssueToTimesheets(issue); } //Set previous Reference Numbers if (getPreviousTimesheetReferences.Result.Any()) { foreach (var previousIsseuReference in getPreviousTimesheetReferences.Result) { var issueId = previousIsseuReference.Key; var referenceNumber = previousIsseuReference.Value; var timesheetRow = mTimesheet.TimesheetRows.FirstOrDefault(t => t.IssueId == issueId); if (timesheetRow != null) { timesheetRow.SystemReferenceNumber = referenceNumber; } } } CMS.UiFactory.StartNew(() => { mView.TelerikGrid.Rebind(); RaisePropertyChanged("IssueTimesheetRowModels"); RaisePropertyChanged("TotalHours"); RaisePropertyChanged("Week"); RaisePropertyChanged("User"); RaisePropertyChanged("LastModifiedBy"); OkButtonCommand.RaiseCanExecuteChanged(); SubmitButtonCommand.RaiseCanExecuteChanged(); AddIssueButtonCommand.RaiseCanExecuteChanged(); mView.IsBusyIndicator.IsBusy = false; }); }); }
public void SetBindingForNotes(TimesheetRow timesheetRow, int dayIndex) { mTimesheetValue = timesheetRow.TimesheetValues[dayIndex]; RaisePropertyChanged("Notes"); RaisePropertyChanged("NoteLabel"); }