public virtual ActionResult Create() { var model = new CreateBudgetViewModel { Id = BudgetId.Create().ToString(), Name = "New Budget", Currencies = MyBudget.Domain.ValueObjects.Currencies.GetAll(), }; return(View(model)); }
public void be_created() { var budgetId = BudgetId.Create(); var ownerId = UserId.CreateNew(); var budget = new Budget(); budget.Create(budgetId, "name", ownerId, Currencies.Euro().IsoCode); var events = budget.GetUncommittedEvents(); Assert.AreEqual(1, events.Count()); Assert.IsTrue(events.OfType <BudgetCreated>().Any()); }
public virtual ActionResult Create(CreateBudgetViewModel model) { try { var handler = CommandManager.Create <CreateBudget>(); handler(new CreateBudget { UserId = GetCurrentUserId().ToString(), BudgetName = model.Name, BudgetId = BudgetId.Create().ToString(), CurrencyISOCode = model.CurrencyISOCode, Id = Guid.NewGuid(), Timestamp = DateTime.Now, }); return(RedirectToAction("Index")); } catch { return(View()); } }