예제 #1
0
        public int AddPhoto(RecommendationPhoto newPhoto)
        {
            using var db = new SqlConnection(_connectionString);

            var sql = $@"INSERT INTO [dbo].[Recommendation_Photos]
                               ([RecId]
                               ,[PhotoUrl])
                        Output inserted.PhotoId
                         VALUES
                               (@recId
                               ,@photoUrl)";

            var newId = db.ExecuteScalar <int>(sql, newPhoto);

            newPhoto.PhotoId = newId;
            return(newId);
        }
예제 #2
0
        public IActionResult AddRecPhoto(RecommendationPhoto newPhoto)
        {
            _repo.AddPhoto(newPhoto);

            return(Created($"api/rec-photos/{newPhoto.PhotoId}", newPhoto));
        }