Esempio n. 1
0
        // Update specific gradedwork
        public GradedWorkUpdate UpdateGradedWork(GradedWorkUpdate updatedgradedwork)
        {
            var e = ds.GradedWorks.Find(updatedgradedwork.GradedWorkId);

                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(updatedgradedwork);
                    ds.SaveChanges();
                    return updatedgradedwork;
                }
        }
 public HttpResponseMessage PutGW(int id, GradedWorkUpdate gradedwork)
 {
     if (ModelState.IsValid && id == gradedwork.GradedWorkId)
     {
         // Attempt to update the item
         var updatedgradedwork = r.UpdateGradedWork(gradedwork);
         return (updatedgradedwork == null) ?
             Request.CreateResponse(HttpStatusCode.BadRequest) :
             Request.CreateResponse(HttpStatusCode.OK, updatedgradedwork);
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }