public SparePart FindById(int spareId) { SparePart temp = new SparePart(); Run(db => { temp = db.SpareParts.Where(x => x.Id == spareId).FirstOrDefault(); }); return temp; }
public virtual ActionResult Edit(SparePart sparePart) { if (ModelState.IsValid) { _db.SavePart(sparePart); TempData["message"] = string.Format("Изменения в товаре \"{0}\" были сохранены", sparePart.MarkWithModel); return RedirectToAction("Index"); } return View(sparePart); }
public ViewResult Edit(SparePart model) { if (ModelState.IsValid) { SaveGame(model); TempData["message"] = string.Format("Изменения в игре \"{0}\" были сохранены", model.MarkWithModel); return View("Index", db.SpareParts); } return View(model); }
private void SaveGame(SparePart sparepart) { if (sparepart.Id== 0) db.SpareParts.Add(sparepart); else { SparePart dbEntry = db.SpareParts.Find(sparepart.Id); db.Entry(dbEntry).CurrentValues.SetValues(sparepart); } db.SaveChanges(); }
public void SavePart(SparePart sparePart) { Run(db => { if (sparePart.Id == 0) { db.SpareParts.Add(sparePart); } else { SparePart dbEntry = db.SpareParts.Find(sparePart.Id); db.Entry(dbEntry).CurrentValues.SetValues(sparePart.Id); } db.SaveChanges(); }); }
public void AddItem(SparePart sparepart, int quantity) { CartPosition CurrentPosition = PositionCollection .Where(g => g.SparePart.Id == sparepart.Id) .FirstOrDefault(); if (CurrentPosition == null) { PositionCollection.Add(new CartPosition { SparePart = sparepart, Quantity = quantity }); } else { CurrentPosition.Quantity += quantity; } }
public void RemoveLine(SparePart sparepart) { PositionCollection .RemoveAll(line => line.SparePart.Id == sparepart.Id); }