//更新,含明细 public ActionResult Update(string json) { var rdto = new ResultMessages(); rdto.Message = ""; JavaScriptSerializer jss = new JavaScriptSerializer(); try { AuditionMain obj = jss.Deserialize<AuditionMain>(json); AuditionMain oriObj = ctx.AuditionMains.Single(r => r.Id == obj.Id); oriObj.Name = obj.Name; oriObj.Address = obj.Address; oriObj.InfoOrigin = obj.InfoOrigin; oriObj.Position = obj.Position; oriObj.Phone = obj.Phone; oriObj.EMail = obj.EMail; oriObj.AuditionType = obj.AuditionType; oriObj.DeptId = obj.DeptId; oriObj.Remarks = obj.Remarks; foreach (var v in obj.AuditionSubs) { AuditionSub reqSub; if (v.Id > 0) { reqSub = oriObj.AuditionSubs.Single(r => r.Id == v.Id); } else { reqSub = new AuditionSub(); reqSub.Pid = oriObj.Id; oriObj.AuditionSubs.Add(reqSub); } reqSub.Interviewer = v.Interviewer; reqSub.Reminder = v.Reminder; reqSub.InterviewTime = v.InterviewTime; reqSub.Result = v.Result; reqSub.Remarks = v.Remarks; } ctx.SubmitChanges(); rdto.Message = "更新成功"; rdto.Result = true; } catch (Exception ex) { rdto.Message = "更新失败"; rdto.Result = false; } return Json(rdto); }
private void detach_AuditionSubs(AuditionSub entity) { this.SendPropertyChanging(); entity.AuditionMain = null; }
partial void UpdateAuditionSub(AuditionSub instance);
partial void DeleteAuditionSub(AuditionSub instance);
partial void InsertAuditionSub(AuditionSub instance);