예제 #1
0
        public TrailImagesModel GetTrailImagesById(int id)
        {
            TrailImagesModel trailImage = new TrailImagesModel();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT * FROM trail_images WHERE trail_images.trail_image_id = @id;", conn);
                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        trailImage = MapRowToTrailImages(reader);
                    }
                    else
                    {
                        trailImage = null;
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }

            return(trailImage);
        }
예제 #2
0
        public List <TrailImagesModel> GetTrailImagesByTrailId(int trailId)
        {
            List <TrailImagesModel> trailImages = new List <TrailImagesModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT * FROM trail_images WHERE trail_images.trail_id = @trailId;", conn);
                    cmd.Parameters.AddWithValue("@trailId", trailId);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TrailImagesModel trailImage = MapRowToTrailImages(reader);

                        trailImages.Add(trailImage);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(trailImages);
        }
예제 #3
0
        public List <TrailImagesModel> GetAllTrailImages()
        {
            List <TrailImagesModel> trailImages = new List <TrailImagesModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand    cmd    = new SqlCommand(@"SELECT * FROM trail_images", conn);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TrailImagesModel trailImage = MapRowToTrailImages(reader);
                        trailImages.Add(trailImage);
                    }

                    return(trailImages);
                }
            }
            catch (SqlException)
            {
                throw;
            }
        }
예제 #4
0
        public static int InsertFakeTrailImage(TrailImagesModel trailImage, int trailId)
        {
            int trailImageId = -1;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO trail_images " +
                                                "(trail_id, trail_image_address, local) " +
                                                "VALUES (@trailId, @imageAddress, @bit)", conn);
                cmd.Parameters.AddWithValue("@trailId", trailId);
                cmd.Parameters.AddWithValue("@imageAddress", trailImage.ImageAddress);
                cmd.Parameters.AddWithValue("@bit", trailImage.Bit);


                cmd.ExecuteNonQuery();

                return(trailImageId);
            }
        }
예제 #5
0
        public void Initialize()
        {
            park = new ParkModel()
            {
                Name        = "testPark",
                Description = "testDescription",
                Latitude    = 41,
                Longitude   = 100,
                Zoom        = 200
            };

            trail = new TrailModel()
            {
                Name        = "testTrail",
                Description = "testTrailDescription"
            };

            trailImage = new TrailImagesModel()
            {
                Bit          = true,
                ImageAddress = "address"
            };
        }