Пример #1
0
        public ActionResult ProductPhotoes_Create([DataSourceRequest]DataSourceRequest request, ProductPhoto productPhoto)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductPhoto
                {
                    ThumbNailPhoto = productPhoto.ThumbNailPhoto,
                    ThumbnailPhotoFileName = productPhoto.ThumbnailPhotoFileName,
                    LargePhoto = productPhoto.LargePhoto,
                    LargePhotoFileName = productPhoto.LargePhotoFileName,
                    ModifiedDate = DateTime.Now
                };

                db.ProductPhotoes.Add(entity);
                db.SaveChanges();
                productPhoto.ProductPhotoID = entity.ProductPhotoID;
            }

            return Json(new[] { productPhoto }.ToDataSourceResult(request, ModelState));
        }
Пример #2
0
        public ActionResult ProductPhotoes_Destroy([DataSourceRequest]DataSourceRequest request, ProductPhoto productPhoto)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductPhoto
                {
                    ProductPhotoID = productPhoto.ProductPhotoID,
                    ThumbNailPhoto = productPhoto.ThumbNailPhoto,
                    ThumbnailPhotoFileName = productPhoto.ThumbnailPhotoFileName,
                    LargePhoto = productPhoto.LargePhoto,
                    LargePhotoFileName = productPhoto.LargePhotoFileName,
                    ModifiedDate = productPhoto.ModifiedDate
                };

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

            return Json(new[] { productPhoto }.ToDataSourceResult(request, ModelState));
        }
Пример #3
0
        public ActionResult ProductPhotoes_Update([DataSourceRequest]DataSourceRequest request, ProductPhoto productPhoto)
        {
            if (ModelState.IsValid)
            {
                var entity = new ProductPhoto
                {
                    ProductPhotoID = productPhoto.ProductPhotoID,
                    ThumbNailPhoto = productPhoto.ThumbNailPhoto,
                    ThumbnailPhotoFileName = productPhoto.ThumbnailPhotoFileName,
                    LargePhoto = productPhoto.LargePhoto,
                    LargePhotoFileName = productPhoto.LargePhotoFileName,
                    ModifiedDate = DateTime.Now

                };

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

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