public ActionResult Manage(string id, EditMode mode) { Employee currentUser = _session.GetCurrentUser(); ExpenseReport expenseReport; if (mode == EditMode.New) { expenseReport = _expenseReportBuilder.Build(currentUser); if (!string.IsNullOrEmpty(id)) { expenseReport.Number = id; } } else { expenseReport = _bus.Send(new ExpenseReportByNumberQuery { ExpenseReportNumber = id }).Result; } ExpenseReportManageModel model = CreateViewModel(mode, expenseReport); model.IsReadOnly = !_workflowFacilitator.GetValidStateCommands(new ExecuteTransitionCommand(expenseReport, null, currentUser, _calendar.GetCurrentTime())).Any(); ViewBag.ExpenseReport = expenseReport; ViewBag.CurrentUser = currentUser; return(View("Manage", model)); }
public ExpenseReport Build(Employee creator) { ExpenseReport expenseReport = new ExpenseReport(); expenseReport.Number = _numberGenerator.GenerateNumber(); expenseReport.Submitter = creator; expenseReport.CreatedDate = _calendar.GetCurrentTime(); expenseReport.Status = ExpenseReportStatus.Draft; return(expenseReport); }