public void Post([FromBody] JObject value) { Success posted = value.ToObject <Success>(); using (SuccessDb db = new SuccessDb()) { db.Successes.Add(posted); db.SaveChanges(); } }
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(); } } }
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(); } }