Website to store photos - Photos.Com

This website allows users to create web albums and upload photos into albums. It was developed using ASP.NET 3.5 and SQL Server 2005 express edition as the back-end. Code is written in C#.

This application uses ASP.NET pages for presentation. ObjectDataSource is used to get data from Data Access Layer (DAL) and bind data to ListView.  It uses membership for membership related operations such as registration, login etc.

The following are major activities in this application.

Technologies and Products Used

Steps to download, deploy and run this project

The following are the steps to related to be taken to run the existing part of the application. This project makes use of membership feature of ASP.NET. So,we have to configure the website using ASP.NET Configuration tool as explained below.
  1. Download photos.zip and unzip it into any directory in your system. For example, if you extract to c:\ then it will create a directory c:\photos. The download contains all ASP.NET pages but it has NO DATABASE. We have to create database objects using ASP.NET configuration tool manually.
  2. Open Visual Studio.NET 2008 or Visual Web Developer 2008.
  3. Open the project from the directory into which you extracted project.For example, c:\photos
  4. Select Website->ASP.NET Configuration option
  5. Select Security tab
  6. Select Use the security Setup Wizard to configure security step by step.
  7. Select From Internet option in Step 2
  8. Click on Next button in the remaining screens and finally click on Finish.
  9. It create a database called ASPNETDB.MDF with required tables and other database components
  10. Open the database in Server explorer or Database Explorer and create tables - ALBUMS and PHOTOS. The structure is shown in the picture below. ASPNET_USERS table is already created by ASP.NET. The rest of the tables are to be created.

    AID in ALBUMS table and PHOTOID in PHOTOS table are identity columns.

    Following diagram shows the tables used in the application. ASPNET_USERS is a table created by membership of ASP.NET. You have to create ALBUMS and PHOTOS.

    Before you create these tables, create a unique index on USERNAME column of ASPNET_USERS table so that it can be used as parent key from ALBUMS table.

  11. Create the following stored procedure in the database.
    
    
    CREATE PROCEDURE dbo.CreateAlbum
    (
     @username nvarchar(256),
     @title varchar(256), @description varchar(1000)	
    )
    AS
       insert into albums (username,title,description,createdon)
          values(@username,@title,@description, getdate())
    
    
    CREATE PROCEDURE dbo.Get_Album_Details
    (
    @aid int
    )
    AS
     select a.aid,a.title,a.description,createdon, 
           count(photoid) nophotos, 
           isnull(min(photoid),0) firstphoto
     from  albums a left outer join   photos p
     on  a.aid = p.aid  
     where  @aid = a.aid
     group by a.aid,a.title,a.description, a.createdon
     
    
    CREATE PROCEDURE dbo.GetAlbums 
    (
    @username nvarchar(256)
    )
    AS
     select a.aid,a.title,a.description, 
            count(photoid) nophotos, 
            isnull(min(photoid),0) firstphoto
     from  albums a left outer join   photos p
     on  a.aid = p.aid
     where  @username = a.username
     group by a.aid,a.title,a.description
    
    
    
    CREATE Procedure AddPhoto 
    (
    @aid int,
    @filename varchar(100), 
    @title varchar(200), 
    @tags varchar(100),
    @photoid int output
    ) 
    AS
      insert into photos values(@filename,@title,@tags,getdate(),@aid);
      select @photoid =  @@identity;
      
    
    CREATE PROCEDURE dbo.DeleteAlbum
    (
     @aid int
    )
    AS
       begin tran
       
       delete from photos where aid = @aid;
       
       if @@error <> 0 
         begin
            rollback transaction
            raiserror('Could not delete photos from album',15,1);
            return;
         end;
    
       
       delete from albums where aid = @aid;
       
       if @@error <> 0 
         begin
            rollback transaction
            raiserror('Could not delete album',15,1);
            return;
         end;
      
     
       commit transaction;
       
       
     
    CREATE PROCEDURE dbo.Get_Photo_Details
    (
    @photoid int
    )
    AS
      select  title,tags,addedon from photos
      where photoid = @photoid;
      
    
    
    
    CREATE PROCEDURE dbo.GetPhotoIds
    (
    @aid int
    )
    AS
      select photoid from photos where aid = @aid;
    
    
    CREATE PROCEDURE dbo.GetPhotosFromAlbum
    (
    @aid int
    )
    AS
      select  photoid, title, tags, addedon 
      from  photos
      where aid = @aid
      order by photoid
    
    
    CREATE PROCEDURE dbo.SearchForPhotos
    (
    @pattern varchar(100)
    )
    AS
      select * from photos
      where  title like '%' + @pattern + '%' or tags like '%' + @pattern + '%'
      order by aid desc, photoid desc
    
    
  12. Goto Solution Explorer and make login.aspx the startup page.
  13. Run project from Visual Studio.NET 2008 or Visual Web Developer 2008.
  14. You should see login.aspx page.