public void CreateRootGallery(User owner, bool isTrashGallery) { string galleryName; string galleryDescription; if(isTrashGallery) { galleryName = "Trash"; galleryDescription = "Use for photos that does not belong to any gallery"; } else { galleryName = "Root gallery"; galleryDescription = "Root gallery for user, cannot be deleted."; } var gal = new Gallery { DateCreated = DateTime.Now, ParentId = ObjectId.Empty, OwnerId = owner.Id, Name = galleryName, Description = galleryDescription, Order = 1, IsTrashGallery = isTrashGallery }; Save(gal); }
public User RegisterNewUser(Register regModel) { var cryptedPassword = new Crypto().Encrypt(regModel.Password); var newUser = new User { Email = regModel.Email, PasswordCrypted = cryptedPassword, UserName = regModel.Name }; Save(newUser); return newUser; }
public Gallery ClearTrashGallery(User owner) { var trash = GetTrashGallery(owner); if(trash != null && trash.Photos != null && trash.Photos.Any()) { trash.Photos.Clear(); Save(trash); } return trash; }
public void Save(User user) { _users.Collection.Save(user); }
public void Delete(User user) { _users.Collection.Remove(Query.EQ("_id", user.Id)); }
public static bool IsPasswordOK(string password, User user) { var cryptedPassword = new Crypto().Encrypt(password); return cryptedPassword.Equals(user.PasswordCrypted); }
public bool IsTrashGalleryExistForUser(User owner) { return _galleries.Collection.AsQueryable().Any(g => g.OwnerId == owner.Id && g.IsTrashGallery); }
public Gallery GetTrashGallery(User owner) { return _galleries.Collection.AsQueryable().First(g => g.OwnerId == owner.Id && g.IsTrashGallery); }
public bool IsRootGalleryExistForUser(User owner) { return _galleries.Collection.AsQueryable().Any(g => g.OwnerId == owner.Id && g.ParentId == ObjectId.Empty); }
public Gallery GetRootGallery(User owner) { return _galleries.Collection.AsQueryable().First(g => g.OwnerId == owner.Id && !g.IsTrashGallery && g.ParentId == ObjectId.Empty); }
public List<Gallery> GetGalerieForUser(User owner) { return _galleries.Collection.Find(Query.EQ("OwnerId", owner.Id)).ToList(); }
private void LoginUser(User user) { FormsAuthentication.SetAuthCookie(user.Id.ToString(), true); }
public void MovePhotoSiblingsToTrash(User owner) { var photos = _photos.Collection.FindAll(); if(photos != null && photos.Any()) { var galleryManager = new GalleryManager(); var trashGallery = galleryManager.GetTrashGallery(owner); var siblings = (from photo in photos where !galleryManager.IsPhotoInGallery(photo.Id) select photo.Id.ToString()).ToList(); if (siblings.Count > 0) { galleryManager.AddPhotosToGallery(trashGallery.Id.ToString(), siblings.ToArray()); } } }
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; }