コード例 #1
0
        public ActionResult ProductSubcategories_Create([DataSourceRequest]DataSourceRequest request, ProductSubcategory productSubcategory)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductSubcategory
                {
                    ProductCategoryID = productSubcategory.ProductCategoryID,

                    Name = productSubcategory.Name,
                    rowguid = Guid.NewGuid(),
                    ModifiedDate = DateTime.Now
                };

                db.ProductSubcategories.Add(entity);
                db.SaveChanges();
                productSubcategory.ProductSubcategoryID = entity.ProductSubcategoryID;
            }

            return Json(new[] { productSubcategory }.ToDataSourceResult(request, ModelState));
        }
コード例 #2
0
        public ActionResult ProductSubcategories_Destroy([DataSourceRequest]DataSourceRequest request, ProductSubcategory productSubcategory)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductSubcategory
                {
                    ProductCategoryID = productSubcategory.ProductCategoryID,

                    ProductSubcategoryID = productSubcategory.ProductSubcategoryID,
                    Name = productSubcategory.Name,
                    rowguid = productSubcategory.rowguid,
                    ModifiedDate = productSubcategory.ModifiedDate
                };

                db.ProductSubcategories.Attach(entity);
                db.ProductSubcategories.Remove(entity);
                db.SaveChanges();
            }

            return Json(new[] { productSubcategory }.ToDataSourceResult(request, ModelState));
        }
コード例 #3
0
        public ActionResult ProductSubcategories_Update([DataSourceRequest]DataSourceRequest request, ProductSubcategory productSubcategory)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductSubcategory
                {
                    ProductCategoryID = productSubcategory.ProductCategoryID,

                    ProductSubcategoryID = productSubcategory.ProductSubcategoryID,
                    Name = productSubcategory.Name,
                    rowguid = productSubcategory.rowguid,
                    ModifiedDate = DateTime.Now
                };

                db.ProductSubcategories.Attach(entity);
                db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return Json(new[] { productSubcategory }.ToDataSourceResult(request, ModelState));
        }