Beispiel #1
0
        public async Task <IActionResult> Edit(string id, [Bind("CatId,CatName")] CatMst catMst)
        {
            if (id != catMst.CatId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(catMst);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CatMstExists(catMst.CatId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(catMst));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            CatMst catMst = db.CatMsts.Find(id);

            db.CatMsts.Remove(catMst);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(CatMst cat)
 {
     if (ModelState.IsValid)
     {
         db.Edit(cat);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
 public ActionResult Edit([Bind(Include = "CatId,CatName,CatThumbnail")] CatMst catMst)
 {
     if (ModelState.IsValid)
     {
         db.Entry(catMst).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(catMst));
 }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("CatId,CatName")] CatMst catMst)
        {
            if (ModelState.IsValid)
            {
                _context.Add(catMst);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(catMst));
        }
        public ActionResult Create([Bind(Include = "CatName,CatId,CatThumbnail")] CatMst catMst)
        {
            catMst.CatId = "cat" + Guid.NewGuid().ToString().GetHashCode().ToString("x");
            if (ModelState.IsValid)
            {
                db.CatMsts.Add(catMst);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(catMst));
        }
        // GET: Admin/CatMsts/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CatMst catMst = db.CatMsts.Find(id);

            if (catMst == null)
            {
                return(HttpNotFound());
            }
            return(View(catMst));
        }