Ejemplo n.º 1
0
        public List <CategorieDal> GetCategories(int skip, int take)
        {
            List <CategorieDal> proposedReturnValue = new List <CategorieDal>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetCategories", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Skip", skip);
                    command.Parameters.AddWithValue("@Take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CategorieMapper m = new CategorieMapper(reader);
                        while (reader.Read())
                        {
                            CategorieDal r = m.CategorieFromReader(reader);
                            proposedReturnValue.Add(r);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(proposedReturnValue);
        }
Ejemplo n.º 2
0
        //Categories
        public CategorieDal FindCategorieByID(int CategorieID)
        {
            CategorieDal ProposedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("FindCategoryByID", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@CategoryID", CategorieID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CategorieMapper m     = new CategorieMapper(reader);
                        int             count = 0;
                        while (reader.Read())
                        {
                            ProposedReturnValue = m.CategorieFromReader(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Found more than 1 User with key{CategorieID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ProposedReturnValue);
        }
Ejemplo n.º 3
0
        public CategorieDal CategorieFromReader(System.Data.SqlClient.SqlDataReader reader)
        {
            CategorieDal proposedReturnValue = new CategorieDal();

            proposedReturnValue.CategorieID = reader.GetInt32(OffsetToCategorieID);
            proposedReturnValue.Categorie   = reader.GetString(OffsetToCategorie);
            return(proposedReturnValue);
        }