Esempio n. 1
0
        public async Task <ActionResult> Create([Bind(Include = "PurchasedPic_Id,Customer_Id,Title,Picture,UploadDate,DateTaken")]
                                                PurchasedPhoto purchasedPhoto, HttpPostedFileBase ImageFile)
        {
            getCustomerList();
            if (ModelState.IsValid)
            {
                if (ImageFile != null)
                {
                    purchasedPhoto.Picture = new byte[ImageFile.ContentLength];
                    ImageFile.InputStream.Read(purchasedPhoto.Picture, 0, ImageFile.ContentLength);
                }
                if (purchasedPhoto.DateTaken > purchasedPhoto.UploadDate)
                {
                    ViewBag.ErrorMessage = "The date taken cannot exceed the current date.";
                    return(View(purchasedPhoto));
                }
                else
                {
                    db.PurchasedPhotoes.Add(purchasedPhoto);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "CustomerPhoto"));
                }
            }
            return(View(purchasedPhoto));
        }
Esempio n. 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            PurchasedPhoto purchasedPhoto = await db.PurchasedPhotoes.FindAsync(id);

            db.PurchasedPhotoes.Remove(purchasedPhoto);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index", "CustomerPhoto"));
        }
Esempio n. 3
0
        public async Task <ActionResult> Edit(int?id)
        {
            getCustomerList();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchasedPhoto purchasedPhoto = await db.PurchasedPhotoes.FindAsync(id);

            if (purchasedPhoto == null)
            {
                return(HttpNotFound());
            }
            return(View(purchasedPhoto));
        }
Esempio n. 4
0
        public async Task <ActionResult> Details(int?id, byte[] Picture)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchasedPhoto purchasedPhoto = await db.PurchasedPhotoes.FindAsync(id);

            if (purchasedPhoto == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Photo = Picture;
            return(View(purchasedPhoto));
        }
Esempio n. 5
0
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchasedPhoto purchasedPhoto = await db.PurchasedPhotoes.FindAsync(id);

            if (purchasedPhoto == null)
            {
                return(HttpNotFound());
            }
            var photo = (from pic in db.PurchasedPhotoes
                         where pic.PurchasedPic_Id == id
                         select new { pic.Picture }).ToList();

            foreach (var item in photo)
            {
                ViewBag.Photo = item.Picture;
            }
            return(View(purchasedPhoto));
        }