public async Task <ActionResult> Edit(RecruitJob model) { var result = new JsonModel(); // 数据有误 if (!ModelState.IsValid) { result.GetError(ModelState); return(Json(result)); } var operationType = OperationType.Insert; var operationTitle = "添加招聘职位"; if (model.Id > 0) { var adPos = await RecruitJobRepository.GetByIdAsync(model.Id); if (adPos == null) { result.message = "记录不存在了"; return(Json(result)); } operationType = OperationType.Update; operationTitle = "修改招聘职位"; } await RecruitJobRepository.SaveAsync(model); await LogRepository.Insert(TableSource.RecruitJob, operationType, operationTitle, model.Id); result.Data = model; result.message = "保存成功!"; return(Json(result)); }
public async Task <ActionResult> Edit(long id = 0) { RecruitJob model; if (id > 0) { model = await RecruitJobRepository.GetByIdAsync(id); if (model == null) { var json = new JsonModel { message = "记录不存在了", statusCode = 300 }; return(Json(json, JsonRequestBehavior.AllowGet)); } } else { model = DbFactory.CreateRecruitJob(); model.WorkDuty = "1." + Environment.NewLine + "2." + Environment.NewLine + "3."; model.Requirement = "1." + Environment.NewLine + "2." + Environment.NewLine + "3."; } return(PartialView(model)); }