protected void changeAlbumNameBtn_Click(object sender, EventArgs e) { this.errorLabel.Visible = false; GigaGalleryWS ws = new GigaGalleryWS(); UserValidationWS validationWS = new UserValidationWS(); string newName = this.newAlbumName.Text.Trim(); if (Session["selectedAlbumId"] == null) { // No album was selected. this.errorLabel.Text = "No album was selected! Please select an album!"; this.errorLabel.Visible = true; return; } if (validationWS.isAlbumNameValid(newName)) { Album albmObj = ws.GetAlbumById((int)Session["selectedAlbumId"]); albmObj.AlbumName = newName; // Annoying but only works like this. bool res = false; try { res = ws.UpdateAlbum(albmObj.AlbumId, albmObj.AlbumOwnerId, albmObj.AlbumName, albmObj.AlbumCreationTime, albmObj.AlbumSize); } catch { this.errorLabel.Text = "Invalid Action!"; this.errorLabel.Visible = true; this.imagesGridView.DataBind(); this.imagesGridView.SelectedIndex = -1; return; } if (res) { this.updateDropDownParams(sender, e); this.imagesGridView.DataBind(); Session["selectedAlbumId"] = null; } else { this.errorLabel.Text = "Could not update album, try again later!"; this.errorLabel.Visible = true; } this.imagesGridView.SelectedIndex = -1; } else { this.errorLabel.Text = validationWS.albumNameLengthInvalidMessage(); this.errorLabel.Visible = true; this.imagesGridView.SelectedIndex = -1; this.imagesGridView.DataBind(); return; } }
protected void createAlbumBtn_Click(object sender, EventArgs e) { this.errorLabel.Visible = false; GigaGalleryWS ws = new GigaGalleryWS(); UserValidationWS validationWS = new UserValidationWS(); string newName = this.newAlbumName.Text.Trim(); if (validationWS.isAlbumNameValid(newName)) { bool res = false; try { res = ws.AddAlbum((int)Session["pUserId"], newName); } catch { this.errorLabel.Text = "Invalid Action!"; this.errorLabel.Visible = true; this.imagesGridView.DataBind(); this.imagesGridView.SelectedIndex = -1; return; } if (res) { this.updateDropDownParams(sender, e); this.imagesGridView.DataBind(); this.imagesGridView.SelectedIndex = -1; } else { this.errorLabel.Text = "Could not create new album, try again later!"; this.errorLabel.Visible = true; this.imagesGridView.DataBind(); this.imagesGridView.SelectedIndex = -1; } } else { this.errorLabel.Text = validationWS.albumNameLengthInvalidMessage(); this.errorLabel.Visible = true; this.imagesGridView.SelectedIndex = -1; this.imagesGridView.DataBind(); return; } }