Example #1
0
        // Update specific semester
        public SemesterUpdate UpdateSemester(SemesterUpdate updatedSemester)
        {
            var e = ds.Semesters.Find(updatedSemester.SemesterId);

            if (e == null)
            {
                return null;
            }
            else
            {
                // For the object fetched from the data store,
                // set its values to those provided
                // (the method ignores missing properties, and navigation properties)
                ds.Entry(e).CurrentValues.SetValues(updatedSemester);
                ds.SaveChanges();
                return updatedSemester;
            }
        }
 public HttpResponseMessage PutSem(int id, SemesterUpdate semester)
 {
     if (ModelState.IsValid && id == semester.SemesterId)
     {
         // Attempt to update the item
         var updatedsemester = r.UpdateSemester(semester);
         return (updatedsemester == null) ?
             Request.CreateResponse(HttpStatusCode.BadRequest) :
             Request.CreateResponse(HttpStatusCode.OK, updatedsemester);
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }