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

            var request = new HttpRequestMessage(HttpMethod.Post, "/api/schoolbusattachments");
            SchoolBusAttachment schoolBusAttachment = new SchoolBusAttachment();

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

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

            // make a change.

            // now do an update.

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

            response.EnsureSuccessStatusCode();

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

            response.EnsureSuccessStatusCode();

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

            schoolBusAttachment = JsonConvert.DeserializeObject <SchoolBusAttachment>(jsonString);

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

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

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

        public virtual IActionResult SchoolbusattachmentsIdPutAsync(int id, SchoolBusAttachment body)
        {
            var exists = _context.SchoolBusAttachments.Any(a => a.Id == id);

            if (exists && id == body.Id)
            {
                _context.SchoolBusAttachments.Update(body);
                // Save the changes
                _context.SaveChanges();
                return(new StatusCodeResult(200));
            }
            else
            {
                return(new StatusCodeResult(404));
            }
        }
 /// <summary>
 /// Setup the test.
 /// </summary>
 public SchoolBusAttachmentModelTests()
 {
     instance = new SchoolBusAttachment();
 }
        /// <summary>
        ///
        /// </summary>

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

        public virtual IActionResult SchoolbusattachmentsPostAsync(SchoolBusAttachment body)
        {
            _context.SchoolBusAttachments.Add(body);
            _context.SaveChanges();
            return(new ObjectResult(body));
        }
 public virtual IActionResult SchoolbusattachmentsPost([FromBody] SchoolBusAttachment item)
 {
     return(this._service.SchoolbusattachmentsPostAsync(item));
 }
 public virtual IActionResult SchoolbusattachmentsIdPut([FromRoute] int id, [FromBody] SchoolBusAttachment item)
 {
     return(this._service.SchoolbusattachmentsIdPutAsync(id, item));
 }