コード例 #1
0
ファイル: ProgramRepo.cs プロジェクト: hjc879227/WebServices
        // Update specific program
        public ProgramUpdate UpdateProgram(ProgramUpdate updatedProgram)
        {
            var p = ds.Programs.Find(updatedProgram.ProgramId);

            if (p == 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(p).CurrentValues.SetValues(updatedProgram);
                ds.SaveChanges();
                return updatedProgram;
            }
        }
コード例 #2
0
 public HttpResponseMessage PutProg(int id, ProgramUpdate program)
 {
     if (ModelState.IsValid && id == program.ProgramId)
     {
         // Attempt to update the item
         var updatedProgram = r.UpdateProgram(program);
         return (updatedProgram == null) ?
             Request.CreateResponse(HttpStatusCode.BadRequest) :
             Request.CreateResponse(HttpStatusCode.OK, updatedProgram);
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }