public ActionResult HRAdminEditClientSave(HRAdminEditClient model, string returnUrl = "HRAdminClientIndex") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var results = Common.GetHRAdminClientQuery(db, WebSecurity.CurrentUserId); var result = results.Include(a => a.HRs).Include(a => a.PensionCities).Include(a => a.TaxCities).Include(a => a.WorkCities).Include(a => a.AccumulationCities).Where(a => a.Id == model.ClientId).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end if (ModelState.IsValid) { try { var hrs = Common.GetHRQuery(db).Where(a => model.HRIds.Any(b => b == a.Id)).ToList(); var workCities = Common.GetCityQuery(db).Where(a => model.WorkCities.Any(b => b == a.Id)).ToList(); var taxCities = Common.GetCityQuery(db).Where(a => model.TaxCities.Any(b => b == a.Id)).ToList(); var pensionCities = Common.GetCityQuery(db).Where(a => model.PensionCities.Any(b => b == a.Id)).ToList(); var accumulationCities = Common.GetCityQuery(db).Where(a => model.AccumulationCities.Any(b => b == a.Id)).ToList(); result.HRs = hrs; result.WorkCities = workCities; result.TaxCities = taxCities; result.PensionCities = pensionCities; result.AccumulationCities = accumulationCities; result.PersonInfoNote = model.PersonInfoNote; result.EducationNote = model.EducationNote; result.WorkNote = model.WorkNote; result.FamilyNote = model.FamilyNote; db.PPSave(); Common.RMOk(this, "记录:" + result + "保存成功!"); return Redirect(Url.Content(returnUrl)); } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } ViewBag.ReturnUrl = returnUrl; return View("HRAdminEditClient", model); }
public ActionResult HRAdminEditClient(int id = 0, string returnUrl = "HRAdminClientIndex") { ViewBag.Path1 = "参数设置"; //检查记录在权限范围内 var results = Common.GetHRAdminClientQuery(db, WebSecurity.CurrentUserId); var result = results.Where(a => a.Id == id).SingleOrDefault(); if (result == null) { Common.RMError(this); return Redirect(Url.Content(returnUrl)); } //end var record = new HRAdminEditClient { ClientId = result.Id, ClientName = result.Name, EducationNote = result.EducationNote, FamilyNote = result.FamilyNote, PersonInfoNote = result.PersonInfoNote, WorkNote = result.WorkNote, HRIds = result.HRs.Select(a => a.Id).ToList(), WorkCities = result.WorkCities.Select(a => a.Id).ToList(), TaxCities = result.TaxCities.Select(a => a.Id).ToList(), PensionCities = result.PensionCities.Select(a => a.Id).ToList(), AccumulationCities = result.AccumulationCities.Select(a => a.Id).ToList(), }; ViewBag.ReturnUrl = returnUrl; return View(record); }