public Choice toChoice() { DiplomaContext ctx = new DiplomaContext(); Choice choice = new Choice { StudentNumber = this.StudentNumber, FirstName = this.FirstName, LastName = this.LastName, //Term = ctx.Terms.Find(this.Term), Term_TermCode = ctx.Terms.Find(this.Term).TermCode, //FirstChoice = ctx.Options.Find(this.FirstChoice), FirstChoice_Title = ctx.Options.Find(this.FirstChoice).Title, //SecondChoice = ctx.Options.Find(this.SecondChoice), SecondChoice_Title = ctx.Options.Find(this.SecondChoice).Title, //ThirdChoice = ctx.Options.Find(this.ThirdChoice), ThirdChoice_Title = ctx.Options.Find(this.ThirdChoice).Title, //FourthChoice = ctx.Options.Find(this.FourthChoice), FourthChoice_Title = ctx.Options.Find(this.FourthChoice).Title }; return choice; }
// PUT api/ChoiceAPI/5 public IHttpActionResult PutChoice(int id, Choice choice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != choice.ChoiceId) { return BadRequest(); } db.Entry(choice).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ChoiceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }