Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }