public MediaForm() { InitializeComponent(); Photo firstPhoto = new Photo("First Ph") { Mode = Mode.PhotoModes[3] }; Photo secondPhoto = new Photo("Second Ph"); this.PhotoRepository.Add(firstPhoto); this.PhotoRepository.Add(secondPhoto); //Video firstVideo = new Video("First Vid") { Mode = Mode.VideoModes[3] }; //Video secondVideo = new Video("Second Vid"); Gallery gallery = new Gallery("Main gallery"); Gallery secondGallery = new Gallery("Second gallery"); this.GalleryRepository.Add(gallery); this.GalleryRepository.Add(secondGallery); gallery.AddFile(firstPhoto); VideoRepository.MediaInfoObjects = new Video(false).Deserialize().ToList(); this.ComboBoxStaticPageMode.DataSource = Mode.AllModes; }
protected void Page_Load(object sender, EventArgs e) { Guid? id = null; if (!string.IsNullOrEmpty(Request.QueryString["guid"])) id = new Guid(Request.QueryString["guid"]); else if (ViewState["id"] != null) id = (Guid)ViewState["id"]; if (id.HasValue) { _gallery = Gallery.Load(id.Value); } if (!IsPostBack) { if (!id.HasValue) { _gallery = new Gallery(); _gallery.Title = "Nueva galería"; _gallery.Description = "Breve descripción de la galería"; _gallery.Content = "Contenido de la galería"; _gallery.Author = User.Identity.Name; UploadedFile file = UploadedFile.FromStream(File.OpenRead( Path.Combine(Server.MapPath(Request.ApplicationPath), "images/file.jpg"))); file.FileName = "File"; file.Description = "Imagen de prueba"; file.ContentType = "image/jpeg"; _gallery.AddFile(file); _gallery.AddUser(User.Identity.Name); _gallery.AcceptChanges(); ViewState["id"] = _gallery.ID; } BindGallery(_gallery); } }
public override Gallery SelectGallery(Guid id, bool includeComments, bool includeFiles) { Gallery gallery = null; GalleryDataContext db = new GalleryDataContext( ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); Table<LinqGallery> galleries = db.GetTable<LinqGallery>(); LinqGallery row = galleries.SingleOrDefault<LinqGallery>( g => g.ApplicationName == this.ApplicationName && g.ID == id); if (row == null) return null; gallery = new Gallery(row.ID) { ApplicationName = this.ApplicationName, Author = row.Author, Content = row.Content, DateCreated = row.DateCreated, Description = row.Description, IsVisible = row.IsVisible, Keywords = row.Keywords, LastUpdated = row.LastUpdated, LastUpdatedBy = row.LastUpdatedBy, Slug = row.Slug, Status = row.Status, Title = row.Title }; if (gallery == null) return null; if (includeComments) GetComments(gallery); if (includeFiles) { foreach (UploadedFile file in UploadStorageService.GetFiles(gallery.ID)) { gallery.AddFile(file); } } GetUsers(gallery); return gallery; }