Ejemplo n.º 1
0
 public static string AddProductsImg(int PID, string Image_binary, string Image_name)
 {
     try
     {
         PAWDStoreEntities context   = new PAWDStoreEntities();
         byte[]            ImageFile = null;
         if (Image_binary != null && !string.IsNullOrEmpty(Image_binary))
         {
             ImageFile = Convert.FromBase64String(Image_binary);
         }
         if (ImageFile != null)
         {
             string filePath = HttpContext.Current.Server.MapPath(string.Format("~/ProductImage/" + Image_name + ""));
             File.WriteAllBytes(filePath, ImageFile);
         }
         var status = context.ProductImageInsert(PID, null, Image_name, DateTime.Now, null, string.Empty).SingleOrDefault();
         return(JsonConvert.SerializeObject(status));
     }
     catch (Exception ex)
     {
         throw ex.InnerException;
     }
 }