public virtual ActionResult Create(string budgetId) { var budget = ProjectionManager.GetBudgetsList().GetBudgetById(new MyBudget.Domain.Budgets.BudgetId(budgetId)); var model = new CategoryViewModel { BudgetId = budgetId, BudgetName = budget.Name, Id = "Category-" + Guid.NewGuid().ToString(), Name = "New Category", Description = "Description", }; return View(model); }
public virtual ActionResult Edit(string budgetId, string categoryId) { var bid = new Domain.Budgets.BudgetId(budgetId); var category = ProjectionManager.GetCategories().GetBudgetsCategories(bid) .Single(r => r.Id == categoryId); var budget = ProjectionManager.GetBudgetsList().GetBudgetById(bid); var model = new CategoryViewModel { Id = categoryId, BudgetId = budgetId, BudgetName = budget.Name, Description = category.Description, Name = category.Name, }; return View(model); }
public virtual ActionResult Edit(CategoryViewModel model) { try { var handler = CommandManager.Create<UpdateCategory>(); handler(new UpdateCategory { UserId = GetCurrentUserId().ToString(), CategoryName = model.Name, CategoryDescription = model.Description, CategoryId = model.Id, Id = Guid.NewGuid(), Timestamp = DateTime.Now, }); return RedirectToAction(Actions.Index(model.BudgetId)); } catch { return View(); } }