public ActionResult DeleteMulti(string Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); string[] arrId = Id.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries); int counter = 0; foreach (var item in arrId) { int tid = Convert.ToInt32(item); Tapp_Param model = ctx.Tapp_Param.FirstOrDefault(c => c.Id == tid); if (model != null) { model.IsDelete = 1; model.DeleteBy = this.AppUser().UserName; model.DeleteTime = DateTime.Now; // ctx.Tapp_Param.Remove(model); 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())); }
public ActionResult Detail(int Id) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); Tapp_Param dto = ctx.Tapp_Param.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())); } }
/// <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); } }
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 Edit(Tapp_Param dto) { if (dto.Id > 0) { HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>(); if (ctx.Tapp_Param.Count(c => c.ParamsName == dto.ParamsName && c.IsDelete == 0 && c.Id != dto.Id) > 0) { return(Content(this.GetJSON(new { Result = false, Msg = "参数名已存在" }), this.JsonContentType())); } Tapp_Param model = ctx.Tapp_Param.FirstOrDefault(c => c.Id == dto.Id); this.CopyObject <Tapp_Param>(model, dto); model.EditTime = DateTime.Now; model.EditBy = this.AppUser().UserName; 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())); } }