public async Task <IActionResult> Create([Bind("Id,CrawlUrl,ExcludeWord,IgnoreCompany,MinimumWage,MaximumWage,Remarks")] FilterSetting filterSetting) { try { // 調用 SettingService 提供的函數來建立設定檔,若中途出錯則跳轉到指定的錯誤頁面 string ErrorMessage = SettingService.CreateSetting(_context, filterSetting, User.Identity.Name); if (ErrorMessage != null) { ViewBag.Error = ErrorMessage; return(View("~/Views/Shared/ErrorPage.cshtml")); } // 若中途沒有出錯則寫入變更到DB,並跳轉回設定檔列表 await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception) { ViewBag.Error = "系統忙碌中,請稍後再試 >___<"; return(View("~/Views/Shared/ErrorPage.cshtml")); } }