public object CreateTaxRate(TaxRateInputDto taxRate) { SqlHelper sqlHelper = new SqlHelper(connectionString); List <SqlParameter> taxRateParameters = new List <SqlParameter> { new SqlParameter("effectiveFrom", taxRate.EffectiveFrom), new SqlParameter("effectiveTo", taxRate.EffectiveTo), new SqlParameter("longTermTaxRate", taxRate.LongTermTaxRate), new SqlParameter("shortTermTaxRate", taxRate.ShortTermTaxRate), new SqlParameter("shortTermPeriod", taxRate.ShortTermPeriod), new SqlParameter("createdDate", DateTime.Now), new SqlParameter("createdBy", "John Smith") }; var taxRateQuery = $@"INSERT INTO [tax_rate] ([effective_from] ,[effective_to] ,[long_term_tax_rate] ,[short_term_tax_rate] ,[short_term_period] ,[created_date] ,[last_updated_date] ,[created_by]) VALUES (@effectiveFrom ,@effectiveTo ,@longTermTaxRate ,@shortTermTaxRate ,@shortTermPeriod ,@createdDate ,@createdDate ,@createdBy)"; try { sqlHelper.VerifyConnection(); sqlHelper.Insert(taxRateQuery, CommandType.Text, taxRateParameters.ToArray()); sqlHelper.CloseConnection(); } catch (Exception ex) { sqlHelper.CloseConnection(); Console.WriteLine($"SQL Exception: {ex}"); return(Utils.Wrap(false)); } return(Utils.Wrap(true)); }
public object EditTaxRate(int id, TaxRateInputDto taxRate) { SqlHelper sqlHelper = new SqlHelper(connectionString); List <SqlParameter> taxRateParameters = new List <SqlParameter> { new SqlParameter("id", id), new SqlParameter("effectiveFrom", taxRate.EffectiveFrom), new SqlParameter("effectiveTo", taxRate.EffectiveTo), new SqlParameter("longTermTaxRate", taxRate.LongTermTaxRate), new SqlParameter("shortTermTaxRate", taxRate.ShortTermTaxRate), new SqlParameter("shortTermPeriod", taxRate.ShortTermPeriod), new SqlParameter("lastUpdatedDate", DateTime.Now), new SqlParameter("lastUpdatedBy", "John Smith") }; var taxRateQuery = $@"UPDATE [tax_rate] SET [effective_from] = @effectiveFrom ,[effective_to] = @effectiveTo ,[long_term_tax_rate] = @longTermTaxRate ,[short_term_tax_rate] = @shortTermTaxRate ,[short_term_period] = @shortTermPeriod ,[last_updated_date] = @lastUpdatedDate ,[last_updated_by] = @lastUpdatedBy WHERE [tax_rate].[Id] = @id"; try { sqlHelper.VerifyConnection(); sqlHelper.Update(taxRateQuery, CommandType.Text, taxRateParameters.ToArray()); } catch (Exception ex) { sqlHelper.CloseConnection(); Console.WriteLine($"Edit Tax Rate Exception: {ex}"); return(Utils.Wrap(false)); } return(Utils.Wrap(true)); }
public object EditTaxRate(int id, TaxRateInputDto taxRate) { return(!ModelState.IsValid || taxRate == null ? BadRequest(ModelState) : controller.EditTaxRate(id, taxRate)); }
public object CreateTaxRate(TaxRateInputDto taxRate) { return(!ModelState.IsValid || taxRate == null?BadRequest(ModelState) : controller.CreateTaxRate(taxRate)); }