private async Task SetTransactionFormsDropdowns(NewTransactionModel transaction)
 {
     transaction.Currencies = await this._transactionService.GetCurrenciesSelection();
     transaction.Categories = await this._transactionService.GetCategoriesSelection(transaction.Expense);
     transaction.Budgets = await this._transactionService.GetBudgetsSelection(await this.CurrentProfileId());
     transaction.CategoryIconDictionary = await this._transactionService.GetCategoryIconDictionary();
 }
        /// <summary>
        ///     Creates new transaction
        /// </summary>
        /// <returns>View with model</returns>
        public async Task<ActionResult> Create(bool expense, Guid wallet)
        {
            var userId = await this.CurrentProfileId();
            var permissions = await this._transactionService.GetPermission(userId, wallet);
            if (permissions == null || PermissionEnum.Read == permissions.Permission)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest,
                    TransactionResource.PermissionErrorCreate);
            }
            //get default currency for wallet
            var currency = await this._transactionService.GetDefaultCurrencyInWallet(wallet);
            //fill NewTransaction model with needed informations
            var model = new NewTransactionModel
            {
                Expense = expense,
                WalletId = wallet,
                CurrencyId = currency.Guid
            };
            await this.SetTransactionFormsDropdowns(model);

            return this.View(model);
        }
        public async Task<ActionResult> Create(NewTransactionModel transaction)
        {
            var model = Mapper.Map<TransactionServiceModel>(transaction);

            try
            {
                await this._transactionService.Create(model);
            }
            catch (ServiceValidationException exception)
            {
                ModelState.AddModelErrors(exception);
            }

            //Check server validation
            if (ModelState.IsValid)
            {
                this.AddSuccess(TransactionResource.TransactionCreated);
                return this.RedirectToAction(SharedConstant.Index, new {wallet = transaction.WalletId});
            }
            await this.SetTransactionFormsDropdowns(transaction);

            return this.View(transaction);
        }