public IEnumerable <StatusCountValue> GetAll(StatusCountValuesParameters parameters) { string query = "DW.usp_GetStatusCountValues"; var records = new List <StatusCountValue>(); using (var connection = new SqlConnection(_connectionString)) { connection.Open(); using (var command = new SqlCommand(query, connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("startingYear", (int)parameters.StartingYear)); command.Parameters.Add(new SqlParameter("endingYear", (int)parameters.EndingYear)); command.Parameters.Add(new SqlParameter("caseWorkerKey", (int?)parameters.CaseWorkerKey)); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var statusCountValueRecord = StatusCountValueMapper.MapReaderToStatusCountValue(reader); records.Add(statusCountValueRecord); } // while reader } // using reader } // using command } // using connection return(records); } // method GetAll
public HttpResponseMessage Post(StatusCountValuesParameters parameters) { HttpResponseMessage msg; if (parameters.StartingYear < 2009) { msg = Request.CreateErrorResponse( HttpStatusCode.NotFound, String.Format("Starting Year value: {0} is invalid", parameters.StartingYear)); } else { var records = _repository.GetAll(parameters); msg = Request.CreateResponse( HttpStatusCode.OK, records); } return(msg); } // method Get
public IEnumerable <Domain.StatusCountValue> GetAll(StatusCountValuesParameters parameters) { return(_storageProvider.GetAll(parameters)); } // method GetAll