예제 #1
0
        public async Task Insert(Aliment aliment, NutritionalInfoType type, decimal value)
        {
            var queryParameters = new DynamicParameters();

            queryParameters.Add("@AlimentId", aliment.Id);
            queryParameters.Add("@NutritionalInfoId", type);
            queryParameters.Add("@Value", value);

            await Execute("InsertNutritionalValue", queryParameters);
        }
        private async Task ProcessNutritionalValues(int row, int col, Aliment aliment, NutritionalInfoType type)
        {
            string cellValue = GetCellValue(row, col);

            if (!string.IsNullOrEmpty(cellValue))
            {
                decimal value;
                if (cellValue.StartsWith("> "))
                {
                    cellValue = cellValue.Substring(2, cellValue.Length - 2);
                    decimal.TryParse(cellValue, out value);
                    value /= 2;
                }
                else
                {
                    decimal.TryParse(cellValue, out value);
                }

                await _nutritionalValueRepository.Insert(aliment, type, value);
            }
        }