public ActionResult Create(Guid id, GalleryItemModel data)
        {
            try {
                Gallery gallery = new Gallery(id);
                if (Request.Files["PhotoPath"].HasFile())
                {
                    string baseDirectory = Server.MapPath("/assets/images/gallery/");
                    if (!Directory.Exists(baseDirectory))
                    {
                        Directory.CreateDirectory(baseDirectory);
                    }
                    baseDirectory += id.ToString() + "/";
                    if (!Directory.Exists(baseDirectory))
                    {
                        Directory.CreateDirectory(baseDirectory);
                    }

                    string FileName = tksUtil.MakeValidFileName(Request.Files["PhotoPath"].FileName).ToLower();

                    // Save image file to the retrieved directory
                    Request.Files["PhotoPath"].SaveAs(Path.Combine(baseDirectory, FileName));
                    data.PhotoPath = FileName;
                    data.ModuleID  = id;
                    data.SortOrder = -1;
                }

                int galleryID = gallery.Add(data);

                return(RedirectToAction("Index", new { id = data.ModuleID }));
            } catch {
                return(View(data));
            }
        }
        public JsonResult UploadBulk(Guid id)
        {
            GalleryItemModel data = new GalleryItemModel();

            data.ModuleID = id;

            try {
                if (Request.Files["PhotoPath"].HasFile())
                {
                    Gallery gallery = new Gallery(id);

                    string baseDirectory = Server.MapPath("/assets/images/gallery/");
                    if (!Directory.Exists(baseDirectory))
                    {
                        Directory.CreateDirectory(baseDirectory);
                    }
                    baseDirectory += id.ToString() + "/";
                    if (!Directory.Exists(baseDirectory))
                    {
                        Directory.CreateDirectory(baseDirectory);
                    }

                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        HttpPostedFileBase file = Request.Files[i];
                        if (file.ContentLength > 0)
                        {
                            string FileName = tksUtil.MakeValidFileName(Request.Files["PhotoPath"].FileName).ToLower();

                            // Save image file to the retrieved directory
                            Request.Files["PhotoPath"].SaveAs(Path.Combine(baseDirectory, FileName));
                            data.PhotoPath = FileName;
                            data.SortOrder = -1;

                            int galleryID = gallery.Add(data);
                        }
                    }
                }

                return(Json(true));
            } catch {
                return(Json(false));
            }

            //Gallery gallery = new Gallery(id);

            //string fileName1 = "";
            //string FullName1 = "";
            ////HttpFileCollection uploads = Request.Files;
            ////for (int fileCount = 0; fileCount < uploads.Count; fileCount++)
            //foreach (var file in Request.Files) {
            //	fileName1 = file.FileName;
            //}
            ////for (int fileCount = 1; fileCount < 6; fileCount++) {
            ////	if (fileCount < uploads.Count) {
            ////		HttpPostedFile uploadedFile = uploads[fileCount];
            ////		fileName1 = Path.GetFileName(uploadedFile.FileName);
            ////		if (uploadedFile.ContentLength > 0) {
            ////			string[] a = new string[1];
            ////			a = uploadedFile.FileName.Split('.');
            ////			fileName1 = a.GetValue(0).ToString() +
            ////			"." + a.GetValue(1).ToString();
            ////			uploadedFile.SaveAs(Server.MapPath
            ////			("mobile_image/mob_img/" + fileName1));
            ////		}
            ////	}
            ////}
            //return View();
        }