public IActionResult Create([FromForm] LocalizationCreateModel entity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AuditedEntityMapper <LocalizationCreateModel> .FillCountryEntityField(entity, CountryId);

                    bool statusResult = _localizationService.Add(entity);
                    if (statusResult)
                    {
                        return(RedirectToAction(nameof(Index)).WithSuccess(LOCALIZATION_SUCCESS_DEFAULT));
                    }
                    else
                    {
                        return(RedirectToAction(nameof(Index)).WithError(LOCALIZATION_ERROR_DEFAULT));
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                    return(RedirectToAction(nameof(Index)).WithError(ex.Message));
                }
            }

            ViewBag.Languages = _languageService.GetAllAsLookup(CountryId);
            return(View(entity).WithWarning(LOCALIZATION_WARNING_INVALID_MODELSTATE));
        }
Example #2
0
        public IActionResult Create([FromForm] LanguageCreateModel entity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AuditedEntityMapper <LanguageCreateModel> .FillCountryEntityField(entity, CountryId);

                    bool statusResult = _languageService.Add(entity);
                    if (statusResult)
                    {
                        return(RedirectToAction(nameof(Index)).WithSuccess(LOCALIZATION_SUCCESS_DEFAULT));
                    }
                    else
                    {
                        return(RedirectToAction(nameof(Index)).WithError(LOCALIZATION_ERROR_DEFAULT));
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                    return(RedirectToAction(nameof(Index)).WithError(ex.Message));
                }
            }
            return(View(entity));
        }