예제 #1
0
        /// <summary>
        ///     Returns all photos of a specified user
        /// </summary>
        /// <param name="user">id of the user to search for</param>
        /// <returns>
        ///     empty list if user does not have any photos or doesn't exist, else returns a List
        ///     of UserPhoto of all photos of specified user
        /// </returns>
        public static List <UserPhoto> GetPhotosByUser(int user)
        {
            var list = new List <UserPhoto>();
            var tb   = DbPhotos.GetPhotosOfUser(user);

            foreach (DataRow r in tb.Rows)
            {
                list.Add(new UserPhoto(r));
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// creates a userPhoto from database by id
        /// </summary>
        /// <param name="id">id of user photo</param>
        public UserPhoto(int id)
        {
            Id = id;
            var dr = DbPhotos.GetPhoto(id, PhotoType.GamePhotos);

            if (dr == null)
            {
                throw new ArgumentException("no photo with that id");
            }

            UserId    = (int)dr["User"];
            Image     = (string)dr["Photo"];
            Timestamp = (DateTime)dr["Timestamp"];
        }
예제 #3
0
 /// <summary>
 /// inserts a photo for a user
 /// </summary>
 /// <param name="user">id of user</param>
 /// <param name="filename">name of file</param>
 /// <returns>id of photo</returns>
 public static int InsertPhoto(int user, string filename)
 {
     return(DbPhotos.InsertPhoto(user, filename, PhotoType.UserPhotos));
 }