/// <summary> /// Appends Account-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of Budget class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, Budget budget, DbActionType action) { command.AddCommonParameters(budget.Id, action); command.Parameters.Add("@id_category", SqlDbType.Int).Value = budget.CategoryId; command.Parameters.Add("@amount", SqlDbType.Money).Value = budget.Amount; command.Parameters.Add("@budget_date", SqlDbType.DateTime).Value = budget.BudgetDate.ToDbValue(); command.Parameters.Add("@id_company", SqlDbType.Int).Value = budget.CompanyId.ToDbValue(); command.Parameters.Add("@period_type", SqlDbType.SmallInt).Value = budget.PeriodType.ToDbValue(); }
/// <summary> /// Appends UserProfile-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of UserProfile class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, UserProfile userProfile, DbActionType action) { command.AddCommonParameters(userProfile.Id, action); command.Parameters.Add("@email", SqlDbType.NVarChar).Value = userProfile.Name.ToDbValue(); command.Parameters.Add("@password", SqlDbType.NVarChar).Value = userProfile.Password.ToDbValue(); command.Parameters.Add("@password_question", SqlDbType.NVarChar).Value = userProfile.PasswordQuestion.ToDbValue(); command.Parameters.Add("@password_answer", SqlDbType.NVarChar).Value = userProfile.PasswordAnswer.ToDbValue(); command.Parameters.Add("@first_name", SqlDbType.NVarChar).Value = userProfile.FirstName.ToDbValue(); command.Parameters.Add("@last_name", SqlDbType.NVarChar).Value = userProfile.LastName.ToDbValue(); command.Parameters.Add("@comment", SqlDbType.NVarChar).Value = userProfile.Comment.ToDbValue(); command.Parameters.Add("@is_approved", SqlDbType.Bit).Value = userProfile.IsApproved; command.Parameters.Add("@current_time_utc", SqlDbType.DateTime).Value = DateTime.UtcNow; }
/// <summary> /// Appends Transaction-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of Transaction class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, Transaction transaction, DbActionType action) { command.AddCommonParameters(transaction.Id, action); command.Parameters.Add("@date", SqlDbType.DateTime).Value = transaction.Date; command.Parameters.Add("@amount", SqlDbType.Decimal).Value = transaction.Amount; command.Parameters.Add("@merchant", SqlDbType.NVarChar).Value = transaction.Merchant.ToDbValue(); command.Parameters.Add("@id_account", SqlDbType.Int).Value = transaction.AccountId.ToDbValue(); command.Parameters.Add("@id_category", SqlDbType.Int).Value = transaction.CategoryId.ToDbValue(); command.Parameters.Add("@description", SqlDbType.NVarChar).Value = transaction.Description.ToDbValue(); command.Parameters.Add("@notes", SqlDbType.NVarChar).Value = transaction.Notes.ToDbValue(); command.Parameters.Add("@type", SqlDbType.Int).Value = transaction.TransactionType; command.Parameters.Add("@direction", SqlDbType.Int).Value = transaction.Direction; command.Parameters.Add("@include_in_tax", SqlDbType.Bit).Value = transaction.IncludeInTax; command.Parameters.Add("@tags", SqlDbType.NVarChar).Value = string.Join(Transaction.TAG_SEPARATOR, transaction.TagIds); }
/// <summary> /// Appends Tag-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of Tag class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, Tag entity, DbActionType action) { command.AddCommonParameters(entity.Id, action); command.Parameters.Add("@name", SqlDbType.NVarChar).Value = entity.Name.ToDbValue(); command.Parameters.Add("@id_user", SqlDbType.Int).Value = entity.UserId.ToDbValue(); }
/// <summary> /// Appends Rule-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of FieldRule class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, FieldRule rule, DbActionType action) { command.AddCommonParameters(rule.Id, action); command.Parameters.Add("@id_user", SqlDbType.Int).Value = rule.UserId.ToDbValue(); command.Parameters.Add("@field_target", SqlDbType.NVarChar).Value = rule.FieldTarget.ToDbValue(); command.Parameters.Add("@field_target_value", SqlDbType.NVarChar).Value = rule.FieldTargetValue.ToDbValue(); command.Parameters.Add("@field", SqlDbType.NVarChar).Value = rule.Field.ToDbValue(); command.Parameters.Add("@field_value", SqlDbType.NVarChar).Value = rule.FieldValue.ToDbValue(); command.Parameters.Add("@priority", SqlDbType.Int).Value = rule.Priority.ToDbValue(); command.Parameters.Add("@type_rule", SqlDbType.SmallInt).Value = (short)rule.RuleType; }
/// <summary> /// Appends Account-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of Account class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, Account account, DbActionType action) { command.AddCommonParameters(account.Id, action); command.Parameters.Add("@curr_date_utc", SqlDbType.DateTime).Value = DateTime.UtcNow; command.Parameters.Add("@name", SqlDbType.NVarChar).Value = account.Name.ToDbValue(); command.Parameters.Add("@id_company", SqlDbType.Int).Value = account.CompanyId.ToDbValue(); command.Parameters.Add("@id_currency", SqlDbType.Int).Value = account.CurrencyId.ToDbValue(); command.Parameters.Add("@initial_balance", SqlDbType.Decimal).Value = account.InitialBalance; command.Parameters.Add("@id_type", SqlDbType.Int).Value = account.TypeId.ToDbValue(); command.Parameters.Add("@description", SqlDbType.NVarChar).Value = account.Description.ToDbValue(); command.Parameters.Add("@balance", SqlDbType.Decimal).Value = account.Balance; command.Parameters.Add("@id_financial_institution", SqlDbType.Int).Value = account.FinInstitutionId.ToDbValue(); command.Parameters.Add("@card_number", SqlDbType.NVarChar).Value = account.CardNumber.ToDbValue(); }
/// <summary> /// Appends Account-specific parameters to the specificied SqlCommand. /// </summary> /// <param name="command">SqlCommand to be executed.</param> /// <param name="alert">Instance of Modem class</param> /// <param name="action">Database action type (select, insert, update, delete).</param> public static void AddEntityParameters(this SqlCommand command, Modem account, DbActionType action) { command.AddCommonParameters(account.Id, action); command.Parameters.Add("@description", SqlDbType.NVarChar).Value = account.Description.ToDbValue(); command.Parameters.Add("@gateway", SqlDbType.NVarChar).Value = account.Description.ToDbValue(); }