Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Photo")] CategoryTbl categoryTbl)
        {
            if (id != categoryTbl.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoryTbl);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryTblExists(categoryTbl.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryTbl));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(long id)
        {
            CategoryTbl categoryTbl = db.CategoryTbls.Find(id);

            db.CategoryTbls.Remove(categoryTbl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "CategoryID,MainCategoryID,CategoryName")] CategoryTbl categoryTbl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoryTbl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID);
     return(View(categoryTbl));
 }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Photo")] CategoryTbl categoryTbl)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoryTbl);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoryTbl));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "CategoryID,MainCategoryID,CategoryName")] CategoryTbl categoryTbl)
        {
            if (ModelState.IsValid)
            {
                db.CategoryTbls.Add(categoryTbl);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID);
            return(View(categoryTbl));
        }
Exemple #6
0
 public void save(CategoryVM vm)
 {
     try
     {
         CategoryTbl entity = new CategoryTbl();
         entity.CategoryName = vm.CategoryName;
         _MarbalContext.Entry(entity).State = EntityState.Added;
         _MarbalContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #7
0
        // GET: Store/Category/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CategoryTbl categoryTbl = db.CategoryTbls.Find(id);

            if (categoryTbl == null)
            {
                return(HttpNotFound());
            }
            return(View(categoryTbl));
        }
Exemple #8
0
        // GET: Store/Category/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CategoryTbl categoryTbl = db.CategoryTbls.Find(id);

            if (categoryTbl == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID);
            return(View(categoryTbl));
        }
 private void LoadForm()
 {
     //SelectedItem = _categoryTblService.GetAll().Where(c => c.Category_Kubun == 0).SingleOrDefault();
     SelectCategory();
     SelectedItem = Categorys[3];
 }