public RelayDisciplineDTO GetRelayDisciplineDto(int pk, RelayDTO relay, int fk_d, int position)
        {
            var disciplineHandler = new DisciplineHandler();
            var discipline        = disciplineHandler.Select(fk_d);

            return(new RelayDisciplineDTO
            {
                Pk = pk,
                FK_R = relay.Pk,
                FK_D = fk_d,
                Position = position,
                Relay = relay,
                Discipline = discipline
            });
        }
Beispiel #2
0
        protected override List <TimeDTO> ReadParamterized(string cmd, List <string> parameters)
        {
            var times = new List <TimeDTO>();

            using (SqlConnection con = new SqlConnection(_readerConnectionString))
            {
                try
                {
                    var query = new SqlCommand(cmd, con);
                    AddParameters(query, parameters);

                    con.Open();

                    using (var sqlReader = query.ExecuteReader())
                    {
                        TimeDTO tmpTime;
                        while (sqlReader.Read())
                        {
                            tmpTime = GetTimeDto(
                                sqlReader.GetInt32(0),
                                sqlReader.GetInt32(1),
                                sqlReader.GetInt32(2),
                                sqlReader.GetDecimal(3),
                                sqlReader.GetDateTime(4)
                                );

                            var birthday = sqlReader.IsDBNull(7) ? new DateTime() : sqlReader.GetDateTime(7);
                            var phoneNr  = sqlReader.IsDBNull(10) ? "" : sqlReader.GetString(10);
                            var email    = sqlReader.IsDBNull(11) ? "" : sqlReader.GetString(11);

                            // Fill up person object
                            tmpTime.Person = PersonHandler.GetPersonDto(
                                tmpTime.FK_P,
                                sqlReader.GetString(5),
                                sqlReader.GetString(6),
                                birthday,
                                sqlReader.GetBoolean(8),
                                sqlReader.GetBoolean(9),
                                phoneNr,
                                email
                                );

                            // Fill up discipline object
                            tmpTime.Discipline = DisciplineHandler.GetDisciplineDto(
                                tmpTime.FK_D,
                                sqlReader.GetString(12),
                                sqlReader.GetInt32(13)
                                );

                            times.Add(tmpTime);
                        }
                    }
                }
                catch (SqlException e)
                {
                    throw;
                }
                catch (Exception e)
                {
                    throw;
                }
            }

            return(times);
        }