/// <summary> /// Integration test for SchoolbusownerattachmentsGet /// </summary> public async void TestSchoolBusOwnerAttachments() { // now create a school bus owner record var request = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbusownerattachments"); SchoolBusOwnerAttachment schoolBusOwnerAttachment = new SchoolBusOwnerAttachment(); var jsonString = schoolBusOwnerAttachment.ToJson(); request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json"); var response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); // parse as JSON. jsonString = await response.Content.ReadAsStringAsync(); schoolBusOwnerAttachment = JsonConvert.DeserializeObject <SchoolBusOwnerAttachment>(jsonString); // get the id var id = schoolBusOwnerAttachment.Id; // make a change. // now do an update. request = new HttpRequestMessage(HttpMethod.Put, "/api/schoolbusownerattachments/" + id); request.Content = new StringContent(schoolBusOwnerAttachment.ToJson(), Encoding.UTF8, "application/json"); response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); // do a get. request = new HttpRequestMessage(HttpMethod.Get, "/api/schoolbusownerattachments/" + id); response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); // parse as JSON. jsonString = await response.Content.ReadAsStringAsync(); schoolBusOwnerAttachment = JsonConvert.DeserializeObject <SchoolBusOwnerAttachment>(jsonString); // do a delete. request = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbusownerattachments/" + id + "/delete"); response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); // should get a 404 if we try a get now. request = new HttpRequestMessage(HttpMethod.Get, "/api/schoolbusownerattachments/" + id); response = await _client.SendAsync(request); Assert.Equal(response.StatusCode, HttpStatusCode.NotFound); }
/// <summary> /// /// </summary> /// <param name="id">id of SchoolBusOwnerAttachment to fetch</param> /// <response code="200">OK</response> /// <response code="404">SchoolBusOwnerAttachment not found</response> public virtual IActionResult SchoolbusownerattachmentsIdPutAsync(int id, SchoolBusOwnerAttachment body) { var exists = _context.SchoolBusOwnerAttachments.Any(a => a.Id == id); if (exists && id == body.Id) { _context.SchoolBusOwnerAttachments.Update(body); // Save the changes _context.SaveChanges(); return(new ObjectResult(body)); } else { return(new StatusCodeResult(404)); } }
public virtual IActionResult SchoolbusownerattachmentsPost([FromBody] SchoolBusOwnerAttachment item) { return(this._service.SchoolbusownerattachmentsPostAsync(item)); }
public virtual IActionResult SchoolbusownerattachmentsIdPut([FromRoute] int id, [FromBody] SchoolBusOwnerAttachment item) { return(this._service.SchoolbusownerattachmentsIdPutAsync(id, item)); }
/// <summary> /// Setup the test. /// </summary> public SchoolBusOwnerAttachmentModelTests() { instance = new SchoolBusOwnerAttachment(); }
/// <summary> /// /// </summary> /// <param name="body"></param> /// <response code="201">SchoolBusOwnerAttachment created</response> public virtual IActionResult SchoolbusownerattachmentsPostAsync(SchoolBusOwnerAttachment body) { _context.SchoolBusOwnerAttachments.Add(body); _context.SaveChanges(); return(new ObjectResult(body)); }