Пример #1
0
        public JObject UploadImage(int?id, HttpPostedFileBase file)
        {
            JObject ArcJson = new JObject();
            int     banner  = 0;

            try
            {
                if (id == null)
                {
                    ArcJson = Funcion.CreateJsonResponse(1, "El Banner no Existe");
                }
                else
                {
                    banner = (int)id;
                    if (file == null)
                    {
                        ArcJson = Funcion.CreateJsonResponse(1, "No hay Imagen Anexa");
                    }
                    else if (!Funcion.ProductExist(banner))
                    {
                        ArcJson = Funcion.CreateJsonResponse(1, "El Banner no Existe");
                    }
                    else
                    {
                        string sExtension = System.IO.Path.GetExtension(file.FileName).Substring(1);
                        Stream stream     = file.InputStream;
                        Image  image      = Image.FromStream(stream);
                        if (image.Height != 125 || image.Width != 425)
                        {
                            ArcJson = Funcion.CreateJsonResponse(1, "La Imagen no tiene las medidas Correctas");
                        }
                        else
                        {
                            ProcessFileImage(banner, image, sExtension);
                            ArcJson = Funcion.CreateJsonResponse(0, "La Imagen se subio Correctamente");
                        }
                    }
                }
                return(ArcJson);
            }
            catch (Exception)
            {
                ArcJson = Funcion.CreateJsonResponse(1, "Ocurrio un Error grave en el Server de Imagenes");
                return(ArcJson);
            }
        }