public async Task <IActionResult> Add(string submitbutton, string language_state, [Bind("Id", "LangNo, LangNa,LangEn")] Language language) { if (!LoginUtil.CheckIfLoggedIn(HttpContext)) { return(View(nameof(Index))); } StateOfRequest mState; if (string.IsNullOrEmpty(language_state)) { mState = new StateOfRequest("LangNo"); } else { mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(language_state); } mState.StartTime = DateTime.Now; string temp_state = JsonUtil.SetJsonStringFromObject(mState); int orgId = mState.OrgId; string sButton = submitbutton.ToUpper(); if (sButton == "CANCEL") { Language newLanguage = new Language(); List <Language> languagesTemp = _languagesManager.FindOnePageOfLanguagesForOneLanguage(mState, newLanguage, orgId); mState.IsFirstAddRecord = true; temp_state = JsonUtil.SetJsonStringFromObject(mState); ViewBag.LanguageState = temp_state; return(View(nameof(LanguagesList), languagesTemp)); } if (ModelState.IsValid) { int result = await _languagesManager.AddOneLanguageToTable(language); if (result == ErrorCodeModel.Succeeded) { // succeeded to add the language mState.OrgId = language.Id; mState.OrgNo = language.LangNo; mState.IsFirstAddRecord = false; temp_state = JsonUtil.SetJsonStringFromObject(mState); return(RedirectToAction(nameof(Add), new { language_state = temp_state })); } else { ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(result); } } else { // Model.IsValid = false ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(ErrorCodeModel.ModelBindingFailed); } ViewBag.LanguageState = temp_state; return(View(language)); }