public ActionResult Upload()
        {
            //These checks should be in an Action Filter.
            //These are cross cutting concerns that can be handled in a filter/aspect.
            if (Request.Files != null && Request.Files.Count == 1 && Request.Files[0].ContentLength < 10285760)
            {
                var _service = Container.Windsor.Resolve<IImageResizerService>();
                var request = new ImageResizerRequest { InputMemoryStream = (MemoryStream)Request.Files[0].InputStream, InputSaveFolder = Server.MapPath("~/Content/Images/"), InputFileName = Request.Files[0].FileName };
                _service.Initialize(request);
                var response = _service.Process();
                TempData.Add("UploadedImage", response.ImageUri);
                //var localPath = Server.MapPath(string.Format("~/Content/Images/{0}", Request.Files[0].FileName));
                //var origionalPath = Server.MapPath(string.Format("~/Content/Images/origional_{0}", Request.Files[0].FileName));
                //var fileName = Request.Files[0].FileName;
                //using (var srcImage = Image.FromStream(Request.Files[0].InputStream))
                //{
                //    if (srcImage.Height > 700 || srcImage.Width > 500)
                //    {
                //        Request.Files[0].SaveAs(origionalPath);
                //    }
                //    ImageBuilder.Current.Build(srcImage, localPath, new ResizeSettings("?maxwidth=500&maxheight=700&format=png"));

                //}
                //TempData.Add("UploadedImage", fileName);
            }
            return RedirectToAction("Index");
        }
        public void Initialize(ImageResizerRequest request)
        {
            //I'd normally use conditions, code contracts or AOP for these upfront assertions.
            if (request.InputMemoryStream == null)
            {
                throw new ArgumentException("InputMemoryStream can't be null. The most common use is Request.Files[0].InputStream");
            }
            _stream = request.InputMemoryStream;

            if (!string.IsNullOrWhiteSpace(request.InputSaveFolder))
            {
                _savePath = request.InputSaveFolder;
            }
            else
            {
                //using default path. (current directory/bin in this case)
                //dead code. will be removed once working prototype.

            }
        }
 public void Initialize_Should_Accept_ImageResizerRequest_With_SaveFolder()
 {
     var request = new ImageResizerRequest { InputMemoryStream = new MemoryStream(), InputSaveFolder = @"E:\Projects\Uploaded\Uploaded\Content\Images" };
     _service.Initialize(request);
 }
 public void Initialize_Should_Accept_ImageResizerRequest()
 {
     var request = new ImageResizerRequest { InputMemoryStream = new MemoryStream() };
     _service.Initialize(request);
 }