示例#1
0
        public void WhenCreatingCampus_AssertCampusAdded()
        {
            int lastCampusId = GetLastCampusId();
            var newCampus    = new CampusDTO {
                Name = "New Test Campus"
            };
            var newCampusId = _campusService.CreateCampus(newCampus);

            Assert.Equal(lastCampusId + 1, newCampusId);
        }
        public HttpResponseMessage CreateCampus([FromBody] CampusDTO campusDTO)
        {
            int    newID = _campusService.CreateCampus(campusDTO);
            string uri   = Url.Link("CampusByIDRoute", new { id = newID });
            // Generate a link to the new campus and set the location header in the response.
            var response = new HttpResponseMessage(HttpStatusCode.Created);

            response.Headers.Location = new System.Uri(uri);
            return(response);
        }
示例#3
0
        public async Task <ActionResult <CampusResponse> > InsertCampus([FromBody] PostCampusRequest model)
        {
            var rs = await _campusService.CreateCampus(model);

            return(Ok(rs));
        }