public async Task <IActionResult> CreateComponent()
        {
            var language = this.GetCurrentLanguage();

            var viewModel = new ComponentInputModel
            {
                CurrencyListItems      = await this.currenciesService.AllLocalized <CurrencySelectListItem>(language),
                ComponentTypeListItems = await this.componentTypesService.AllLocalized <ComponentTypeSelectListItem>(language)
            };

            return(this.View(viewModel));
        }
        public async Task <IActionResult> CreateComponent(ComponentInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var language = this.GetCurrentLanguage();

                model.CurrencyListItems = await this.currenciesService.AllLocalized <CurrencySelectListItem>(language);

                model.ComponentTypeListItems = await this.componentTypesService.AllLocalized <ComponentTypeSelectListItem>(language);

                return(this.View(model));
            }

            try
            {
                var entityToAdd = new Component
                {
                    UserId          = this.GetUserId <string>(),
                    CurrencyId      = model.CurrencyId,
                    ComponentTypeId = model.ComponentTypeId,
                    Name            = model.Name,
                    Amount          = model.Amount,
                    IsActive        = model.IsActive
                };

                await this.componentsService.AddAsync(entityToAdd);

                this.AddAlertMessageToTempData(AlertMessageTypes.Success, Resources.Success, Resources.ComponentAddSuccess);
            }
            catch (Exception)
            {
                this.AddAlertMessageToTempData(AlertMessageTypes.Error, Resources.Error, Resources.ComponentAddError);
            }

            return(this.RedirectToAction("Index"));
        }