Пример #1
0
        public static bool AddUser(User u)
        {
            User users = GetUserByEmail(u.UserEmail);

            if (users != null)
            {
                throw new Exception("Email is already in use!");
            }

            string sql = string.Format("insert into users (user_name, user_password, user_email, user_birthday, user_album_count, is_admin) values('{0}', '{1}', '{2}', #{3}#, {4} ,{5})", u.UserName, u.UserPassword, u.UserEmail, u.UserBirthday, u.UserAlbumCount, u.IsAdmin);

            return(DBF.ChangeTable(sql) == 1);
        }
Пример #2
0
        public static bool AddImage(Img i)
        {
            // Get all images with the same name and check if their album is identical.
            List <Img> images_to_check = GetImagesByName(i.ImageName);

            if (images_to_check != null)
            {
                foreach (Img img in images_to_check)
                {
                    if (img.ImageAlbumId == i.ImageAlbumId)
                    {
                        // Code will stop if it reaces this becuase we throw exception.
                        throw new Exception("An Image with the same name already exists in this album!");
                    }
                }
            }
            string sql = string.Format("insert into images (image_album_id, image_owner_id, image_name, image_creation_time, image_file_path) values({0}, {1}, '{2}', #{3}#, '{4}')", i.ImageAlbumId, i.ImageOwnerId, i.ImageName, i.ImageCreationTime, i.ImageFilePath);

            return(DBF.ChangeTable(sql) == 1);
        }
Пример #3
0
        public static bool AddAlbum(Album a)
        {
            // Get all albums with the same name and check if their owner is identical.
            List <Album> albums_to_check = GetAlbumsByName(a.AlbumName);

            if (albums_to_check != null)
            {
                foreach (Album al in albums_to_check)
                {
                    if (al.AlbumOwnerId == a.AlbumOwnerId)
                    {
                        // Code will stop if it reaces this becuase we throw exception.
                        throw new Exception("An Album with the same name already belongs to this user!");
                    }
                }
            }

            string sql = string.Format("insert into albums (album_owner_id, album_name, album_creation_time, album_size) values({0}, '{1}', #{2}#, {3})", a.AlbumOwnerId, a.AlbumName, a.AlbumCreationTime, a.AlbumSize);

            return(DBF.ChangeTable(sql) == 1);
        }