public ActionResult Edit(int id) { var timesheet = timesheetService.GetTimesheet(id); if (timesheet == null) { return(HttpNotFound()); } var canEdit = !(timesheet.CarerPaymentGenerated || timesheet.CustomerPaymentGenerated); var headerInfo = new Dictionary <string, string> { { "Booking", timesheet.Agreement.ID.ToString() }, { "Week Ending", timesheet.WeekEnding.ToShortDateString() }, { "Reference", timesheet.Reference }, { "Customer", $"{timesheet.Agreement.CustomerDisplayName} [{timesheet.Agreement.CustomerID}]" }, { "Care Recipient", $"{timesheet.Agreement.CareRecipientDisplayName}" + (timesheet.Agreement.CareRecipientID.HasValue ? $" [{timesheet.Agreement.CareRecipientID}]" : "") }, { "Payer", timesheet.Agreement.PayerDisplayName + (timesheet.Agreement.PayerId.HasValue ? $" [{timesheet.Agreement.PayerId}]" : "") }, { "Submitted By", timesheet.SubmittedBy } }; if (timesheet.SubmittedDate.HasValue) { headerInfo.Add("Submitted Date", timesheet.SubmittedDate.Value.ToString("g")); } ViewBag.CanEdit = canEdit; ViewBag.HeaderInfo = headerInfo; var model = TimesheetWeekViewModel.ToViewModel(timesheet); return(View(model)); }