Example #1
0
        public virtual IEnumerable <IPhotographerModel> GetPhotographers()
        {
            var output = "Get all photographers";

            Console.WriteLine(output);
            var photographers = new List <IPhotographerModel>();

            try
            {
                Conn.Open();
                using (var reader = PS.GetAllPhotographers.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        photographers.Add(DTOParser.ParsePhotographerModel(RecordToDictionary(reader)));
                    }
                }
                Conn.Close();
                return(photographers);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new Exception(output, e);
            }
            finally
            {
                Conn.Close();
            }
        }
Example #2
0
        public virtual IPhotographerModel GetPhotographer(int ID)
        {
            var output = $"Get Photographer with ID: {ID}";

            Console.WriteLine(output);
            try
            {
                Conn.Open();
                PS.GetOnePhotographerId.Parameters["@ID"].Value = ID;
                PhotographerModel photographer;
                using (var reader = PS.GetOnePhotographerId.ExecuteReader())
                {
                    reader.Read();
                    photographer = DTOParser.ParsePhotographerModel(RecordToDictionary(reader));
                }
                Conn.Close();
                return(photographer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new Exception(output, e);
            }
            finally
            {
                Conn.Close();
            }
        }