// [Audit] public async Task <ActionResult> DeleteConfirmed(int id) { Nuoc nuoc = await db.Nuocs.FindAsync(id); //if (!User.IsInRole("Admin") && nuoc.MaNhaThuoc != this.GetNhaThuoc().MaNhaThuoc) // throw new UnauthorizedAccessException(); db.Nuocs.Remove(nuoc); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// [Audit] public async Task <ActionResult> Edit([Bind(Include = "MaNuoc,TenNuoc,MaNhaThuoc")] Nuoc nuoc) { if (ModelState.IsValid) { //if (!User.IsInRole("Admin") && nuoc.MaNhaThuoc != this.GetNhaThuoc().MaNhaThuoc) // throw new UnauthorizedAccessException(); db.Entry(nuoc).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(nuoc)); }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Nuoc nuoc = await db.Nuocs.FindAsync(id); if (nuoc == null) { return(HttpNotFound()); } //if (!User.IsInRole("Admin") && nuoc.MaNhaThuoc != this.GetNhaThuoc().MaNhaThuoc) // throw new UnauthorizedAccessException(); return(View(nuoc)); }