public async Task <ActionResult> DeleteConfirmed(int id) { Mebel mebel = await db.Mebels.FindAsync(id); db.Mebels.Remove(mebel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Mebel_id,Mebel_name")] Mebel mebel) { if (ModelState.IsValid) { db.Entry(mebel).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(mebel)); }
public async Task <ActionResult> Create([Bind(Include = "Mebel_id,Mebel_name")] Mebel mebel) { if (ModelState.IsValid) { db.Mebels.Add(mebel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(mebel)); }
// GET: Mebels/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mebel mebel = await db.Mebels.FindAsync(id); if (mebel == null) { return(HttpNotFound()); } return(View(mebel)); }
public void Delete(MebelBindingModel model) { using (var context = new MebelDatabase()) { Mebel element = context.Mebel.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Mebel.Remove(element); context.SaveChanges(); } else { throw new Exception("Мебель не найдена"); } } }
private Mebel CreateModel(MebelBindingModel model, Mebel mebel) { mebel.Name = model.Name; mebel.Price = model.Price; return(mebel); }