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); }
public IActionResult AddRecPhoto(RecommendationPhoto newPhoto) { _repo.AddPhoto(newPhoto); return(Created($"api/rec-photos/{newPhoto.PhotoId}", newPhoto)); }