🐛 Trying to fix poll update
This commit is contained in:
		@@ -199,14 +199,13 @@ public class PollController(AppDatabase db, PollService polls, PublisherService
 | 
			
		||||
            if (request.Questions != null)
 | 
			
		||||
            {
 | 
			
		||||
                // Remove existing questions
 | 
			
		||||
                db.PollQuestions.RemoveRange(poll.Questions);
 | 
			
		||||
                poll.Questions.Clear();
 | 
			
		||||
                // Add new questions
 | 
			
		||||
                poll.Questions = request.Questions.Select(q => q.ToQuestion()).ToList();
 | 
			
		||||
                poll.Questions.AddRange(request.Questions.Select(q => q.ToQuestion()));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            polls.ValidatePoll(poll);
 | 
			
		||||
 | 
			
		||||
            poll.UpdatedAt = SystemClock.Instance.GetCurrentInstant();
 | 
			
		||||
            await db.SaveChangesAsync();
 | 
			
		||||
 | 
			
		||||
            // Commit the transaction if all operations succeed
 | 
			
		||||
@@ -271,4 +270,4 @@ public class PollController(AppDatabase db, PollService polls, PublisherService
 | 
			
		||||
            return StatusCode(500, "An error occurred while deleting the poll... " + ex.Message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user