コード例 #1
0
        // [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"));
        }
コード例 #2
0
        // [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));
        }
コード例 #3
0
        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));
        }