Exemplo n.º 1
0
        // PUT api/UniversalCourse/5
        public HttpResponseMessage PutUniversalCourse(string code, UniversalCourse universalcourse)
        {
            if (ModelState.IsValid && code == universalcourse.Code)
            {
                db.Entry(universalcourse).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        // PUT api/StudentCourse/5
        public HttpResponseMessage PutStudentCourse(int id, StudentCourse studentcourse)
        {
            if (ModelState.IsValid && id == studentcourse.Id)
            {
                db.Entry(studentcourse).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 3
0
        // PUT api/universities/{universityCode}/programs/{programCode}
        public HttpResponseMessage PutProgram(string universityCode, EIProgram program)
        {
            if (ModelState.IsValid)
            {
                program.EducationalInstitute = db.EducationalInstitutes.Single(u => u.Code == universityCode);
                db.Entry(program).State      = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }