예제 #1
0
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
        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;
        }
예제 #4
0
 public static void Save(User user)
 {
     DbContext.Current.Add(user);
 }
예제 #5
0
 public static bool IsPasswordOK(string password, User user)
 {
     var cryptedPassword = new Crypto().Encrypt(password);
     return cryptedPassword.Equals(user.PasswordCrypted);
 }
예제 #6
0
 public static void Delete(User user)
 {
     DbContext.Current.Delete<User>(d => d.Id == user.Id);
 }
예제 #7
0
 public static bool IsRootGalleryExistForUser(User owner)
 {
     return DbContext.Current.All<Galerie>().Any(d => d.OwnerId == owner.Id && d.ParentId == null);
 }