Ejemplo n.º 1
0
        public List <CostDbModel> GetAll()
        {
            var costs      = new List <CostDbModel>();
            var sqlCommand = new SqlCommand();

            string sqlQuery = @"
					SELECT * FROM Cost
			"            ;

            sqlCommand.CommandText = sqlQuery;

            IEnumerable <CustomDataRow> dataRowCollection = _sqlServerDatabase.GetCustomDataRowCollection(sqlCommand);

            foreach (var dataRow in dataRowCollection)
            {
                var cost = new CostDbModel();

                cost.Id       = ConversionHelper.ToInt(dataRow["IdCost"]);
                cost.IsActive = ConversionHelper.ToBoolean(dataRow["IsActive"]);
                cost.RefCriteriaValueCostType = ConversionHelper.ToInt(dataRow["RefCriteriaValueCostType"]);
                cost.Amount            = ConversionHelper.ToFloat(dataRow["Amount"]);
                cost.DateTimeCreatedOn = ConversionHelper.ToDateTime(dataRow["DateTimeCreatedOn"]);

                costs.Add(cost);
            }

            return(costs);
        }
Ejemplo n.º 2
0
        private void SaveCost(object parameter)
        {
            var values = (object[])parameter;
            var cost   = new CostDbModel {
                IsActive = true,
                RefCriteriaValueCostType = ConversionHelper.ToInt(values[0]),
                Amount            = ConversionHelper.ToFloat(values[1]),
                DateTimeCreatedOn = ConversionHelper.ToDateTime(values[2])
            };

            _costRepository.Save(cost);

            StatusMessage = "Cost saved succesfully!";
        }
Ejemplo n.º 3
0
        public bool Save(CostDbModel cost)
        {
            var sqlCommand = new SqlCommand();

            string sqlQuery = @"
					INSERT INTO Cost (IsActive, RefCriteriaValueCostType, Amount, DateTimeCreatedOn)
					VALUES (@IsActive, @RefCriteriaValueCostType, @Amount, @DateTimeCreatedOn)
			"            ;

            sqlCommand.CommandText = sqlQuery;
            sqlCommand.Parameters.AddWithValue("@IsActive", 1);
            sqlCommand.Parameters.AddWithValue("@RefCriteriaValueCostType", cost.RefCriteriaValueCostType);
            sqlCommand.Parameters.AddWithValue("@Amount", cost.Amount);
            sqlCommand.Parameters.AddWithValue("@DateTimeCreatedOn", cost.DateTimeCreatedOn);

            _sqlServerDatabase.ExecuteNonQuery(sqlCommand);

            return(false);
        }
Ejemplo n.º 4
0
        public CostDbModel Get(int id)
        {
            var sqlCommand = new SqlCommand();

            string sqlQuery = @"
					SELECT * FROM Cost WHERE IdCost = @IdCost
			"            ;

            sqlCommand.CommandText = sqlQuery;
            sqlCommand.Parameters.AddWithValue("@IdCost", id);

            CustomDataRow dataRow = _sqlServerDatabase.GetCustomDataRow(sqlCommand);

            var cost = new CostDbModel();

            cost.Id       = ConversionHelper.ToInt(dataRow["IdCost"]);
            cost.IsActive = ConversionHelper.ToBoolean(dataRow["IsActive"]);
            cost.RefCriteriaValueCostType = ConversionHelper.ToInt(dataRow["RefCriteriaValueCostType"]);
            cost.Amount            = ConversionHelper.ToFloat(dataRow["Amount"]);
            cost.DateTimeCreatedOn = ConversionHelper.ToDateTime(dataRow["DateTimeCreatedOn"]);

            return(cost);
        }