private async Task SendEmailAsync(TaxiReservation taxiReservation) { var sender = new MailgunSender(domainName, apiKey); Email.DefaultSender = sender; var user = await userService.FindUserByTaxiReservationIdAsync(taxiReservation.UserId); var taxi = await FindTaxiReservationByIdAsync(taxiReservation.TaxiReservationId); var template = " You received this message because your taxi has been booked in the Garnet Travel " + "reservation system." + "\r\n Your reservation time: " + taxi.TaxiReservationStart + "\r\n Pick-up location: " + taxi.StartLocal + "\r\n Drop-off location: " + taxi.EndLocal + "\r\n Number of travelers: " + taxi.NumberOfGuest + "\r\n Phone number: " + taxi.PhoneNumber + "\r\n\n Sincerely, Garnet Travel team" + "\r\n (This is an auto generated message, please do not reply!)"; var email = Email .From(domainName, "GarnetTravel.Info") .To(user.Email) .Subject($"Reservation notification #{taxiReservation.TaxiReservationId}") .UsingTemplate(template, false, false); await email.SendAsync(); }
/// <summary> /// edit a reservation /// </summary> /// <param name="taxiReservation">taxiReservation object</param> /// <returns>taxi reservation</returns> public TaxiReservation EditReservation(TaxiReservation taxiReservation) { Database db = Database.Open(DatabaseName); var dbCommand = "UPDATE TaxiReservation SET (Date = @1) WHERE Id = @0"; var row = db.QuerySingle(dbCommand, taxiReservation.Id, taxiReservation.Date); db.Close(); return(taxiReservation); }
/// <summary> /// gets a reservation by id /// </summary> /// <param name="Id">id</param> /// <returns>reservation</returns> public TaxiReservation GetReservation(int Id) { Database db = Database.Open(DatabaseName); string insertCommand = "SELECT * FROM TaxiReservation WHERE Id = @0"; var row = db.QuerySingle(insertCommand, Id); db.Close(); var reservering = new TaxiReservation(row.Id, row.TaxiCompanyId, row.UserInfoId, row.Date); return(reservering); }
/// <summary> /// gets all reservations from a taxi company /// </summary> /// <param name="TaxiCompanyId">taxi comapny id</param> /// <returns>list of reservations</returns> public List <TaxiReservation> GetAllReservationsFromTaxiCompany(int TaxiCompanyId) { Database db = Database.Open(DatabaseName); string insertCommand = "SELECT * FROM TaxiReservation WHERE TaxiCompanyId = @0"; var rows = db.Query(insertCommand, TaxiCompanyId); db.Close(); List <TaxiReservation> reserveringen = new List <TaxiReservation>(); foreach (var row in rows) { var reservering = new TaxiReservation(row.Id, row.TaxiCompanyId, row.UserInfoId, row.Date); reserveringen.Add(reservering); } return(reserveringen); }
public async Task FindTaxiReservationByTaxiReservationIdAsyncTest() { using (var context = new ApplicationContext(options)) { var taxiReservationService = new TaxiReservationService(context, mockMapper.Object, mockUserService.Object, configuration); var taxiReservation = new TaxiReservation { TaxiReservationStart = new DateTime(2019, 11, 10), TaxiReservationId = 1, NumberOfGuest = 2, PhoneNumber = "222222222", StartLocal = "Budapest", EndLocal = "Siófok", UserId = "1" }; long id = taxiReservation.TaxiReservationId; var actual = await taxiReservationService.FindTaxiReservationByIdAsync(1); Assert.Equal(id, actual.TaxiReservationId); } }