public ActionResult Edit(SparePart sparepart)
 {
     if (ModelState.IsValid)
     {
         SparePartDAL.UpdateSparePart(sparepart);
         return RedirectToAction("Index");
     }
     return View(sparepart);
 }
        public ActionResult Create(SparePart sparepart)
        {
            if (ModelState.IsValid)
            {
                sparepart.UserId = WebSecurity.CurrentUserId;
                sparepart.Activated = true;
                SparePartDAL.AddSparePart(sparepart);
                return RedirectToAction("Index");
            }

            return View(sparepart);
        }
 /// <summary>
 /// Create a new SparePart object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="partName">Initial value of the PartName property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="activated">Initial value of the Activated property.</param>
 public static SparePart CreateSparePart(global::System.Int32 id, global::System.String partName, global::System.Decimal price, global::System.Boolean activated)
 {
     SparePart sparePart = new SparePart();
     sparePart.Id = id;
     sparePart.PartName = partName;
     sparePart.Price = price;
     sparePart.Activated = activated;
     return sparePart;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the SpareParts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSpareParts(SparePart sparePart)
 {
     base.AddObject("SpareParts", sparePart);
 }
 public ActionResult Edit(SparePart sparepart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sparepart).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.UserId = new SelectList(db.UserProfiles, "UserId", "UserName", sparepart.UserId);
     return View(sparepart);
 }
Beispiel #6
0
 public static void UpdateSparePart(SparePart sparePart)
 {
     db.Entry(sparePart).State = EntityState.Modified;
     db.SaveChanges();
 }
Beispiel #7
0
 public static void AddSparePart(SparePart sparePart)
 {
     db.SpareParts.Add(sparePart);
     db.SaveChanges();
 }