public ActionResult Create(photoAdd picture)
        {
            if (ModelState.IsValid)
            {
                pic.addPicture(picture);

                return View("Index",pic.getAllPictures());
            }

            return View(picture);
        }
Exemplo n.º 2
0
        public Picture addPicture(photoAdd newItem)
        {
            Picture picture = new Picture();

            byte[] logoBytes = new byte[newItem.PhotoUpload.ContentLength];
            newItem.PhotoUpload.InputStream.Read(logoBytes, 0, newItem.PhotoUpload.ContentLength);

            picture.Id = newItem.Id;
            picture.Name = newItem.Name;
            picture.Image = logoBytes;
            picture.ImageType = newItem.PhotoUpload.ContentType;

            dc.Pictures.Add(picture);
            dc.SaveChanges();

            return picture;
        }