public int Add(clockrecord cc) { using (var ctx = new oneallEntities()) { ctx.clockrecord.Add(cc); return(ctx.SaveChanges()); } }
public ActionResult Get() { using (var ctx = new oneallEntities()) { IQueryable <clockrecord> queryable = ctx.clockrecord; var json = queryable.ToList().Select(x => new { id = x.id, createat = x.createat.Value.ToString("yyyy-MM-dd HH:mm:ss"), location = x.location }); return(Json(json, JsonRequestBehavior.AllowGet)); } }
public ActionResult List(int page, int pagesize) { using (var ctx = new oneallEntities()) { IQueryable <clockrecord> queryable = ctx.clockrecord.OrderByDescending(m => m.id).Skip((page - 1) * pagesize < 0 ? 0 : (page - 1) * pagesize).Take(pagesize); var json = queryable.ToList().Select(x => new { id = x.id, createat = x.createat.Value.ToString("yyyy-MM-dd HH:mm:ss"), location = x.location, describe = x.describe }); return(Json(json, JsonRequestBehavior.AllowGet)); } }