Exemplo n.º 1
0
        public override string UploadImage(MemoryStream memoryStream, string imageName, out ImageErrorModel errorModel)
        {
            string imagePath = "";

            Logging.Logging logging = new Logging.Logging();

            errorModel = new ImageErrorModel();
            try
            {
                Image image = null;
                using (image = Image.FromStream(memoryStream))
                {
                    if (image.Width < defaultWidth || image.Height < defaultHeight)
                    {
                        //      image = resize(defaultWidth, defaultHeight, image);
                    }
                    imagePath = defaultLocationImage + "\\" + imageName;
                    image.Save(imagePath);
                    errorModel.isSuccess = true;
                    return("~/" + subRoot + "/" + imageName);
                }
            }
            catch (Exception e)
            {
                errorModel.exception       = e;
                errorModel.isSuccess       = false;
                errorModel.message         = "Không thể upload hình thành công";
                errorModel.ImageUploadEnum = Common.Enum.Log.ImageUploadEnum.Local;
                logging.ErrorLogs(errorModel.ToString());
                return("false");
            }
        }