public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            BaseWithImages model = (BaseWithImages)base.BindModel(controllerContext, bindingContext);

            List <Image> images = GetAndSavePostedImages(controllerContext.HttpContext.Request, model.DetermineImageType());

            if (images.Count != controllerContext.HttpContext.Request.Files.Count)
            {
                bindingContext.ModelState.AddModelError("Images", "Failed to save some of the files");
            }
            if (images.Count > 0)
            {
                model.Images = new ImageSet(images);
            }
            return(model);
        }
Пример #2
0
 public static MvcHtmlString ListItemWithImage(this HtmlHelper helper, BaseWithImages model, bool adminMode, string targetControllerName)
 {
     return(ListItemWithImage(helper, new ListItemWithImageModel {
         Model = model, AdminMode = adminMode, TargetControllerName = targetControllerName
     }));
 }
Пример #3
0
 public static MvcHtmlString ListItemWithImage(this HtmlHelper helper, BaseWithImages model, bool adminMode)
 {
     return(ListItemWithImage(helper, model, adminMode, null));
 }