Exemplo n.º 1
0
 public CrimeType[] GetAllCrimeType()
 {
     try
     {
         using (var c = new Connect())
         {
             SqlConnection sqlconn = c.GetConnection();
             var crimeMapper = new CrimeTypeDataMapper(sqlconn);
             IEnumerable<CrimeType> list = crimeMapper.GetAll();
             return list.ToArray();
         }
     }
     catch (Exception exception)
     {
         throw new FaultException<ServerError>(new ServerError());
     }
 }
Exemplo n.º 2
0
 public CrimeType[] GetAllCrimeType()
 {
     try
     {
         using (var c = new Connect())
         {
             SqlConnection           sqlconn     = c.GetConnection();
             var                     crimeMapper = new CrimeTypeDataMapper(sqlconn);
             IEnumerable <CrimeType> list        = crimeMapper.GetAll();
             return(list.ToArray());
         }
     }
     catch (Exception exception)
     {
         throw new FaultException <ServerError>(new ServerError());
     }
 }
Exemplo n.º 3
0
        //
        // Get an array of Regist associated with a person id
        //
        public Regist[] GetRegists(int person_id)
        {
            try
            {
                using (var connect = new Connect())
                {
                    SqlConnection sqlconn         = connect.GetConnection();
                    var           registMapper    = new RegistDataMapper(sqlconn);
                    var           crimeTypeMapper = new CrimeTypeDataMapper(sqlconn);
                    var           partiMapper     = new ParticipantDataMapper(sqlconn);

                    IEnumerable <Participant> participants = partiMapper.GetAll().Where(p => p.Person.Id == person_id);
                    var regists = new List <Regist>();


                    foreach (Participant part in participants)
                    {
                        regists.Add(registMapper.GetById(part.Regist.Id));
                    }

                    foreach (Regist r in regists)
                    {
                        foreach (Participant p in partiMapper.GetAll().Where(part => part.Regist.Id == r.Id))
                        {
                            r.AddParticipant(p);
                        }
                        r.SetParticipants();
                    }

                    return(regists.ToArray());
                }
            }
            catch (Exception exception)
            {
                throw new FaultException <ServerError>(new ServerError());
            }
        }
Exemplo n.º 4
0
        //
        // Get an array of Regist associated with a person id
        //
        public Regist[] GetRegists(int person_id)
        {
            try
            {
                using (var connect = new Connect())
                {
                    SqlConnection sqlconn = connect.GetConnection();
                    var registMapper = new RegistDataMapper(sqlconn);
                    var crimeTypeMapper = new CrimeTypeDataMapper(sqlconn);
                    var partiMapper = new ParticipantDataMapper(sqlconn);

                    IEnumerable<Participant> participants = partiMapper.GetAll().Where(p => p.Person.Id == person_id);
                    var regists = new List<Regist>();

                    foreach (Participant part in participants)
                    {
                        regists.Add(registMapper.GetById(part.Regist.Id));
                    }

                    foreach (Regist r in regists)
                    {
                        foreach (Participant p in partiMapper.GetAll().Where(part => part.Regist.Id == r.Id))
                        {
                            r.AddParticipant(p);
                        }
                        r.SetParticipants();
                    }

                    return regists.ToArray();
                }
            }
            catch (Exception exception)
            {
                throw new FaultException<ServerError>(new ServerError());
            }
        }