예제 #1
0
        public FileContentResult GetImage(int id)
        {
            IRepositoryBase <Photo> repositoryPhoto = new PhotoRepository();
            var photo = repositoryPhoto.GetByID(id);

            return(File(photo.Image, photo.Name));
        }
예제 #2
0
 public ActionResult Edit(Product product, int ProductModelId, int ProductCategoryID, int ProductSubCategoryID, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         if (file != null)
         {
             IRepositoryBase <Photo> repositoryPhoto = new PhotoRepository();
             Photo photo = repositoryPhoto.GetByID(product.PhotoID);
             photo.Name  = file.FileName;
             photo.Image = new byte[file.ContentLength];
             file.InputStream.Read(photo.Image, 0, file.ContentLength);
             product.PhotoID = repositoryPhoto.Update(photo);
         }
         (repository as IProductRepository).Edit(product, ProductModelId, ProductSubCategoryID);
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }