コード例 #1
0
 public ActionResult Edit(Part part)
 {
     if (ModelState.IsValid && Part.Update(part))
     {
         return RedirectToAction("Index");
     }
     ViewBag.Category_id = new SelectList(Category.All(), "Id", "Name", part.Category_id);
     ViewBag.Vendor_id = new SelectList(Vendor.All(), "Id", "Name", part.Vendor_id);
     return View(part);
 }
コード例 #2
0
ファイル: PartModel.cs プロジェクト: navygator/service_db
        public static bool Create(Part part)
        {
            bool result = true;
            try
            {
                db.Parts.AddObject(part);
                db.SaveChanges();
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
コード例 #3
0
ファイル: PartModel.cs プロジェクト: navygator/service_db
        public static bool Update(Part part)
        {
            bool result = true;
            try
            {
                EntityDataModelContainer mc = new EntityDataModelContainer();
                mc.Parts.Attach(part);
                mc.ObjectStateManager.ChangeObjectState(part, EntityState.Modified);
                mc.SaveChanges();
                db.Refresh(System.Data.Objects.RefreshMode.StoreWins, part);
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Parts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToParts(Part part)
 {
     base.AddObject("Parts", part);
 }
コード例 #5
0
 /// <summary>
 /// Create a new Part object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="category_id">Initial value of the Category_id property.</param>
 /// <param name="vendor_id">Initial value of the Vendor_id property.</param>
 /// <param name="part_num">Initial value of the Part_num property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static Part CreatePart(global::System.Int32 id, global::System.Int32 category_id, global::System.Int32 vendor_id, global::System.String part_num, global::System.String description)
 {
     Part part = new Part();
     part.Id = id;
     part.Category_id = category_id;
     part.Vendor_id = vendor_id;
     part.Part_num = part_num;
     part.Description = description;
     return part;
 }