public virtual ActionResult Create(EditBudgetLineViewModel model) { if (ModelState.IsValid) { try { var handler = CommandManager.Create<CreateLine>(); handler(model.PrepareCreateLine(GetCurrentUserId().ToString())); } catch (Exception ex) { ModelState.AddModelError("CurrencyISOCode", ex.Message); } } if (ModelState.IsValid) { return RedirectToAction(Actions.Index(model.BudgetId)); } else { var newmodel = Prepare_EditBudgetLineViewModel(model.BudgetId); newmodel.LoadUserInputFrom(model); return View(Views.Edit, newmodel); } }
internal void LoadUserInputFrom(EditBudgetLineViewModel model) { BudgetName = model.BudgetName; BudgetId = model.BudgetId; LineId = model.LineId; Date = model.Date; CurrencyISOCode = model.CurrencyISOCode; }
public virtual ActionResult Edit(string budgetId, string lineId) { var categories = ProjectionManager.GetCategories().GetBudgetsCategories(new Domain.Budgets.BudgetId(budgetId)); var budget = ProjectionManager.GetBudgetsList().GetBudgetById(new Domain.Budgets.BudgetId(budgetId)); var model = new EditBudgetLineViewModel(budget.Name, budget.Id, budget.CurrencyISOCode, ProjectionManager.GetStreamEvents(lineId), categories, budget.GetDistributionKeys(), Currencies.GetAll()); return View(model); }
EditBudgetLineViewModel Prepare_EditBudgetLineViewModel(string id) { var categories = ProjectionManager.GetCategories().GetBudgetsCategories(new Domain.Budgets.BudgetId(id)); var budget = ProjectionManager.GetBudgetsList().GetBudgetById(new Domain.Budgets.BudgetId(id)); var model = new EditBudgetLineViewModel(budget.Name, id, budget.CurrencyISOCode, categories, budget.GetDistributionKeys(), Currencies.GetAll()); return model; }