コード例 #1
0
        public ActionResult EditBrand(int id = 0)
        {
            TblBrand obj = dbContext.TblBrands.Where(x => x.BrandId == id).FirstOrDefault();

            if (obj == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BrandList = dbContext.TblBrands.ToList();
            return(View("Index", obj));
        }
コード例 #2
0
        public ActionResult BrandSaveChanges(TblBrand obj)
        {
            if (obj.BrandId > 0)
            {
                TblBrand objbrand = dbContext.TblBrands.Where(x => x.BrandId == obj.BrandId).FirstOrDefault();
                objbrand.BrandName = obj.BrandName;
            }
            else
            {
                dbContext.TblBrands.Add(obj);
            }

            dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }