public static void RegisterNewUser(Register regModel) { var cryptedPassword = new Crypto().Encrypt(regModel.Password); var newUser = new User {Email = regModel.Email, PasswordCrypted = cryptedPassword, UserName = regModel.Name}; Save(newUser); GalerieManager.CreateRootGallery(newUser); }
public static void CreateRootGallery(User owner) { var gal = new Galerie { DatumVytvoreni = DateTime.Now, ParentId = null, OwnerId = owner.Id, Nazev = "Kořenová galerie", Popis = "Kořenová galerie, nelze smazat.", Poradi = 1 }; Save(gal); }
public static List<OrigPhotosWaiting> GetWaitingPhotos(User user) { var retColl = new List<OrigPhotosWaiting>(); var currentUserDir = user.UserNameSEO; var files = GetFilesInUploadDirectory(currentUserDir); if(files.Length > 0) { var uploadTempType = GetBySystemName("minithumb"); var uploadType = GetBySystemName("upload"); for(int i=0; i<files.Length; i++) { var photoAlreadyInDb = GetFotkaByFileName(files[i].Name); string fileName; string id; if(photoAlreadyInDb == null) //fotku sme jeste nezpracovavali { fileName = RenameToSystemFileName(files[i].FullName); var fotka = new Fotka {NazevSouboru = fileName, User = user, DatumUploadu = 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.NazevSouboru; id = photoAlreadyInDb.Id; } var photoWaiting = new OrigPhotosWaiting { FileName = fileName, UploadedDate = files[i].CreationTime, Id = id}; //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["GalerieRootDirVirtualPath"], 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["GalerieRootDirVirtualPath"], currentUserDir, uploadTempType.Adresar, fileName); retColl.Add(photoWaiting); } } return retColl; }
public static void Save(User user) { DbContext.Current.Add(user); }
public static bool IsPasswordOK(string password, User user) { var cryptedPassword = new Crypto().Encrypt(password); return cryptedPassword.Equals(user.PasswordCrypted); }
public static void Delete(User user) { DbContext.Current.Delete<User>(d => d.Id == user.Id); }
public static bool IsRootGalleryExistForUser(User owner) { return DbContext.Current.All<Galerie>().Any(d => d.OwnerId == owner.Id && d.ParentId == null); }