public ActionResult ListPost(int id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); var query = ctx.TErp_Post.Where(c => c.IsDelete == 0 && c.DeptId == id) .OrderBy(c => c.CreateTime) .Select(c => new PostDto { Id = c.Id, PostName = c.PostName, PositionId = c.PositionId }); List <PostDto> dtos = query.ToList(); return(Content(this.GetJSON(new { total = dtos.Count, rows = dtos }), this.JsonContentType())); }
/// <summary> /// 获取用户角色 /// </summary> /// <param name="userId">用户ID</param> /// <returns></returns> public List <UserRoleDto> LoadUserRole(int userId) { HKSJRecruitmentContext ctx = HttpContext.Current.GetDbContext <HKSJRecruitmentContext>(); return(ctx.Tapp_User_Role.Where(c => c.UserId == userId).Select(c => new UserRoleDto { UserId = c.UserId, IsRight = true, RoleId = c.RoleId, RoleName = c.Tapp_Role.RoleName }).ToList()); }
/// <summary> /// 获取权限按钮 /// </summary> /// <param name="userId"></param> /// <param name="controller"></param> /// <param name="action"></param> /// <returns></returns> public List <Tapp_Button> LoadButton(int userId, string controller, string action) { string url = "/" + controller + "/" + action; HKSJRecruitmentContext ctx = HttpContext.Current.GetDbContext <HKSJRecruitmentContext>(); Tapp_Menu menu = ctx.Tapp_Menu.FirstOrDefault(c => c.MenuUrl == url); if (menu != null) { return(LoadButton(userId, menu.Id)); } return(null); }
/// <summary> /// /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult Detail(int Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); RecruitModel dto = GetRecruitModel(Id, ctx); if (dto != null) { return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType())); } }
public ActionResult Detail(int Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); TErp_Position dto = ctx.TErp_Position.FirstOrDefault(c => c.Id == Id); if (dto != null) { return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType())); } }
public ActionResult Index() { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); List <Tapp_Menu> Menus = ctx.Tapp_Menu.OrderUsingSortExpression("parentid asc,seqno asc").ToList(); foreach (var item in Menus) { item.Tapp_Button.Clear(); item.Tapp_Role_Right.Clear(); } ViewBag.Buttons = this.LoadButton(); ViewBag.Menus = this.GetJSON(Menus); return(View()); }
public ActionResult List(PanramQueryParam queryParam) { Expression <Func <Tapp_Param, bool> > predicate = c => true; predicate = predicate.And(c => c.Parentid == queryParam.Parentid && c.IsDelete == 0); HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); IPageList <Tapp_Param> models = ctx.Tapp_Param .Where(predicate) .OrderUsingSortExpression("parentid asc, sort asc") .ToPagedList(queryParam.PageIndex, queryParam.PageSize); List <Tapp_Param> dtos = models.ToList(); return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType())); }
/// <summary> /// 参数配置控制器 /// </summary> /// <returns></returns> public ActionResult Index() { ViewBag.Buttons = this.LoadButton(); int id = 0; HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); Tapp_ParamType info = ctx.Tapp_ParamType .Where(c => c.IsShow == 0).OrderBy(c => c.Id).FirstOrDefault(); if (info != null) { id = info.Id; } ViewBag.ParentId = id; return(View()); }
public ActionResult Detail(int Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); HKSJRecruitment.Models.proModels.HR_Employee dto = ctx.Database.SqlQuery <HKSJRecruitment.Models.proModels.HR_Employee>(@"SELECT A.ID,A.uid,A.pwd,A.name,A.idcard,A.idcard,A.birthday,A.dptid,B.DeptName as dptname,A.postid,C.PositionName post,A.sex,A.tel,A.status,A.EntryDate,A.address,A.education,A.schools from HR_Employee A LEFT join TErp_Department B ON A.dptid=B.Id left join TErp_Position C ON A.postid=C.Id").FirstOrDefault(c => c.ID == Id);; // ctx.HR_Employee.FirstOrDefault(c => c.ID == Id); if (dto != null) { return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType())); } }
public ActionResult ResetUserPwd(string uid) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); Tapp_User appUser = ctx.Tapp_User.FirstOrDefault(c => c.UserName == uid); string defaultPwd = Md5.Encrypt(appUser.UserName + "123456"); appUser.UserPwd = defaultPwd; if (ctx.SaveChanges() >= 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功" }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败" }), this.JsonContentType())); } }
public ActionResult List(EmployeeQueryParam queryParam) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string sql = @"SELECT A.ID,A.uid,A.pwd,A.name,A.idcard,A.idcard,A.birthday,A.dptid,B.DeptName as dptname,A.postid,C.PositionName post,A.sex,A.tel,A.status,A.EntryDate,A.address,A.education,A.schools from HR_Employee A LEFT join TErp_Department B ON A.dptid=B.Id left join TErp_Position C ON A.postid=C.Id where (A.isDelete is null or A.isDelete = 0) "; if (!string.IsNullOrEmpty(queryParam.name)) { sql += string.Format("and A.name like {0}", SQLHelper.ToSQLParamLikeStr(queryParam.name)); } sql += "order by A.ID desc"; IPageList <HKSJRecruitment.Models.proModels.HR_Employee> dtoss = ctx.Database.SqlQuery <HKSJRecruitment.Models.proModels.HR_Employee>(sql).ToPagedList(queryParam.PageIndex, queryParam.PageSize); return(Content(this.GetJSON(new { total = dtoss.PageInfo.TotalCount, rows = dtoss }), this.JsonContentType())); }
/// <summary> /// 根据状态名称获得状态ID /// </summary> /// <param name="pParamsName"></param> /// <returns></returns> private int GetStatus(string pParamsName) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); List <Tapp_Param> models = ctx.Tapp_Param .Where(c => c.IsDelete == 0 && c.Parentid == 10).OrderUsingSortExpression("parentid asc, sort asc").ToList(); Tapp_Param tParam = models.FirstOrDefault(c => c.ParamsName.Equals(pParamsName, StringComparison.OrdinalIgnoreCase)); if (tParam != null) { return(tParam.Id); } else { return(0); } }
/// <summary> /// 根据职位名称获得职位ID /// </summary> /// <param name="postName"></param> /// <returns></returns> private int GetPostId(string postName) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); List <TErp_Position> models = ctx.TErp_Position .Where(c => c.IsDelete == 0).OrderUsingSortExpression("id asc").ToList(); TErp_Position tPost = models.FirstOrDefault(c => c.PositionName.Equals(postName, StringComparison.OrdinalIgnoreCase)); if (tPost != null) { return(tPost.Id); } else { return(0); } }
public ActionResult List(RoleQueryParam queryParam) { Expression <Func <Tapp_Role, bool> > predicate = c => true; if (!string.IsNullOrEmpty(queryParam.RoleName)) { predicate = predicate.And(c => c.RoleName.Contains(queryParam.RoleName)); } HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); IPageList <Tapp_Role> models = ctx.Tapp_Role .Where(predicate) .OrderUsingSortExpression(queryParam.Sort, queryParam.Order) .ToPagedList(queryParam.PageIndex, queryParam.PageSize); List <Tapp_Role> dtos = models.ToList(); return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType())); }
public ActionResult List(ButtonQueryParam queryParam) { Expression <Func <Tapp_Button, bool> > predicate = c => true; if (queryParam.MenuId > 0) { predicate = predicate.And(c => c.MenuId == queryParam.MenuId); } HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); IPageList <Tapp_Button> models = ctx.Tapp_Button .Where(predicate) .OrderUsingSortExpression(queryParam.Sort, queryParam.Order) .ToPagedList(queryParam.PageIndex, queryParam.PageSize); List <Tapp_Button> dtos = models.ToList(); return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType())); }
public ActionResult Edit(Tapp_Button dto) { if (dto.Id > 0) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); ctx.Entry <Tapp_Button>(dto).State = System.Data.Entity.EntityState.Modified; if (ctx.SaveChanges() >= 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据", Dto = dto }), this.JsonContentType())); } }
public ActionResult ListSearchCreateBy() { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); var query = from a in ctx.Tapp_User join b in ctx.HR_Employee on a.UserName equals b.uid where (a.State == 1) orderby a.Id ascending select new UserEmployee { UserName = a.UserName, Name = b.name }; List <UserEmployee> models = query.ToList(); return(Content(this.GetJSON(new { total = models.Count, rows = models }), this.JsonContentType())); }
public ActionResult Add(HR_Employee dto) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string uid = dto.uid; if (ctx.Tapp_User.Count(c => c.UserName == uid) > 0) { return(Content(this.GetJSON(new { Result = false, Msg = "账号[" + uid + "]已使用", Dto = dto }), this.JsonContentType())); } if (!dto.dptid.HasValue) { return(Content(this.GetJSON(new { Result = false, Msg = "请选择部门", Dto = dto }), this.JsonContentType())); } if (!dto.postid.HasValue) { return(Content(this.GetJSON(new { Result = false, Msg = "请选择职位", Dto = dto }), this.JsonContentType())); } int deptId = dto.dptid.Value; int postId = dto.postid.Value; if (ctx.TErp_Department.Count(c => c.Id == deptId && c.IsDelete == 0) == 0) { return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在", Dto = dto }), this.JsonContentType())); } if (ctx.TErp_Position.Count(c => c.Id == postId && c.IsDelete == 0) == 0) { return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在", Dto = dto }), this.JsonContentType())); } ctx.HR_Employee.Add(dto); Tapp_User use = new Tapp_User(); use.UserName = dto.uid; use.UserPwd = "123456"; use.State = 1; use.UserPwd = Md5.Encrypt(dto.uid + "123456"); ctx.Tapp_User.Add(use); if (ctx.SaveChanges() >= 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); }
public ActionResult UserRight(string userids, string roleids) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string[] arrRoleId = roleids.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries); foreach (var username in userids.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries)) { Tapp_User appUser = ctx.Tapp_User.FirstOrDefault(c => c.UserName == username); if (appUser == null) { return(Content(this.GetJSON(new { Result = false, Msg = "员工[" + username + "]不存在" }), this.JsonContentType())); } string[] arrDbRoleId = ctx.Tapp_User_Role.Where(c => c.UserId == appUser.Id).Select(c => c.RoleId.ToString()).ToArray(); foreach (var item in arrDbRoleId.Except(arrRoleId)) { //删除 int roleId = Convert.ToInt32(item); Tapp_User_Role right = ctx.Tapp_User_Role.FirstOrDefault(c => c.RoleId == roleId && c.UserId == appUser.Id); if (right != null) { ctx.Tapp_User_Role.Remove(right); } } foreach (var item in arrRoleId.Except(arrDbRoleId)) { //新增 int roleId = Convert.ToInt32(item); Tapp_Role role = ctx.Tapp_Role.FirstOrDefault(c => c.Id == roleId); if (role != null) { ctx.Tapp_User_Role.Add(new Tapp_User_Role { RoleId = roleId, UserId = appUser.Id }); } } } if (ctx.SaveChanges() >= 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功" }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败" }), this.JsonContentType())); } }
public ActionResult Add(Tapp_Param dto) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); if (ctx.Tapp_Param.Count(c => c.ParamsName == dto.ParamsName && c.IsDelete == 0) > 0) { return(Content(this.GetJSON(new { Result = false, Msg = "参数名已存在" }), this.JsonContentType())); } dto.CreateTime = DateTime.Now; dto.CreateBy = this.AppUser().UserName; dto.IsDelete = 0; ctx.Tapp_Param.Add(dto); if (ctx.SaveChanges() > 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); }
public ActionResult ListDepartment() { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); var query = ctx.TErp_Department .Where(c => c.IsDelete == 0). OrderUsingSortExpression("seqno desc") .Select(c => new DepartmentDto { Id = c.Id, DeptName = c.DeptName, ParentId = c.ParentId, SeqNo = c.SeqNo, DeptIcon = c.DeptIcon }); List <DepartmentDto> dtos = query.ToList(); return(Content(this.GetJSON(new { total = dtos.Count, rows = dtos }), this.JsonContentType())); }
public ActionResult Add(TErp_Position dto) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string positionName = dto.PositionName; if (ctx.TErp_Position.Count(c => c.PositionName == positionName && c.IsDelete == 0) > 0) { return(Content(this.GetJSON(new { Result = false, Msg = "职位名称[" + positionName + "]重复" }), this.JsonContentType())); } dto.CreateBy = this.AppUser().UserName; dto.CreateTime = DateTime.Now; ctx.TErp_Position.Add(dto); if (ctx.SaveChanges() > 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); }
public ActionResult Detail(int Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); Hr_NeedDto dto = ctx.THR_Needs.Select(c => new Hr_NeedDto { Id = c.Id, DeptId = c.DeptId, DeptName = c.TErp_Department.DeptName, PostId = c.PostId, PostName = c.TErp_Position.PositionName, CutTime = c.CutTime, Demander = c.Demander, NeedQuantity = c.NeedQuantity, Remarks = c.Remarks, CreateBy = c.CreateBy, CreateTime = c.CreateTime, IsDelete = c.IsDelete, DeleteBy = c.DeleteBy, DeleteTime = c.DeleteTime, EditBy = c.EditBy, EditTime = c.EditTime, HaveBeenQuantity = c.HaveBeenQuantity, FileWord = c.FileWord, JobResponsibility = c.JobResponsibility, PostRequest = c.PostRequest, IsHaveBeen = c.IsHaveBeen.Value, InterviewAddress = c.InterviewAddress, Principal = c.Principal }).FirstOrDefault(c => c.Id == Id); HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy); if (emp != null) { dto.CreateBy = emp.name; } if (dto != null) { return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType())); } }
/// <summary> /// 获取权限按钮 /// </summary> /// <param name="userId"></param> /// <param name="menuId"></param> /// <returns></returns> public List <Tapp_Button> LoadButton(int userId, int menuId) { HKSJRecruitmentContext ctx = HttpContext.Current.GetDbContext <HKSJRecruitmentContext>(); if (UserHelper.IgnoreCheckRight) { return(ctx.Tapp_Button.Where(c => c.MenuId == menuId && c.IsShow == 1).OrderBy(c => c.SeqNo).ToList()); } else { var query = from role in ctx.Tapp_Role_Right join button in ctx.Tapp_Button on role.ButtonId equals button.Id join user in ctx.Tapp_User_Role on role.RoleId equals user.RoleId where user.UserId == userId && role.MenuId == menuId && button.IsShow == 1 orderby button.SeqNo ascending select button; return(query.Distinct().ToList()); } }
public ActionResult ListEmployee(EmployeeQueryParam queryParam) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); Expression <Func <HR_Employee, bool> > predicate = c => c.isDelete == null || c.isDelete == 0; if (queryParam.deptid > 0) { predicate = predicate.And(c => c.dptid == queryParam.deptid); } if (!string.IsNullOrEmpty(queryParam.name)) { predicate = predicate.And(c => c.name.Contains(queryParam.name) || c.uid.Contains(queryParam.name)); } IPageList <EmployeeData> dtos = ctx.HR_Employee.Where(predicate).OrderBy(c => c.ID).Select(c => new EmployeeData { Id = c.ID, Name = c.name, Uid = c.uid }).ToPagedList(queryParam.PageIndex, queryParam.PageSize); return(Content(this.GetJSON(new { total = dtos.PageInfo.TotalCount, rows = dtos }), this.JsonContentType())); }
/// <summary> /// 获取Tapp_User /// </summary> /// <param name="controller"></param> /// <returns></returns> public static Tapp_User AppUser(this Controller controller) { HKSJRecruitmentContext ctx = new HKSJRecruitmentContext(); int userId = HttpContext.Current.AppUserId(); Tapp_User u = ctx.Tapp_User.FirstOrDefault(c => c.Id == userId); if (u != null) { u.UserPwd = string.Empty; u.Tapp_User_Role = null; //HttpContext.Current.Session[UserHelper.SystemUserSessionKey] = u; } return(u); //if (HttpContext.Current.Session[UserHelper.SystemUserSessionKey] == null) //{ //} //return HttpContext.Current.Session[UserHelper.SystemUserSessionKey] as Tapp_User; }
public ActionResult Edit(TErp_Post dto) { if (dto.Id > 0) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); int deptId = dto.DeptId; int positionId = dto.PositionId; if (ctx.TErp_Department.Count(c => c.Id == deptId && c.IsDelete == 0) == 0) { return(Content(this.GetJSON(new { Result = false, Msg = "请选择部门" }), this.JsonContentType())); } if (ctx.TErp_Position.Count(c => c.Id == positionId && c.IsDelete == 0) == 0) { return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType())); } TErp_Post model = ctx.TErp_Post.FirstOrDefault(c => c.Id == dto.Id); this.CopyObject <TErp_Post>(model, dto); Tapp_User user = this.AppUser(); model.EditBy = user.UserName; model.EditTime = DateTime.Now; if (ctx.SaveChanges() >= 0) { var m = ctx.TErp_Post.Where(c => c.Id == dto.Id).Select(c => new PostDto { DeptId = c.DeptId, DeptName = c.TErp_Department.DeptName, PositionId = c.PositionId, PositionLevel = c.TErp_Position.PositionLevel, PostDesc = c.PostDesc, PostName = c.PostName, Id = c.Id, PositionName = c.TErp_Position.PositionName }).FirstOrDefault(); return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据", Dto = dto }), this.JsonContentType())); } }
public string GetUid(string fullName) { fullName = fullName.Trim(); string pinYins = string.Empty; foreach (char obj in fullName) { try { ChineseChar chineseChar = new ChineseChar(obj); string t = chineseChar.Pinyins[0]; pinYins += t.Substring(0, t.Length - 1); } catch { pinYins += obj; } } pinYins = pinYins.ToLower(); List <string> uids = new List <string>(); string username = string.Empty; HKSJRecruitmentContext ctx = HttpContext.Current.GetDbContext <HKSJRecruitmentContext>(); if (ctx.Tapp_User.Count(c => c.UserName == pinYins) == 0) { username = pinYins; } else { Regex regex = new Regex(@"^\d+$"); foreach (var item in ctx.Tapp_User.Where(c => c.UserName.Contains(pinYins)).Select(c => c.UserName)) { string input = item.Substring(pinYins.Length); if (regex.IsMatch(input)) { uids.Add(item); } } username = pinYins + (uids.Count + 1); } return(username); }
public ActionResult Add(TErp_Department dto) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string deptName = dto.DeptName; if (ctx.TErp_Department.Count(c => c.DeptName == deptName && c.IsDelete == 0) > 0) { return(Content(this.GetJSON(new { Result = false, Msg = "部门名称[" + deptName + "]重复", Dto = dto }), this.JsonContentType())); } Tapp_User user = this.AppUser(); dto.CreateBy = user.UserName; dto.CreateTime = DateTime.Now; ctx.TErp_Department.Add(dto); if (ctx.SaveChanges() >= 0) { return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); }
public ActionResult EditCreateBy(THR_Recruit dto) { if (dto.Id > 0) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); THR_Recruit model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id); model.CreateBy = dto.CreateBy; if (ctx.SaveChanges() >= 0) { RecruitModel m = GetRecruitModel(dto.Id, ctx); return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), this.JsonContentType())); } return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType())); } else { return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据", Dto = dto }), this.JsonContentType())); } }