Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/add ps number to note corrupted #419

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@

foreach (var row in data)
{
object?[] rowValues =

Check warning on line 149 in src/api/VoteMonitor.Api.DataExport/Handlers/GetExcelDbCommandHandler.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
row.ObserverId, row.ObserverPhone,
row.ObserverId,
row.ObserverPhone,
row.ObserverName,
row.PollingStation,
row.LastModified.ToString("s"),
Expand All @@ -158,6 +159,8 @@
row.NumberOfFemaleMembers,
row.MinPresentMembers,
row.ChairmanPresence,
row.SinglePollingStationOrCommission,
row.AdequatePollingStationSize,
};
dataTable.Rows.Add(rowValues);
}
Expand Down Expand Up @@ -219,7 +222,7 @@

foreach (var question in questions)
{
object?[] rowValues = new List<object?>

Check warning on line 225 in src/api/VoteMonitor.Api.DataExport/Handlers/GetExcelDbCommandHandler.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 225 in src/api/VoteMonitor.Api.DataExport/Handlers/GetExcelDbCommandHandler.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
question.FormCode,
question.FormSectionCode,
Expand Down Expand Up @@ -279,7 +282,7 @@

foreach (var note in notes)
{
object?[] rowValues = new List<object?>

Check warning on line 285 in src/api/VoteMonitor.Api.DataExport/Handlers/GetExcelDbCommandHandler.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
note.ObserverId,
note.ObserverPhone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ public record AddNoteToUnknownPollingStation : IRequest<int>
public int ObserverId { get; }
public string CountyCode { get; }
public string MunicipalityCode { get; }
public int PollingStationNumber { get; }
public int? QuestionId { get; }
public string Text { get; }
public UploadedFileModel[] Attachments { get; }

public AddNoteToUnknownPollingStation(int observerId, string countyCode, string municipalityCode, int? questionId, string text, UploadedFileModel[] attachments = null)
public AddNoteToUnknownPollingStation(int observerId, string countyCode, string municipalityCode, int pollingStationNumber, int? questionId, string text, UploadedFileModel[] attachments = null)
{
ObserverId = observerId;
CountyCode = countyCode;
MunicipalityCode = municipalityCode;
PollingStationNumber = pollingStationNumber;
QuestionId = questionId;
Text = text;
Attachments = attachments ?? Array.Empty<UploadedFileModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}
else
{
var command = new AddNoteToUnknownPollingStation(this.GetIdObserver(), note.CountyCode, note.MunicipalityCode, note.QuestionId, note.Text, attachments);
var command = new AddNoteToUnknownPollingStation(this.GetIdObserver(), note.CountyCode, note.MunicipalityCode, note.PollingStationNumber, note.QuestionId, note.Text, attachments);
var result = await _mediator.Send(command);
return ProcessUpload(result, note, command.Attachments.Select(x => x.Path).ToArray());
}
Expand Down Expand Up @@ -108,7 +108,7 @@
[HttpPost("upload")]
[Authorize("Observer")]
[Obsolete("Will be removed when ui will use multiple files upload")]
[Produces(type: typeof(UploadNoteResult))]

Check warning on line 111 in src/api/VoteMonitor.Api.Note/Controllers/NoteController.cs

View workflow job for this annotation

GitHub Actions / build

'UploadNoteResult' is obsolete: 'Will be removed when ui will use multiple files upload'
public async Task<IActionResult> UploadOld([FromForm] UploadNoteModel note)
{
// TODO[DH] use a pipeline instead of separate Send commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
IRequestHandler<NoteQuery, List<NoteModel>>,
IRequestHandler<AddNoteCommandV2, int>,
IRequestHandler<AddNoteToUnknownPollingStation, int>,
IRequestHandler<AddNoteCommand, int>

Check warning on line 15 in src/api/VoteMonitor.Api.Note/Handlers/NoteQueriesHandler.cs

View workflow job for this annotation

GitHub Actions / build

'AddNoteCommand' is obsolete: 'Will be removed when ui will use multiple files upload'
{

private readonly VoteMonitorContext _context;
Expand Down Expand Up @@ -43,7 +43,7 @@
{
Files = n.Attachments.Select(x => x.FileName).ToArray(),
Text = n.Text,
FormCode = (string?)n.Question.FormSection.Form.Code,

Check warning on line 46 in src/api/VoteMonitor.Api.Note/Handlers/NoteQueriesHandler.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
FormId = (int?)n.Question.FormSection.Form.Id,
QuestionId = (int?)n.Question.Id,
CountyCode = n.PollingStation.Municipality.County.Code,
Expand Down Expand Up @@ -84,7 +84,7 @@
return await _context.SaveChangesAsync(cancellationToken);
}

public async Task<int> Handle(AddNoteCommand request, CancellationToken cancellationToken)

Check warning on line 87 in src/api/VoteMonitor.Api.Note/Handlers/NoteQueriesHandler.cs

View workflow job for this annotation

GitHub Actions / build

'AddNoteCommand' is obsolete: 'Will be removed when ui will use multiple files upload'
{
var noteEntity = new Entities.Note
{
Expand Down Expand Up @@ -119,6 +119,7 @@
Text = request.Text,
CountyCode = request.CountyCode,
MunicipalityCode = request.MunicipalityCode,
PollingStationNumber = request.PollingStationNumber,
// A note can be added to a polling station as well.
// In that case IdQuestion is either null or 0
IdQuestion = request.QuestionId == 0 ? null : request.QuestionId,
Expand Down
2 changes: 1 addition & 1 deletion src/api/VoteMonitor.Entities/NoteCorrupted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public class NoteCorrupted : IIdentifiableEntity
public int IdObserver { get; set; }
public string CountyCode { get; set; }
public string MunicipalityCode { get; set; }
public int PollingStationNumber { get; set; }
public string Text { get; set; }

public virtual Question Question { get; set; }
public virtual Observer Observer { get; set; }
public virtual PollingStation PollingStation { get; set; }
public virtual ICollection<NotesAttachmentCorrupted> Attachments { get; set; }

}
1 change: 1 addition & 0 deletions src/api/VoteMonitor.Entities/VotingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.HasIndex(e => e.MunicipalityCode);

entity.Property(e => e.LastModified);
entity.Property(e => e.PollingStationNumber);

entity.HasOne(d => d.Question)
.WithMany(p => p.NotesCorrupted)
Expand Down
Loading
Loading