public async Task <IActionResult> Recruit(RecruitModel model)
        {
            try
            {
                this._logger.LogDebug("mutant: {0}", JsonConvert.SerializeObject(model));

                if (model == null)
                {
                    return(BadRequest("model empty"));
                }

                var result = await this.service.Recruit(model.Dna);

                this._logger.LogDebug("Is Mutant: {}", result);

                if (!result)
                {
                    return(StatusCode(StatusCodes.Status403Forbidden));
                }

                return(Ok());
            }
            catch (System.Exception ex)
            {
                this._logger.LogError(ex.Message, ex);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Esempio n. 2
0
        /// <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()));
            }
        }
Esempio n. 3
0
        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()));
            }
        }
Esempio n. 4
0
        public ActionResult Detail(int Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            RecruitModel           dto = ctx.THR_Recruit.Select(c => new RecruitModel
            {
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                Id          = c.Id,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                Status      = c.Status.Value,
                Interview   = c.Interview,
                Email       = c.Email,
                EntryType   = c.EntryType.Value,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                Interviewer = c.Interviewer
            }).FirstOrDefault(c => c.Id == Id);

            if (dto != null)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy);
                if (emp != null)
                {
                    dto.CreateBy = emp.name;
                }
                return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType()));
            }
            else
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType()));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// model
        /// </summary>
        /// <param name="pId"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private static RecruitModel GetRecruitModel(int pId, HKSJRecruitmentContext pctx)
        {
            RecruitModel dto = pctx.THR_Recruit.Select(c => new RecruitModel
            {
                Id          = c.Id,
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                NeedsId     = c.NeedsId,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                Status      = c.Status.Value,
                StatusName  = c.Tapp_Param.ParamsName,
                Interview   = c.Interview,
                Email       = c.Email,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                DeleteBy    = c.DeleteBy,
                DeleteTime  = c.DeleteTime,
                EditBy      = c.EditBy,
                EditTime    = c.EditTime,
                Interviewer = c.Interviewer,
                IsHaveBeen  = c.THR_Needs.IsHaveBeen.Value
            }).FirstOrDefault(c => c.Id == pId);
            HR_Employee emp = pctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy);

            if (emp != null)
            {
                dto.CreateBy = emp.name;
            }
            return(dto);
        }
Esempio n. 6
0
        public ActionResult Edit(THR_Recruit dto)
        {
            if (dto.Id > 0)
            {
                HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
                if (ctx.THR_Recruit.Count(c => c.Tel == dto.Tel && c.IsDelete == 0 && c.Id != dto.Id) > 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "电话已存在" }), this.JsonContentType()));
                }
                if (!dto.DptId.HasValue)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
                }
                int dptId = dto.DptId.Value;
                if (ctx.TErp_Department.Count(c => c.Id == dptId) == 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
                }
                if (!dto.PostId.HasValue)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
                }
                int postId = dto.PostId.Value;
                if (ctx.TErp_Position.Count(c => c.Id == postId) == 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
                }
                if (!dto.Status.HasValue)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
                }
                int status = dto.Status.Value;
                if (ctx.Tapp_Param.Count(c => c.Id == status) == 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
                }
                if (string.IsNullOrEmpty(dto.Interview.ToString()))
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "面试时间不能为空" }), this.JsonContentType()));
                }
                DateTime interview;
                if (!DateTime.TryParse(dto.Interview.ToString(), out interview) && !string.IsNullOrEmpty(dto.Interview.ToString()))
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "面试时间格式不正确" }), this.JsonContentType()));
                }
                DateTime hireTime;
                if (!DateTime.TryParse(dto.HireTime.ToString(), out hireTime) && !string.IsNullOrEmpty(dto.HireTime.ToString()))
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "报道时间格式不正确" }), this.JsonContentType()));
                }
                if (dto.NeedsId == 0 || dto.NeedsId == null)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "招聘需求不能为空" }), this.JsonContentType()));
                }

                //THR_Recruit model = ctx.THR_Recruit.Include("THR_Needs").FirstOrDefault(c => c.Id == dto.Id);
                THR_Recruit model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id);
                //if (model.Status == 82)
                //{
                //    return Content(this.GetJSON(new { Result = false, Msg = "已录用的招聘信息不能修改" }), this.JsonContentType());
                //}
                if (dto.Status == 82 && dto.Status != model.Status)//已录用
                {
                    THR_Needs needsmodel = ctx.THR_Needs.FirstOrDefault(c => c.Id == dto.NeedsId);
                    int       Quantity   = ctx.THR_Recruit
                                           .Where(c => c.IsDelete == 0 && c.NeedsId == dto.NeedsId && c.Status == dto.Status).ToList().Count;//已录用
                    if (needsmodel.NeedQuantity <= Quantity)
                    {
                        return(Content(this.GetJSON(new { Result = false, Msg = "招聘人数已达到招聘需求数,请新增或变更招聘需求!" }), this.JsonContentType()));
                    }
                }
                this.CopyObject <THR_Recruit>(model, dto);
                model.EditTime = DateTime.Now;
                model.EditBy   = this.AppUser().UserName;
                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()));
            }
        }
Esempio n. 7
0
        public ActionResult Add(THR_Recruit dto)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

            if (!dto.DptId.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
            }
            int dptId = dto.DptId.Value;

            if (ctx.TErp_Department.Count(c => c.Id == dptId) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
            }
            if (!dto.PostId.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
            }
            int postId = dto.PostId.Value;

            if (ctx.TErp_Position.Count(c => c.Id == postId) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
            }
            if (!dto.Status.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
            }
            int status = dto.Status.Value;

            if (ctx.Tapp_Param.Count(c => c.Id == status) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
            }
            if (string.IsNullOrEmpty(dto.Interview.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "面试时间不能为空" }), this.JsonContentType()));
            }
            DateTime interview;

            if (!DateTime.TryParse(dto.Interview.ToString(), out interview) && !string.IsNullOrEmpty(dto.Interview.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "面试时间格式不正确" }), this.JsonContentType()));
            }
            DateTime hireTime;

            if (!DateTime.TryParse(dto.HireTime.ToString(), out hireTime) && !string.IsNullOrEmpty(dto.HireTime.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "报道时间格式不正确" }), this.JsonContentType()));
            }
            if (dto.NeedsId == 0 || dto.NeedsId == null)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "招聘需求不能为空" }), this.JsonContentType()));
            }
            if (dto.Status == 82)//已录用
            {
                THR_Needs needmodel = ctx.THR_Needs.FirstOrDefault(c => c.Id == dto.NeedsId);
                int       Quantity  = ctx.THR_Recruit
                                      .Where(c => c.IsDelete == 0 && c.NeedsId == dto.NeedsId && c.Status == dto.Status).ToList().Count;//已录用
                if (needmodel.NeedQuantity <= Quantity)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "招聘人数已达到招聘需求数,请新增或变更招聘需求!" }), this.JsonContentType()));
                }
                //needmodel.HaveBeenQuantity = Quantity + 1;
                //if (needmodel.HaveBeenQuantity == needmodel.NeedQuantity)
                //{ needmodel.IsHaveBeen = 1; }
            }
            TErp_Department dept = ctx.TErp_Department.FirstOrDefault(c => c.Id == dto.DptId.Value);

            dept.SeqNo = dept.SeqNo + 1;
            if (ctx.THR_Recruit.Count(c => c.Tel == dto.Tel && 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;
            dto.EntryType  = 1;
            ctx.THR_Recruit.Add(dto);
            if (ctx.SaveChanges() > 0)
            {
                RecruitModel model = GetRecruitModel(dto.Id, ctx);

                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = model }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
        }