public JsonResult UploadDropZone(int?idAlbum)
        {
            string urlImage = "";

            try
            {
                if (idAlbum != null && idAlbum.GetValueOrDefault() > 0)
                {
                    var ctrlUI = new PictureUserDAL();
                    foreach (string fileName in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[fileName];

                        if (file != null && file.ContentLength > 0)
                        {
                            var strDateTime = DateTime.Now.ToString("dd-MM-yyyy");
                            var fName       = idAlbum + "_" + Guid.NewGuid() + Path.GetExtension(file.FileName);
                            urlImage = string.Format("/UserImages/{0}/{1}/{2}/{3}/{4}", SysBaseInfor.GetCurrentUnitId(), SysBaseInfor.GetCurrentUserId(), SysBaseDirectory.pictureUploaded, strDateTime, fName);
                            var userPath = string.Format("{0}{1}/", userPictureUploadedPath, strDateTime);
                            if (!Directory.Exists(userPath))
                            {
                                Directory.CreateDirectory(userPath);
                            }
                            string path = Path.Combine(userPath, fName);
                            file.SaveAs(path);

                            var pictureSave = new PictureUser();
                            pictureSave.IdAlbum     = idAlbum.GetValueOrDefault();
                            pictureSave.IdUnit      = SysBaseInfor.GetCurrentUnitId().ToInt32();
                            pictureSave.CreatedBy   = SysBaseInfor.GetCurrentUserId();
                            pictureSave.CreatedAt   = DateTime.Now;
                            pictureSave.PictureUrl  = urlImage;
                            pictureSave.PictureName = fName;
                            ctrlUI.CreateItem(pictureSave);
                        }
                    }
                    return(Json(new { urlImage = urlImage }));
                }
                else
                {
                    return(Json("Có lỗi khi tải lên"));
                }
            }
            catch (Exception ex)
            {
                return(Json("Có lỗi khi tải lên"));
            }
        }
 public PartialViewResult TabDefaultGalleryView(string dirSelect)
 {
     if (!string.IsNullOrEmpty(dirSelect))
     {
         int idAlbum = 0;
         if (int.TryParse(dirSelect, out idAlbum))
         {
             var ctrlUI = new PictureUserDAL();
             var lstImg = ctrlUI.GetLstByUnitAndUser(SysBaseInfor.GetCurrentUnitId().ToInt32(), SysBaseInfor.GetCurrentUserId(), idAlbum).Select(item => new GalereyaImage
             {
                 lowsrc      = item.PictureUrl,
                 fullsrc     = item.PictureUrl,
                 description = "Ngày tải: " + item.CreatedAt.ToString("dd/MM/yyyy"),
                 category    = item.IdAlbum.ToString()
             }).ToArray();
             ViewBag.lstImgTabDefault = lstImg;
             ViewBag.dirSelect        = dirSelect;
             return(PartialView("~/Views/PictureManage/_PictureDefaultGallery.cshtml"));
         }
         else
         {
             var           uriImage   = string.Format("/UserImages/{0}/{1}/{2}/", SysBaseInfor.GetCurrentUnitId(), SysBaseInfor.GetCurrentUserId(), dirSelect);
             DirectoryInfo currentDir = new DirectoryInfo(userPicturePath + "/" + dirSelect + "/");
             var           lstImg     = currentDir.GetFiles().OrderBy(fi => fi.CreationTime).Select(fi => new GalereyaImage
             {
                 lowsrc      = Url.Content(uriImage + Path.GetFileName(fi.Name)),
                 fullsrc     = Url.Content(uriImage + Path.GetFileName(fi.Name)),
                 description = "Ngày tải: " + fi.CreationTime.ToString("dd/MM/yyyy"),
                 category    = dirSelect
             }).ToArray();
             ViewBag.lstImgTabDefault = lstImg;
             ViewBag.dirSelect        = dirSelect;
             return(PartialView("~/Views/PictureManage/_PictureDefaultGallery.cshtml"));
         }
     }
     else
     {
         return(PartialView("~/Views/Shared/_blank.cshtml"));
     }
 }