예제 #1
0
        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);
            }
        }
예제 #2
0
파일: Lines.cs 프로젝트: valeriob/MyBudget
 internal void LoadUserInputFrom(EditBudgetLineViewModel model)
 {
     BudgetName      = model.BudgetName;
     BudgetId        = model.BudgetId;
     LineId          = model.LineId;
     Date            = model.Date;
     CurrencyISOCode = model.CurrencyISOCode;
 }
예제 #3
0
파일: Lines.cs 프로젝트: valeriob/MyBudget
 internal void LoadUserInputFrom(EditBudgetLineViewModel model)
 {
     BudgetName = model.BudgetName;
     BudgetId = model.BudgetId;
     LineId = model.LineId;
     Date = model.Date;
     CurrencyISOCode = model.CurrencyISOCode;
 }
예제 #4
0
        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);
        }
예제 #5
0
        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;
        }