public ActionResult Create(CompanyViewModel companyViewModel) { try { // TODO: Add insert logic here CompanyServices.Create(companyViewModel); TempData["message"] = "Inserted Successfully"; return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> Create(CompanyViewModel vm) { var result = await _companyServices.Create(vm, GetAccount()); if (result.Status == Status.ok) { return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "保存失败: " + result.Message); await Init(vm); return(View(vm)); } }