Пример #1
0
        public CompetitorTaxRateResponse InsertUpdateCompetitorTaxRate
            (CompetitorTaxRate competitorTaxRate)
        {
            try
            {
                Log.Info("Started call to InsertUpdateCompetitorTaxRate");
                Log.Info("parameter values"
                         + JsonConvert.SerializeObject(competitorTaxRate));
                Command.CommandText = "SP_COMPETITOR_TAX_RATE_MANAGER";
                Command.CommandType = CommandType.StoredProcedure;
                Command.Parameters.Clear();

                Command.Parameters.AddWithValue("@COMPETITOR_TAX_RATE_XML"
                                                , GetXMLFromObject(competitorTaxRate));

                if (competitorTaxRate.AddedBy.HasValue)
                {
                    Command.Parameters.AddWithValue("@USER_ID", competitorTaxRate.AddedBy.Value);
                }
                else if (competitorTaxRate.ModifiedBy.HasValue)
                {
                    Command.Parameters.AddWithValue("@USER_ID", competitorTaxRate.ModifiedBy.Value);
                }
                Connection.Open();
                SqlDataReader reader = Command.ExecuteReader();

                CompetitorTaxRateResponse result = new CompetitorTaxRateResponse();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result = new CompetitorTaxRateResponse
                        {
                            Message   = reader["ReturnMessage"] != DBNull.Value ? reader["ReturnMessage"].ToString() : null,
                            IsSuccess = Convert.ToBoolean(reader["Result"].ToString())
                        };
                    }
                }
                Log.Info("End call to InsertUpdateCompetitorTaxRate. Result:"
                         + JsonConvert.SerializeObject(result));
                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("Error in InsertUpdateCompetitorTaxRate. Error:"
                          + JsonConvert.SerializeObject(ex));
                LogError(ex);
                throw;
            }
            finally
            {
                Connection.Close();
            }
        }
Пример #2
0
        public CompetitorTaxRateResponse InsertUpdateCompetitorTaxRate
            ([FromBody] List <CompetitorTaxRate> competitorTaxRates)
        {
            var objMaster = _Kernel.Get <IMaster>();
            CompetitorTaxRateResponse result = new CompetitorTaxRateResponse()
            {
                IsSuccess = false
            };

            foreach (var competitorTaxRate in competitorTaxRates)
            {
                result = objMaster.InsertUpdateCompetitorTaxRate(competitorTaxRate);
                if (!result.IsSuccess)
                {
                    break;
                }
            }
            return(result);
        }
Пример #3
0
        public CompetitorTaxRateResponse GetCompetitorTaxRates
            (int companyId, bool?insertDummyRecords, bool?isActive)
        {
            try
            {
                Log.Info("Started call to GetCompetitorTaxRates");
                Log.Info("parameter values" + JsonConvert.SerializeObject(new
                {
                    companyId          = companyId,
                    insertDummyRecords = insertDummyRecords,
                    isActive           = isActive
                }));
                Command.CommandText = "SP_GET_SP_COMPETITOR_TAX_RATES";
                Command.CommandType = CommandType.StoredProcedure;
                Command.Parameters.AddWithValue("@COMPANY_ID", companyId);
                if (insertDummyRecords.HasValue)
                {
                    Command.Parameters.AddWithValue("@INSERT_DUMMY_RECORDS", insertDummyRecords.Value);
                }
                if (isActive.HasValue)
                {
                    Command.Parameters.AddWithValue("@ACTIVE", isActive.Value);
                }
                Connection.Open();

                SqlDataReader             reader = Command.ExecuteReader();
                CompetitorTaxRateResponse result = new CompetitorTaxRateResponse();
                result.CompetitorTaxRates = new List <CompetitorTaxRate>();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result.CompetitorTaxRates.Add(new CompetitorTaxRate
                        {
                            CompetitorId   = int.Parse(reader["CompetitorId"].ToString()),
                            FYAYId         = int.Parse(reader["FYAYId"].ToString()),
                            TaxRate        = decimal.Parse(reader["TaxRate"].ToString()),
                            Description    = reader["Description"] != DBNull.Value ? reader["Description"].ToString() : null,
                            CompanyName    = reader["CompanyName"] != DBNull.Value ? reader["CompanyName"].ToString() : null,
                            AssessmentYear = reader["AssessmentYear"] != DBNull.Value ? reader["AssessmentYear"].ToString() : null,
                            FinancialYear  = reader["FinancialYear"] != DBNull.Value ? reader["FinancialYear"].ToString() : null,
                            Active         = Convert.ToBoolean(reader["Active"].ToString()),
                            Id             = Convert.ToInt32(reader["Id"].ToString())
                        });
                    }
                }
                Log.Info("End call to GetCompetitorTaxRates. Result:"
                         + JsonConvert.SerializeObject(result));
                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("Error in GetCompetitorTaxRates. Error:"
                          + JsonConvert.SerializeObject(ex));
                LogError(ex);
                throw;
            }
            finally
            {
                Connection.Close();
            }
        }