protected void btnSaveChanges_Click(object sender, EventArgs e) { lblError.Text = ""; if (String.IsNullOrEmpty(txtName.Text)) { lblError.Text = "Please give the album a name"; mpeError.Show(); return; } if (!(txtName.Text == SelectedPublicAlbum.Name)) { if (DbObjects.Business.PublicAlbum.PublicAlbumNameExists(txtName.Text)) { lblError.Text = "There is already another album with that name"; mpeError.Show(); return; } } DbObjects.Business.PublicAlbum album = SelectedPublicAlbum; album.Name = txtName.Text; album.Description = txtDescription.Text; album.Save(); Int16 thumbnailId = album.Thumbnail.Id; for (int i = 0; i < rptImages.Items.Count; i++) { RadioButton rdoThumbnail = (RadioButton)rptImages.Items[i].FindControl("rdoThumbnail"); Int16 imageId = Convert.ToInt16(rdoThumbnail.Attributes["publicImageId"]); if (rdoThumbnail.Checked) { thumbnailId = imageId; } TextBox txtCaption = (TextBox)rptImages.Items[i].FindControl("txtCaption"); DbObjects.Business.PublicImage image = album.GetPublicImageById(imageId); if (image.Caption != txtCaption.Text) { album.ChangeImageCaption(imageId, txtCaption.Text); } } if (album.Thumbnail.Id != thumbnailId) { album.SetThumbnailImage(thumbnailId); } BindAlbum(); }
private void DeletePublicImage(DbObjects.Business.PublicImage image) { string absolutePath = Server.MapPath(image.ImageUrl); //delete physical image file if (File.Exists(absolutePath)) { File.Delete(absolutePath); } //remove image from database SelectedPublicAlbum.RemoveImage(image.Id); }