Ejemplo n.º 1
0
        public void AddFollowedArtist(FollowedArtist followedArtistToAdd)
        {
            using var db = new SqlConnection(_connectionString);

            var sql = @"INSERT INTO [dbo].[FollowedArtist]
                                ([BeingFollowedId]
                                ,[FollowerId])
                            OUTPUT inserted.FollowedArtistId
                        VALUES
                                (@BeingFollowedId, @FollowerId)";

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

            followedArtistToAdd.FollowedArtistId = newId;
        }
Ejemplo n.º 2
0
        public FollowedArtist Update(int followedArtistId, FollowedArtist faToUpdate)
        {
            var sql = @"UPDATE [dbo].[FollowedArtist]
                            SET [BeingFollowedId] = @BeingFollowed
                                ,[FollowerId] = @Follower
                            OUTPUT inserted.*
                            WHERE FollowedArtistId = @FollowedArtistId";

            using var db = new SqlConnection(_connectionString);

            var parameters = new
            {
                faToUpdate.BeingFollowedId,
                faToUpdate.FollowerId,
                followedArtistId
            };

            var updatedFA = db.QueryFirstOrDefault <FollowedArtist>(sql, parameters);

            return(updatedFA);
        }
        public IActionResult UpdateFollowedArtist(int followedArtistId, FollowedArtist followedArtistToUpdate)
        {
            var updatedFA = _repo.Update(followedArtistId, followedArtistToUpdate);

            return(Ok(updatedFA));
        }
 public IActionResult AddNewFA(FollowedArtist followedArtistToAdd)
 {
     _repo.AddFollowedArtist(followedArtistToAdd);
     return(Created($"/ api / followedartist /{ followedArtistToAdd.FollowedArtistId }", followedArtistToAdd));
 }