Ejemplo n.º 1
0
        public void CreateSoilSample(SoilSampleModel model)
        {
            using (IDbConnection connection = new SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@FieldId", model.FieldId);
                p.Add("@SampleYear", model.SampleYear);
                p.Add("@id", model.Id, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);

                connection.Execute("dbo.spSoilSamples_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@id");
            }
        }
Ejemplo n.º 2
0
        private void ProcessSample(List <string> sampleRow)
        {
            SoilSampleModel newSampleModel = new SoilSampleModel
            {
                FieldId    = Convert.ToInt32(sampleRow[FieldIndex]),
                SampleYear = Convert.ToInt32(sampleRow[YearIndex])
            };

            foreach (var key in NutrientMappings.Keys)
            {
                SoilSampleNutrientModel newNutrientRecord = CreateSampleNutrientRecord(sampleRow, key);
                newSampleModel.Nutrients.Add(newNutrientRecord);
            }
            SoilSampleData sampleData = new SoilSampleData();

            sampleData.Sample = newSampleModel;
            sampleData.WriteSoilSample();
            Samples.Add(newSampleModel);
        }