public TransportForm Map(DbDataReader dbDataReader) { AdministrativeEmployeeRepository administrativeEmployeeRepository = new AdministrativeEmployeeRepository(dbConnection); AdministrativeEmployee dispatcher = administrativeEmployeeRepository.Search(dbDataReader.GetString(8), true); VehicleRepository vehicleRepository = new VehicleRepository(dbConnection); Vehicle vehicle = vehicleRepository.Search(dbDataReader.GetString(6)); RouteRepository routeRepository = new RouteRepository(dbConnection); Route route = routeRepository.Search(dbDataReader.GetString(7)); if (dispatcher is null || vehicle is null || route is null) { return(null); } string transport_form_number = dbDataReader.GetString(0); bool state = dbDataReader.GetBoolean(1); DateTime startDate, depatureTime; startDate = dbDataReader.GetDateTime(2); depatureTime = dbDataReader.GetDateTime(3); TransportForm transportForm = new TransportForm(transport_form_number, route, vehicle, dispatcher, startDate, depatureTime, state); transportForm.AddFinalcialInformation(ReplacementFund, dbDataReader.GetDecimal(9)); transportForm.AddFinalcialInformation(SocialContribution, dbDataReader.GetDecimal(10)); transportForm.AddFinalcialInformation(TireService, dbDataReader.GetDecimal(11)); transportForm.AddFinalcialInformation(VehicleFixService, dbDataReader.GetDecimal(12)); transportForm.AddFinalcialInformation(NonContractualSecureService, dbDataReader.GetDecimal(13)); transportForm.AddFinalcialInformation(ConstactInsuranceService, dbDataReader.GetDecimal(14)); transportForm.AddFinalcialInformation(SocialProtection, dbDataReader.GetDecimal(15)); transportForm.AddFinalcialInformation(ExtraordinaryProtection, dbDataReader.GetDecimal(16)); transportForm.AddFinalcialInformation(Administration, dbDataReader.GetDecimal(17)); transportForm.AddFinalcialInformation(Others, dbDataReader.GetDecimal(18)); using (DbCommand ticketCommand = CreateCommand()) { ticketCommand.CommandText = "SELECT seats, ticket_date, passenger FROM tickets WHERE transport_form_number = @transport_form_number"; ticketCommand.Parameters.Add(CreateDbParameter(ticketCommand, "@transport_form_number", transportForm.Number)); DbDataReader ticketDataReader = ticketCommand.ExecuteReader(); PersonRepository personRepository = new PersonRepository(dbConnection); while (ticketDataReader.Read()) { if (!(personRepository.Search(ticketDataReader.GetString(2)) is Person passenger)) { continue; } transportForm.AddTicket(passenger.ToPassenger(), ticketDataReader.GetInt16(0), ticketDataReader.GetDateTime(1)); } } transportForm.UpdateTotalValue(); return(transportForm); }
public Commend Map(DbDataReader dbDataReader) { Person sender, receiver; PersonRepository personRepository = new PersonRepository(dbConnection); sender = personRepository.Search(dbDataReader.GetString(4)); receiver = personRepository.Search(dbDataReader.GetString(5)); if (sender is null || receiver is null) { return(null); } AdministrativeEmployeeRepository administrativeEmployee = new AdministrativeEmployeeRepository(dbConnection); VehicleRepository vehicleRepository = new VehicleRepository(dbConnection); AdministrativeEmployee dispatcher = administrativeEmployee.Search(dbDataReader.GetString(6), true); Vehicle vehicle = vehicleRepository.Search(dbDataReader.GetString(7)); if (dispatcher is null || vehicle is null) { return(null); } string delivery_number, destination, description; DateTime delivery_date; decimal freightValue, agreement; State state; delivery_number = dbDataReader.GetString(0); delivery_date = dbDataReader.GetDateTime(1); description = dbDataReader.GetString(10); destination = dbDataReader.GetString(2); freightValue = dbDataReader.GetDecimal(8); agreement = dbDataReader.GetDecimal(9); string stateStr = dbDataReader.GetString(3); state = (stateStr == "D") ? State.Delivered : (stateStr == "C") ? State.Cancel : State.Active; return(new Commend(delivery_number, delivery_date, sender, receiver, dispatcher, destination, description, freightValue, agreement, vehicle, state)); }
public BankDraft Map(DbDataReader dbDataReader) { Person sender, receiver; PersonRepository personRepository = new PersonRepository(dbConnection); sender = personRepository.Search(dbDataReader.GetString(4)); receiver = personRepository.Search(dbDataReader.GetString(5)); if (sender is null || receiver is null) { return(null); } AdministrativeEmployeeRepository administrativeEmployeeRepository = new AdministrativeEmployeeRepository(dbConnection); AdministrativeEmployee dispatcher = administrativeEmployeeRepository.Search(dbDataReader.GetString(6), true); if (dispatcher is null) { return(null); } string delivery_number, destination; DateTime delivery_date; decimal valueToSend, cost; State state; delivery_number = dbDataReader.GetString(0); delivery_date = dbDataReader.GetDateTime(1); destination = dbDataReader.GetString(2); valueToSend = dbDataReader.GetDecimal(7); cost = dbDataReader.GetDecimal(8); string stateStr = dbDataReader.GetString(3); state = (stateStr == "D") ? State.Delivered : (stateStr == "C") ? State.Cancel : State.Active; return(new BankDraft(delivery_number, delivery_date, sender, receiver, dispatcher, destination, valueToSend, cost, state)); }