Пример #1
0
        public void Post([FromBody] JObject value)
        {
            Success posted = value.ToObject <Success>();

            using (SuccessDb db = new SuccessDb()) {
                db.Successes.Add(posted);
                db.SaveChanges();
            }
        }
Пример #2
0
 public void Delete(int id)
 {
     using (SuccessDb db = new SuccessDb()) {
         if (db.Successes.Where(Success => Success.Id == id).Count() > 0)
         {
             db.Successes.Remove(db.Successes.First(Success => Success.Id == id));
             db.SaveChanges();
         }
     }
 }
Пример #3
0
        public void Put(int id, [FromBody] JObject value)
        {
            Success posted = value.ToObject <Success>();

            posted.Id = id;
            using (SuccessDb db = new SuccessDb()) {
                db.Successes.Update(posted);
                db.SaveChanges();
            }
        }