コード例 #1
0
 public ActionResult Edit(Sample sample)
 {
     if (ModelState.IsValid)
     {
         db.Samples.Attach(sample);
         db.ObjectStateManager.ChangeObjectState(sample, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(sample);
 }
コード例 #2
0
        public ActionResult Create(Sample sample)
        {
            if (ModelState.IsValid)
            {
                sample.SampleID = Guid.NewGuid();
                db.Samples.AddObject(sample);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(sample);
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Samples EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSamples(Sample sample)
 {
     base.AddObject("Samples", sample);
 }
コード例 #4
0
 /// <summary>
 /// Create a new Sample object.
 /// </summary>
 /// <param name="sampleID">Initial value of the SampleID property.</param>
 public static Sample CreateSample(global::System.Guid sampleID)
 {
     Sample sample = new Sample();
     sample.SampleID = sampleID;
     return sample;
 }