public void GenerateDocument(ITravelDate selectedTravelDate, string path) { using var streamWriter = new StreamWriter(path); var firstLine = $"Utazás, {selectedTravelDate.TravelName}"; var secondLine = $"Dátum, {selectedTravelDate.DateOfTravel.ToShortDateString()}"; var headerLine = $"Sorszám,Név,Telefon,Indulás,Érkezés,Fizet,Összeg"; streamWriter.WriteLine(firstLine); streamWriter.WriteLine(secondLine); streamWriter.WriteLine(headerLine); var lineIndex = 1; foreach (var travelDateReference in selectedTravelDate.TravelerTravelDateReferences) { var traveler = travelDateReference.Traveler; var line = $"{lineIndex},{traveler.LastName} {traveler.FirstName},{traveler.PhoneNumber},{traveler.DirectionFrom},{traveler.DirectionTo}"; if (traveler.DoesPay) { line = $"{line},Igen,{traveler.Price}"; } else { line = $"{line},Nem,"; } streamWriter.WriteLine(line); lineIndex++; } streamWriter.Flush(); }
public ITravelDate InnerAdd(ITravelDate travelDate) { using var dbContext = _dataAccessor.GetNewDatabaseContext(); var travelDateEntity = dbContext.TravelDates.Add((TravelDate)travelDate); dbContext.SaveChanges(); return(travelDateEntity.Entity); }
public void SelectTraveler(int id) { _selectedTravelDate = _travelDates.FirstOrDefault(x => x.Id == id); }
public void Remove(ITravelDate travelDate) { using var dbContext = _dataAccessor.GetNewDatabaseContext(); dbContext.TravelDates.Remove((TravelDate)travelDate); dbContext.SaveChanges(); }
public void Update(ITravelDate travelDate) { using var dbContext = _dataAccessor.GetNewDatabaseContext(); dbContext.Update(travelDate); dbContext.SaveChanges(); }