/// <summary>
        /// Integration test for SchoolbushistoriesGet
        /// </summary>
        public async void TestSchoolBusHistory()
        {
            var request = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbushistories");
            SchoolBusHistory schoolBusHistory = new SchoolBusHistory();

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

            schoolBusHistory = JsonConvert.DeserializeObject <SchoolBusHistory>(jsonString);

            // get the id
            var id = schoolBusHistory.Id;

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

            response.EnsureSuccessStatusCode();

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

            response.EnsureSuccessStatusCode();

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

            schoolBusHistory = JsonConvert.DeserializeObject <SchoolBusHistory>(jsonString);

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

            Assert.Equal(response.StatusCode, HttpStatusCode.NotFound);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>

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

        public virtual IActionResult SchoolbushistoriesIdPutAsync(int id, SchoolBusHistory body)
        {
            var exists = _context.SchoolBusHistorys.Any(a => a.Id == id);

            if (exists && id == body.Id)
            {
                _context.SchoolBusHistorys.Update(body);
                // Save the changes
                _context.SaveChanges();
                return(new ObjectResult(body));
            }
            else
            {
                return(new StatusCodeResult(404));
            }
        }
 /// <summary>
 /// Setup the test.
 /// </summary>
 public SchoolBusHistoryModelTests()
 {
     instance = new SchoolBusHistory();
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>

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

        public virtual IActionResult SchoolbushistoriesPostAsync(SchoolBusHistory body)
        {
            _context.SchoolBusHistorys.Add(body);
            _context.SaveChanges();
            return(new ObjectResult(body));
        }
 public virtual IActionResult SchoolbushistoriesPost([FromBody] SchoolBusHistory item)
 {
     return(this._service.SchoolbushistoriesPostAsync(item));
 }
 public virtual IActionResult SchoolbushistoriesIdPut([FromRoute] int id, [FromBody] SchoolBusHistory item)
 {
     return(this._service.SchoolbushistoriesIdPutAsync(id, item));
 }