Example #1
0
        public IActionResult Create()
        {
            var model = new CreatePermanentExpenseViewModel
            {
                CostTypes = GetAllCostTypes(),
            };

            return(View(model));
        }
Example #2
0
        public IActionResult Store(CreatePermanentExpenseViewModel costInfoViewModel)
        {
            var costType = _expenseFacade.GetItemType(costInfoViewModel.TypeId);
            var account  = CurrentAccountProvider.GetCurrentAccount(HttpContext.User);

            if (!ModelState.IsValid || costType == null || costType.AccountId != account.Id)
            {
                return(RedirectToAction("Create", new { errorMessage = ExpenseManagerResource.InvalidInputData }));
            }

            var costInfo = Mapper.Map <CostInfo>(costInfoViewModel);


            costInfo.AccountId = account.Id;

            _expenseFacade.CreateItem(costInfo);

            return(RedirectToAction("Index", new { successMessage = ExpenseManagerResource.ExpenseCreated }));
        }