Ejemplo n.º 1
0
        // POST: odata/V_Student
        public IHttpActionResult Post(V_Student V_Student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.V_Student.Add(V_Student);
            db.SaveChanges();

            return(Created(V_Student));
        }
Ejemplo n.º 2
0
        // DELETE: odata/V_Student(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            V_Student V_Student = db.V_Student.Find(key);

            if (V_Student == null)
            {
                return(NotFound());
            }

            db.V_Student.Remove(V_Student);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <V_Student> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            V_Student V_Student = db.V_Student.Find(key);

            if (V_Student == null)
            {
                return(NotFound());
            }

            patch.Patch(V_Student);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!V_StudentExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(V_Student));
        }