예제 #1
0
        public async Task <IActionResult> PutTheloai(string id, Theloai theloai)
        {
            if (id != theloai.Matheloai)
            {
                return(BadRequest());
            }

            _context.Entry(theloai).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TheloaiExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Theloai theloai = db.Theloais.Find(id);

            db.Theloais.Remove(theloai);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Matheloai,Tentheloai,Ghichu")] Theloai theloai)
 {
     if (ModelState.IsValid)
     {
         db.Entry(theloai).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(theloai));
 }
예제 #4
0
        public ActionResult Create([Bind(Include = "Matheloai,Tentheloai,Ghichu")] Theloai theloai)
        {
            if (ModelState.IsValid)
            {
                db.Theloais.Add(theloai);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(theloai));
        }
예제 #5
0
        // GET: Theloais/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Theloai theloai = db.Theloais.Find(id);

            if (theloai == null)
            {
                return(HttpNotFound());
            }
            return(View(theloai));
        }
        // GET: Theloais/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Theloai        theloai  = db.theloais.Find(id);
            List <SanPham> sanPhams = db.sanPhams.Where(x => x.MaLoai == id).ToList();

            if (theloai == null)
            {
                return(HttpNotFound());
            }
            return(View(sanPhams));
        }
예제 #7
0
        public async Task <ActionResult <Theloai> > PostTheloai(Theloai theloai)
        {
            _context.Theloai.Add(theloai);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TheloaiExists(theloai.Matheloai))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTheloai", new { id = theloai.Matheloai }, theloai));
        }