public async Task <IActionResult> Put(int id, [FromBody] RequiredCoursework requirement) { //this will test to see if the model state coming in meets the requirements placed on the model using data annotations/model binding if (!ModelState.IsValid) { BadRequest(ModelState); } var check = _context.RequiredCoursework.FirstOrDefault(v => v.ID == id); if (check != null) { check.Class = requirement.Class; check.IsComplete = requirement.IsComplete; _context.Update(check); await _context.SaveChangesAsync(); return(CreatedAtAction("Get", new { id = requirement.ID }, requirement)); } //attempting to find a way to use Put when an item is not there to be replaced else if (check == null) { await Post(requirement); } return(BadRequest()); }
public async Task <IActionResult> Post([FromBody] RequiredCoursework requirement) { await _context.AddAsync(requirement); await _context.SaveChangesAsync(); //this will return a get URL that references the new requirement added return(CreatedAtAction("Get", new { id = requirement.ID }, requirement)); }
public void ClassPropertyIsAString() { //Arrange var firstPeriod = new RequiredCoursework(); //Act var result = firstPeriod.Class; //Assert Assert.IsType(typeof(string), result); }
public void IDIsAnInt() { //Arrange var newID = new RequiredCoursework(); //Act var result = newID.ID; //Assert Assert.IsType(typeof(int), result); }