Skip to content

Commit

Permalink
Merge pull request #154 from careerfairsystems/TicketFix
Browse files Browse the repository at this point in the history
added a way to custom ticket mails
  • Loading branch information
AlexanderHansson4225 authored Oct 30, 2023
2 parents 1ae8931 + c15d832 commit 80189b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
6 changes: 4 additions & 2 deletions Nexpo/Controllers/Events/TicketsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public async Task<ActionResult> SendManyTicketsToMailAsync(SendTicketViaMailDTO

int userID = user?.Id ?? -1;

string appearAt = DTO.appearAt ?? string.Empty;

var _event = await _eventRepo.Get(eventId);
if (_event == null)
{
Expand All @@ -358,7 +360,7 @@ public async Task<ActionResult> SendManyTicketsToMailAsync(SendTicketViaMailDTO

await _ticketRepo.Add(ticket);

_ = _emailService.SendTicketAsQRViaEmail(DTO.mail, ticket.Code, _event);
_ = _emailService.SendTicketAsQRViaEmail(DTO.mail, ticket.Code, _event, appearAt);
return Ok();

}
Expand All @@ -379,7 +381,7 @@ public async Task<ActionResult> SendManyTicketsToMailAsync(SendTicketViaMailDTO
tickets.Add(ticket);

}
_ = _emailService.SendTicketAsQRViaEmail(DTO.mail, tickets, _event);
_ = _emailService.SendTicketAsQRViaEmail(DTO.mail, tickets, _event, appearAt);

return Ok();
}
Expand Down
2 changes: 2 additions & 0 deletions Nexpo/DTO/Events/SendTicketViaMailDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public class SendTicketViaMailDTO
[Required]
public int numberOfTickets { get; set; }

public string appearAt { get; set; }

}
}
36 changes: 26 additions & 10 deletions Nexpo/Services/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public Task SendPasswordResetEmail(User user)
return SendEmail(user.Email, "Reset your password", content, content);
}

public Task SendTicketAsQRViaEmail(string targetMail, Guid ticketId, Event _event)

public Task SendTicketAsQRViaEmail(string targetMail, Guid ticketId, Event _event, string appearAt)
{
var name = _event.Name;
var location = _event.Location;
Expand All @@ -119,17 +120,23 @@ public Task SendTicketAsQRViaEmail(string targetMail, Guid ticketId, Event _even

string qrImage = "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=" + ticketId;

var content = $"You have been invited to: {name}, at {location}, on {date} between {start} and {end}.<br><br>" +
$"Please show the QR-code below at the entrance to get in.<br><br>" + qrImage;
//var content = $"You have been invited to: {name}, at {location}, on {date} between {start} and {end}.<br><br>" +
// $"Please show the QR-code below at the entrance to get in.<br><br>" +
// $"<img src=\"{qrImage}\" alt=\"QR-code\" width=\"300\" height=\"300\">";
var content = $"You have received an invitation for the event: {name}, located at {location}, scheduled for {date}";

if(string.IsNullOrEmpty(appearAt)){
content += $", between {start} and {end}.<br><br>";
}else{
content += ". ";
content += appearAt;
content += "<br><br>";
}

content += $"Please show the QR-code below at the entrance to get in.<br><br>" + qrImage;

return SendEmail(targetMail, $"ARKAD Ticket for {name}", content, content);
return SendEmail(targetMail, $"Arkad Ticket for {name}", content, content);

}

public Task SendTicketAsQRViaEmail(string targetMail, List<Ticket> tickets, Event _event)
public Task SendTicketAsQRViaEmail(string targetMail, List<Ticket> tickets, Event _event, string appearAt)
{
var name = _event.Name;
var location = _event.Location;
Expand All @@ -143,8 +150,17 @@ public Task SendTicketAsQRViaEmail(string targetMail, List<Ticket> tickets, Even

string qrImage = "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=";

var content = $"You and your {numberOfTickets-1} collegue(s) have been invited to: {name}, at {location}, on {date} between {start} and {end}.<br><br>" +
$"Please show the QR-codes below at the entrance to get in.<br><br>";
var content = $"You and your {numberOfTickets-1} collegue(s) have received an invitation for the event: {name}, located at {location}, scheduled for {date}";

if(string.IsNullOrEmpty(appearAt)){
content += $", between {start} and {end}.<br><br>";
}else{
content += ". ";
content += appearAt;
content += "<br><br>";
}

content += $"Please show the QR-codes below at the entrance to get in.<br><br>";

foreach (var ticket in tickets)
{
Expand Down

0 comments on commit 80189b8

Please sign in to comment.