示例#1
0
 // DELETE api/values/5
 public bool Delete(int id)
 {
     using (Models.School_TestEntities entites = new Models.School_TestEntities())
     {
         var date = entites.ContextTable.Where(a => a.ID == id).FirstOrDefault();
         entites.ContextTable.Remove(date);
         if (entites.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
示例#2
0
        public bool AddDate(Models.ContextTable model)
        {
            var date = model;

            using (Models.School_TestEntities entites = new Models.School_TestEntities())
            {
                entites.ContextTable.Add(date);
                if (entites.SaveChanges() > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
        // PUT api/values/5
        public bool UpdateDate(Models.ContextTable datemodel)
        {
            // var date = JsonConvert.DeserializeObject<Models.ContextTable>(value);
            using (Models.School_TestEntities entites = new Models.School_TestEntities())
            {
                var model = entites.ContextTable.Where(a => a.ID == datemodel.ID).FirstOrDefault();
                model.Title   = datemodel.Title;
                model.AddTime = datemodel.AddTime;
                model.Context = datemodel.Context;

                if (entites.SaveChanges() > 0)
                {
                    return(true);
                }
                return(false);
            }
        }