private Task SendTicketSuccessNotificationAsync(string email, FlightTicketModel ticket) { string body = $"<p>For: {email}</p>" + $"<p>flightId: {ticket.FlightId}, ticketId: {ticket.Id}, Discount: {ticket.Discount}%</p>"; return(_emailService.SendMailAsync(email, "Reservation success", body)); }
private static FlightTicket MapToTicket(FlightTicketModel model, bool accepted = true) { return(new FlightTicket { FlightId = model.FlightId, FlightSeatId = model.FlightSeatId, TicketOwnerEmail = model.TicketOwnerEmail, Discount = model.Discount, Accepted = accepted }); }
public async Task <long> MakeReservation([FromBody] FlightTicketModel model) { var ticketId = await _flightService.MakeReservationAsync(model); if (!string.IsNullOrWhiteSpace(model.TicketOwnerEmail) && _settings.SendEmailNotifications) { model.Id = ticketId; await SendTicketSuccessNotificationAsync(model.TicketOwnerEmail, model); } return(ticketId); }
public Task <long> MakeReservationAsync(FlightTicketModel model) { var ticket = MapToTicket(model, accepted: true); return(_ticketRepository.AddAsync(ticket)); }