// GET: DonVi/Delete/5 public async Task <ActionResult> Delete(string key) { if (key == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TD_DVKT d = await db.TD_DVKT.FindAsync(key); if (d == null) { return(HttpNotFound()); } return(PartialView(d)); }
public async Task <ActionResult> DeleteConfirmed(string MA) { try { TD_DVKT d = await db.TD_DVKT.FindAsync(MA); db.TD_DVKT.Remove(d); await db.SaveChangesAsync(); TempData["Msg"] = "Đã xóa"; } catch (Exception ex) { TempData["Msg"] = "Có lỗi" + ex; } return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(TD_DVKT d) { if (ModelState.IsValid) { try { db.Entry(d).State = EntityState.Modified; await db.SaveChangesAsync(); TempData["Msg"] = "Đã sửa"; } catch (Exception) { TempData["Msg"] = "Có lỗi"; } return(RedirectToAction("Index")); } return(PartialView(d)); }
public async Task <ActionResult> Create(TD_DVKT d) { if (ModelState.IsValid) { try { db.TD_DVKT.Add(d); await db.SaveChangesAsync(); TempData["Msg"] = "Đã thêm 1 đơn vị mới"; } catch (Exception) { TempData["Msg"] = "Có lỗi"; } return(RedirectToAction("Index")); } return(PartialView(d)); }