예제 #1
0
 public ActionResult Edit(TErp_Position dto)
 {
     if (dto.Id > 0)
     {
         HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
         string positionName        = dto.PositionName;
         int    id = dto.Id;
         if (ctx.TErp_Position.Count(c => c.PositionName == positionName && c.Id != id && c.IsDelete == 0) > 0)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "职位名称[" + positionName + "]重复" }), this.JsonContentType()));
         }
         TErp_Position model = ctx.TErp_Position.FirstOrDefault(c => c.Id == dto.Id);
         this.CopyObject <TErp_Position>(model, dto);
         Tapp_User user = this.AppUser();
         model.EditBy   = user.UserName;
         model.EditTime = DateTime.Now;
         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()));
     }
 }
예제 #2
0
        public ActionResult DeleteMulti(string Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

            string[]  arrId   = Id.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries);
            int       counter = 0;
            Tapp_User user    = this.AppUser();

            foreach (var item in arrId)
            {
                int           tid   = Convert.ToInt32(item);
                TErp_Position model = ctx.TErp_Position.FirstOrDefault(c => c.Id == tid);
                if (model != null)
                {
                    int postId = model.Id;
                    if (ctx.THR_Needs.Count(c => c.PostId == postId) > 0 ||
                        ctx.THR_Recruit.Count(c => c.PostId == postId) > 0)
                    {
                        return(Content(this.GetJSON(new { Result = false, Msg = "职位[" + model.PositionName + "]已被引用,不能删除", Id = counter }), this.JsonContentType()));
                    }
                    model.IsDelete   = 1;
                    model.DeleteBy   = user.UserName;
                    model.DeleteTime = DateTime.Now;
                    counter++;
                }
            }
            if (ctx.SaveChanges() > 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Id = counter }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", id = counter }), this.JsonContentType()));
        }
예제 #3
0
        private int GetPositionId(List <TErp_Position> positions, string postName)
        {
            TErp_Position position = positions.FirstOrDefault(c => c.PositionName.Equals(postName, StringComparison.OrdinalIgnoreCase));

            if (position != null)
            {
                return(position.Id);
            }
            else
            {
                return(0);
            }
        }
예제 #4
0
        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()));
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        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()));
        }