Пример #1
0
        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();
        }
Пример #2
0
        public ITravelDate InnerAdd(ITravelDate travelDate)
        {
            using var dbContext = _dataAccessor.GetNewDatabaseContext();
            var travelDateEntity = dbContext.TravelDates.Add((TravelDate)travelDate);

            dbContext.SaveChanges();

            return(travelDateEntity.Entity);
        }
Пример #3
0
 public void SelectTraveler(int id)
 {
     _selectedTravelDate = _travelDates.FirstOrDefault(x => x.Id == id);
 }
Пример #4
0
 public void Remove(ITravelDate travelDate)
 {
     using var dbContext = _dataAccessor.GetNewDatabaseContext();
     dbContext.TravelDates.Remove((TravelDate)travelDate);
     dbContext.SaveChanges();
 }
Пример #5
0
 public void Update(ITravelDate travelDate)
 {
     using var dbContext = _dataAccessor.GetNewDatabaseContext();
     dbContext.Update(travelDate);
     dbContext.SaveChanges();
 }