public void ProcessUploadedPhoto(string[] photoIds)
        {
            foreach (var photoId in photoIds)
            {
                ObjectId objPhotoId;
                if (ObjectId.TryParse(photoId, out objPhotoId))
                {
                    var photo = GetPhoto(objPhotoId);
                    if (photo != null)
                    {
                        var ptManager = new PhotoTypeManager();
                        var origPhotoType = ptManager.GetBySystemName("orig");
                        var uploadPhotoType = ptManager.GetBySystemName("upload");

                        var uploadPath = string.Format("{0}/{1}/{2}", photo.BasePhotoVirtualPath,
                                                       uploadPhotoType.Directory,
                                                       photo.FileName);
                        var uploadPhysicalPath = HttpContext.Current.Server.MapPath(uploadPath);

                        var origPath = string.Format("{0}/{1}/{2}", photo.BasePhotoVirtualPath, origPhotoType.Directory,
                                                     photo.FileName);
                        var origPhysicalPath = HttpContext.Current.Server.MapPath(origPath);

                        try
                        {
                            MoveFile(uploadPhysicalPath, origPhysicalPath);
                        }
                        catch
                        {
                            throw;
                        }

                        RemovePhotoTypeFromPhoto(photo, uploadPhotoType);
                        AddPhotoTypeToPhoto(photo, origPhotoType);
                    }
                }
            }
        }
 public AdminController()
 {
     _galleryManager = new GalleryManager();
     _photoManager = new PhotoManager();
     _photoTypeManager = new PhotoTypeManager();
 }
        public List<OrigPhotosWaiting> GetWaitingPhotos(User user)
        {
            var retColl = new List<OrigPhotosWaiting>();
            var currentUserDir = user.UserNameSEO;
            var files = GetFilesInUploadDirectory(currentUserDir);
            if (files.Length > 0)
            {
                var typeManager = new PhotoTypeManager();
                var uploadTempType = typeManager.GetBySystemName("minithumb");
                var uploadType = typeManager.GetBySystemName("upload");

                for (int i = 0; i < files.Length; i++)
                {
                    var photoAlreadyInDb = GetPhotoByFileName(files[i].Name);

                    string fileName;
                    ObjectId id;
                    if (photoAlreadyInDb == null) //fotku sme jeste nezpracovavali
                    {
                        fileName = RenameToSystemFileName(files[i].FullName);
                        var fotka = new Photo { FileName = fileName, User = user, DateUploaded = files[i].CreationTime };

                        Save(fotka);
                        AddPhotoTypeToPhoto(fotka, uploadType);
                        try
                        {
                            ImageProcessingManager.ResizeImage(fotka, uploadType, uploadTempType);
                            AddPhotoTypeToPhoto(fotka, uploadTempType);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        id = fotka.Id;
                    }
                    else
                    {
                        fileName = photoAlreadyInDb.FileName;
                        id = photoAlreadyInDb.Id;
                    }

                    var photoWaiting = new OrigPhotosWaiting { FileName = fileName, UploadedDate = files[i].CreationTime, Id = id.ToString() };

                    //X,Y dimensions of originally uploaded photo - uncomment if you need to diplay it on ProcessUploadPhotos view.
                    /*
                    var origPath = HttpContext.Current.Server.MapPath(string.Format("/{0}/{1}/{2}/{3}", ConfigurationManager.AppSettings["GalleryRootDirVirtualPath"], currentUserDir, uploadType.Adresar, fileName));
                    var origDimensions = ImageProcessingManager.GetImageDimensions(origPath);
                    photoWaiting.X = origDimensions[0];
                    photoWaiting.Y = origDimensions[1];
                    */

                    photoWaiting.ThumbPath = string.Format("/{0}/{1}/{2}/{3}", ConfigurationManager.AppSettings["GalleryRootDirVirtualPath"], currentUserDir, uploadTempType.Directory, fileName);

                    retColl.Add(photoWaiting);
                }
            }
            return retColl;
        }