Esempio n. 1
0
        public async Task <IActionResult> OnPost()
        {
            //POST/REDIRECT/GET  PRINCIPLE

            if (LanguageText.LanguageType == LanguageType.NONE)
            {
                Languages = htmlHelper.GetEnumSelectList <LanguageType>();
                ModelState.AddModelError("", "Select a Language");
                return(Page());
            }

            if (!ModelState.IsValid)
            {
                Languages = htmlHelper.GetEnumSelectList <LanguageType>();

                return(Page());
            }

            if (LanguageText.Id > 0)
            {
                languageData.Update(LanguageText);
            }
            else
            {
                var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                LanguageText.User = currentUser;
                languageData.Add(LanguageText);
            }

            languageData.Commit();
            TempData["Message"] = "Language Saved";
            return(RedirectToPage("./ClientLanguages"));
            //return RedirectToPage("./List");
        }
Esempio n. 2
0
        public IActionResult OnPost(int id)
        {
            var languageText = languageData.Delete(id);

            languageData.Commit();

            if (languageText == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"{languageText.Text} deleted";
            return(RedirectToPage("./ClientLanguages"));
        }