Exemplo n.º 1
0
        public override void GetUsers(Gallery gallery)
        {
            using (TransactionContext context = TransactionContextFactory.EnterContext(TransactionAffinity.Supported))
            {
                IDataSource dataSource = DataSourceFactory.GetDataSource("DbGalleryProvider");

                IDataCommand cmd = dataSource.GetCommand("GetUsers");

                cmd.Parameters["galleryId"].Value = gallery.ID;

                IDataReader reader = cmd.ExecuteReader();

                try
                {
                    while (reader.Read())
                        gallery.AddUser(reader["userId"].ToString());
                }
                finally
                {
                    if (!reader.IsClosed)
                        reader.Close();
                }
            }
        }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
        public override void GetUsers(Gallery gallery)
        {
            if (gallery == null)
                throw new ArgumentNullException("gallery");

            GalleryDataContext db = new GalleryDataContext(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString);

            Table<GalleryUser> users = db.GetTable<GalleryUser>();

            var query =
                from user in users
                where user.GalleryID == gallery.ID
                orderby user.UserID ascending
                select user;

            foreach (var row in query)
            {
                gallery.AddUser(row.UserID);
            }
        }