public IHttpActionResult PutYearTerm(int id, YearTerm yearTerm) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != yearTerm.YearTermId) { return BadRequest(); } db.Entry(yearTerm).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!YearTermExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public JToken registerJSONObject() { JObject stuff = new JObject(); var YearTermList = db.YearTerms.ToList(); var curYearTerm = new YearTerm(); foreach(YearTerm yearTerm in YearTermList) { if (yearTerm.IsDefault) { curYearTerm = yearTerm; break; } } var optionList = db.Options.ToList(); var validOptionsList = new List<Option>(); foreach(Option option in optionList) { if (option.IsActive) { validOptionsList.Add(option); } } var listUsers = appDb.Users.ToList(); stuff.Add("validOptionsList", JsonConvert.SerializeObject(validOptionsList)); stuff.Add("curYearTerm", JsonConvert.SerializeObject(curYearTerm)); stuff.Add("listUsersUserName", JsonConvert.SerializeObject(listUsers)); return stuff; }
public IHttpActionResult PostYearTerm(YearTerm yearTerm) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.YearTerms.Add(yearTerm); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = yearTerm.YearTermId }, yearTerm); }