Ejemplo n.º 1
0
        public async Task <ActionResult> CreateFixedImageModal(CreateFixedImageModel model, HttpPostedFileBase imageFile)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!imageFile.IsValidImage())
            {
                ModelState.AddModelError("", "Invalid image upload");
                return(View(model));
            }

            model.ImageStream = imageFile.InputStream;
            var result = await ImageWriter.CreateFixedImage(model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(View(model));
            }

            return(CloseModalSuccess());
        }