public List <ArticleDAL> ArticlesGetAll(int Skip, int Take) { List <ArticleDAL> proposedReturnValue = new List <ArticleDAL>(); try { EnsureConnected(); using (SqlCommand command = new SqlCommand("ArticlesGetAll", _con)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@Skip", Skip); command.Parameters.AddWithValue("@Take", Take); using (SqlDataReader reader = command.ExecuteReader()) { ArticleMapper fm = new ArticleMapper(reader); while (reader.Read()) { ArticleDAL item = fm.ToArticle(reader); proposedReturnValue.Add(item); } } } } catch (Exception ex) when(Log(ex)) { // stays empty } return(proposedReturnValue); }
public ArticleDAL ArticleFindByName(int ArticleName) { ArticleDAL proposedReturnValue = null; try { EnsureConnected(); using (SqlCommand command = new SqlCommand("ArticleFindByName", _con)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@ArticleName", ArticleName); using (SqlDataReader reader = command.ExecuteReader()) { ArticleMapper am = new ArticleMapper(reader); int count = 0; while (reader.Read()) { proposedReturnValue = am.ToArticle(reader); count++; } if (count > 1) { throw new Exception($"Multiple Articles found for Name {ArticleName}"); } } } } catch (Exception ex) when(Log(ex)) { // stays empty } return(proposedReturnValue); }