public JsonResult Create(C_Recruitment recruit) { try { recruit.Date = DateTime.Now; db.C_Recruitment.Add(recruit); db.SaveChanges(); var rs = db.C_Recruitment.Select(s => new { s.Id, s.Title, s.Position, s.ContentRecruit, s.Date, s.Picture }); return(Json(new { msg = "Thêm thành công", re = rs })); } catch { return(Json(new { msg = "Có lỗi xảy ra. Vui lòng thử lại" })); } }
public JsonResult Edit(C_Recruitment recruit) { try { var recruits = db.C_Recruitment.Find(recruit.Id); recruits.Title = recruit.Title; recruits.ContentRecruit = recruit.ContentRecruit; recruits.Position = recruit.Position; db.Entry(recruits).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var rs = db.C_Recruitment.Select(s => new { s.Id, s.Title, s.Position, s.ContentRecruit, s.Date, s.Picture }); return(Json(new { msg = "Chỉnh sửa thành công", re = rs })); } catch { return(Json(new { msg = "Có lỗi xảy ra. Vui lòng thử lại" })); } }