Ejemplo n.º 1
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_Post model = ctx.TErp_Post.FirstOrDefault(c => c.Id == tid);
                if (model != null)
                {
                    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()));
        }
Ejemplo n.º 2
0
        public ActionResult Detail(int Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            TErp_Post dto = ctx.TErp_Post.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()));
            }
        }
Ejemplo n.º 3
0
 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()));
     }
 }