Exemple #1
0
 public void AddSPicture(SPicture spicture)
 {
     SPictures.Add(spicture);
     SaveChanges();
 }
Exemple #2
0
 public void RemoveSPicture(SPicture spicture)
 {
     SPictures.Remove(spicture);
     SaveChanges();
 }
        public ActionResult EditSPicture(SPicture spicture, HttpPostedFileBase image)
        {
            if (ModelState.IsValid && image != null && spicture.Name != "")
            {
                SPicture SPicture = null;

                if (spicture.Id == 0)
                {
                    SPicture = spicture;
                    SPicture.PictureMimeType = image.ContentType;
                    SPicture.PictureData = new byte[image.ContentLength];
                    image.InputStream.Read(SPicture.PictureData, 0, image.ContentLength);
                    context.AddSPicture(SPicture);
                }
                else
                {
                    SPicture = context.GetSPictureById(spicture.Id);
                    SPicture.Name = spicture.Name;
                    SPicture.PictureMimeType = image.ContentType;
                    SPicture.PictureData = new byte[image.ContentLength];
                    image.InputStream.Read(SPicture.PictureData, 0, image.ContentLength);
                }

                context.SaveChanges();
            }
            return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString());
        }