Esempio n. 1
0
        private static PhotoAlbum[] Fetch(int? id, string username, string name, eAccess? access)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn,
                                                               "FetchPhotoAlbums",
                                                               id, username, name, access);

                List<PhotoAlbum> photoAlbums = new List<PhotoAlbum>();

                while (reader.Read())
                {
                    PhotoAlbum photoAlbum = new PhotoAlbum();

                    photoAlbum.id = (int)reader["ID"];
                    photoAlbum.username = (string) reader["Username"];
                    photoAlbum.name = (string) reader["Name"];
                    photoAlbum.access = (eAccess) reader["Access"];
                    photoAlbum.coverPhotoID = reader["CoverPhotoID"] != DBNull.Value ? (int?) reader["CoverPhotoID"] : null;

                    photoAlbums.Add(photoAlbum);
                }

                return photoAlbums.ToArray();
            }
        }
Esempio n. 2
0
        protected void btnCreateEditPhotoAlbum_Click(object sender, EventArgs e)
        {
            string photoAlbumName = txtPhotoAlbumName.Text.Trim();
            if (photoAlbumName.Length == 0)
            {
                lblError.Text = "Please specify album name!".Translate();
                return;
            }

            PhotoAlbum photoAlbum = null;
            if (!EditedPhotoAlbumID.HasValue)
                photoAlbum = new PhotoAlbum(CurrentUserSession.Username)
                {
                    Name = photoAlbumName,
                    Access = (PhotoAlbum.eAccess)Convert.ToInt32(ddPhotoAlbumAccess.SelectedValue)
                };
            else
            {
                photoAlbum = PhotoAlbum.Fetch(EditedPhotoAlbumID.Value);
                photoAlbum.Name = photoAlbumName;
                photoAlbum.Access = (PhotoAlbum.eAccess)Convert.ToInt32(ddPhotoAlbumAccess.SelectedValue);
            }

            photoAlbum.Save();
            populateDDPhotoAlbums();
            ddPhotoAlbums.SelectedValue = photoAlbum.ID.ToString();
            pnlManagePhotos.Visible = true;
            loadPhotos = true;
            EditedPhotoAlbumID = null;
        }