public ActionResult AsyncShowSingle()
 {
     var pictureViewModel = new PictureViewModel();
     return View(pictureViewModel);
 }
        public ActionResult Remove(string[] fileNames)
        {
            var pictureViewModel = new PictureViewModel();

            // The parameter of the Remove action must be called "fileNames"

            if (fileNames != null)
            {
                foreach (var fullName in fileNames)
                {
                    var fileName = Path.GetFileName(fullName);
                    var physicalPath = Path.Combine(Server.MapPath("~/Images"), fileName);

                    // TODO: Verify user permissions

                    if (System.IO.File.Exists(physicalPath))
                    {
                        // The files are not actually removed in this demo
                        System.IO.File.Delete(physicalPath);

                        string pictureUrl = @"../../Content/Images/App/loading.gif";

                        pictureViewModel.PictureId = 1;
                        pictureViewModel.PictureName = fileName;
                        pictureViewModel.PictureUrl = pictureUrl;
                        pictureViewModel.Status = false;
                    }
                }
            }

            // Return an empty string to signify success
            //return Content("");
            //return Content(Boolean.TrueString);
            //return Json(Boolean.TrueString, JsonRequestBehavior.AllowGet);
            //return Json(Boolean.TrueString, "text/plain");
            //return Json(pictureViewModel, "text/plain"); //ok
            return Json(pictureViewModel, JsonRequestBehavior.AllowGet); //ok
        }
        public ActionResult Save(IEnumerable<HttpPostedFileBase> files)
        {
            var pictureViewModel = new PictureViewModel();
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    // Some browsers send file names with full path.
                    // We are only interested in the file name.
                    var fileName = Path.GetFileName(file.FileName);
                    var physicalPath = Path.Combine(Server.MapPath("~/Images"), fileName);

                    // The files are not actually saved in this demo
                    file.SaveAs(physicalPath);

                    string pictureUrl = @"../../Images/" + fileName;

                    pictureViewModel.PictureId = 1;
                    pictureViewModel.PictureName = fileName;
                    pictureViewModel.PictureUrl = pictureUrl;
                    pictureViewModel.Status = true;
                }
            }

            // Return an empty string to signify success
            //return Content("");
            //return Content(Boolean.TrueString);
            //return Json(Boolean.TrueString, JsonRequestBehavior.AllowGet);
            //return Json(Boolean.TrueString, "text/plain");
            //return Json(pictureViewModel, "text/plain"); //ok
            return Json(pictureViewModel, JsonRequestBehavior.AllowGet); //ok
        }
 public ActionResult OtherFile()
 {
     var pictureViewModel = new PictureViewModel();
     return View(pictureViewModel);
 }