Пример #1
0
        /// <summary>
        /// Integration test for SchoolbusnotesGet
        /// </summary>
        public async void TestSchoolbusNotes()
        {
            // now create a school bus owner record

            var           request       = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbusnotes");
            SchoolBusNote schoolBusNote = new SchoolBusNote();

            var jsonString = schoolBusNote.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();

            schoolBusNote = JsonConvert.DeserializeObject <SchoolBusNote>(jsonString);
            // get the id
            var id = schoolBusNote.Id;

            // make a change.

            // now do an update.

            request         = new HttpRequestMessage(HttpMethod.Put, "/api/schoolbusnotes/" + id);
            request.Content = new StringContent(schoolBusNote.ToJson(), Encoding.UTF8, "application/json");
            response        = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // do a get.
            request  = new HttpRequestMessage(HttpMethod.Get, "/api/schoolbusnotes/" + id);
            response = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // parse as JSON.
            jsonString = await response.Content.ReadAsStringAsync();

            schoolBusNote = JsonConvert.DeserializeObject <SchoolBusNote>(jsonString);

            // do a delete.
            request  = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbusnotes/" + 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/schoolbusnotes/" + id);
            response = await _client.SendAsync(request);

            Assert.Equal(response.StatusCode, HttpStatusCode.NotFound);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>

        /// <param name="id">id of SchoolBusNote to fetch</param>
        /// <response code="200">OK</response>
        /// <response code="404">SchoolBusNote not found</response>

        public virtual IActionResult SchoolbusnotesIdPutAsync(int id, SchoolBusNote body)
        {
            var exists = _context.SchoolBusNotes.Any(a => a.Id == id);

            if (exists && id == body.Id)
            {
                _context.SchoolBusNotes.Update(body);
                // Save the changes
                _context.SaveChanges();
                return(new ObjectResult(body));
            }
            else
            {
                return(new StatusCodeResult(404));
            }
        }
Пример #3
0
 /// <summary>
 /// Setup the test.
 /// </summary>
 public SchoolBusNoteModelTests()
 {
     instance = new SchoolBusNote();
 }
Пример #4
0
 public virtual IActionResult SchoolbusnotesPost([FromBody] SchoolBusNote item)
 {
     return(this._service.SchoolbusnotesPostAsync(item));
 }
Пример #5
0
 public virtual IActionResult SchoolbusnotesIdPut([FromRoute] int id, [FromBody] SchoolBusNote item)
 {
     return(this._service.SchoolbusnotesIdPutAsync(id, item));
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>

        /// <param name="body"></param>
        /// <response code="201">SchoolBusNote created</response>

        public virtual IActionResult SchoolbusnotesPostAsync(SchoolBusNote body)
        {
            _context.SchoolBusNotes.Add(body);
            _context.SaveChanges();
            return(new ObjectResult(body));
        }