예제 #1
0
        public IHttpActionResult GetProdGallery(int id)
        {
            ProdGallery prodGallery = db.ProdGalleries.Find(id);

            if (prodGallery == null)
            {
                return(NotFound());
            }

            return(Ok(prodGallery));
        }
예제 #2
0
        public String POST()
        {
            int counter = 0;

            //COLLECTING FILES------->
            System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            string      url    = HttpContext.Current.Request.Url.AbsoluteUri;
            ProdGallery picfun = new ProdGallery();

            String Status = "";

            for (int i = 0; i < files.Count; i++)
            {
                //GET THE POSTED FILES------>
                System.Web.HttpPostedFile file = files[i];

                string fileName = new FileInfo(file.FileName).Name;


                if (file.ContentLength > 0)
                {
                    Guid id = Guid.NewGuid();

                    string modifiedFileName = id.ToString() + "_" + fileName;

                    byte[] imageb = new byte[file.ContentLength];
                    file.InputStream.Read(imageb, 0, file.ContentLength);

                    picfun.Image = imageb;
                    db.ProdGalleries.Add(picfun);
                    db.SaveChanges();
                    counter++;
                }
            }

            if (counter > 0)
            {
                return(Status);
            }
            return("Upload Failed");
        }