Esempio n. 1
0
        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 ActionResult Create(CreateBudgetViewModel model)
        {
            var householdId = User.Identity.GetHouseholdId();

            if (ModelState.IsValid && householdId != null)
            {
                _budgetManager.Add(new Budget {
                    HouseholdId = householdId.Value, Duration = model.Duration
                });
            }
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
0
        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());
            }
        }