public void EditReading(int versID, int numEntries) { ReadingLogEntry log = db.ReadingLogEntries.Find(versID); if (log == null) { log = new ReadingLogEntry() { NumEntries = numEntries, VersID = versID }; db.ReadingLogEntries.Add(log); } else log.NumEntries = numEntries; db.SaveChanges(); }
// POST api/<controller> public void Post(LogDTO log) { try { ReadingLogEntry newLog = new ReadingLogEntry() { VersID = log.VersID, NumEntries = log.NumEntries }; db.ReadingLogEntries.Add(newLog); db.SaveChanges(); } catch { throw new HttpResponseException(HttpStatusCode.BadRequest); } }