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 = _expenseReportRepository.GetSingle(id); } ExpenseReportManageModel model = CreateViewModel(mode, expenseReport); model.IsReadOnly = !_workflowFacilitator.GetValidStateCommands(expenseReport, currentUser).Any(); ViewBag.ExpenseReport = expenseReport; ViewBag.CurrentUser = currentUser; return(View("Manage", model)); }
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 override void ExecuteResult(ControllerContext context) { IStateCommand[] commands = _facilitator.GetValidStateCommands(_expenseReport, _session.GetCurrentUser()); IStateCommand matchingCommand = Array.Find(commands, delegate(IStateCommand obj) { return(obj.Matches(_command)); }); matchingCommand.Execute(_visitor); context.Controller.TempData["Flash"] = _session.PopUserMessage(); }