// POST api/subjects
        public HttpResponseMessage Post(SubjectPublic newSubject)
        {
            return null;

            if (ModelState.IsValid)
            {
                // Add the new program
                var s = r.AddNew(newSubject);

                // Build the response object
                var response = Request.CreateResponse<SubjectFull>(HttpStatusCode.Created, s);

                // Set the Location header
                // The "new Uri" object constructor needs a string argument
                // The ApiController.Url property provides that
                // Its Link() method takes two arguments...
                // A route name, which can be seen in App_Start/WebApiConfig.cs, and
                // A route value, which substitutes for the {id} placeholder
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = s.Id }));

                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.UnsupportedMediaType);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add new
        /// </summary>
        /// <param name="newSubject">New SubjectPublic object</param>
        /// <returns>SubjectFull object</returns>
        public SubjectFull AddNew(SubjectPublic newSubject)
        {
            // Add the Subject object
            var s = ds.Subjects.Add(Mapper.Map<Models.Subject>(newSubject));
            ds.SaveChanges();

            return Mapper.Map<SubjectFull>(s);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add new
        /// </summary>
        /// <param name="newSubject">New SubjectPublic object</param>
        /// <returns>SubjectFull object</returns>
        public SubjectFull AddNew(SubjectPublic newSubject)
        {
            // Add the Subject object
            var s = ds.Subjects.Add(Mapper.Map <Models.Subject>(newSubject));

            ds.SaveChanges();

            return(Mapper.Map <SubjectFull>(s));
        }