Exemplo n.º 1
0
        public Company GetById(int id)
        {
            Company company = null;
            var connectionString = ConfigurationManager.ConnectionStrings["appDatabase"].ConnectionString;

            using (var connection = new SqlConnection(connectionString))
            {
                var command = new SqlCommand
                {
                    Connection = connection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "uspGetCompanyById"
                };

                var parameter = new SqlParameter("@CompanyId", SqlDbType.Int) { Value = id };
                command.Parameters.Add(parameter);

                connection.Open();
                var reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    company = new Company
                                      {
                                          Id = int.Parse(reader["CompanyId"].ToString()),
                                          Name = reader["Name"].ToString(),
                                          Classification = (Classification)int.Parse(reader["ClassificationId"].ToString())
                                      };
                }
            }

            return company;
        }
Exemplo n.º 2
0
        public virtual void TestSetup()
        {
            ValidCustomer = InitialiseCustomer.InitCustomer("John", "Doe", "*****@*****.**", new DateTime(1979, 08, 30));
            InvalidCustomerAge = InitialiseCustomer.InitCustomer("John", "Doe", "*****@*****.**", new DateTime(1999, 08, 30));
            InvalidCustomerEmail = InitialiseCustomer.InitCustomer("John", "Doe", "email", new DateTime(1979, 08, 30));
            InvalidCustomerFirstName = InitialiseCustomer.InitCustomer(string.Empty, "Doe", "email.com", new DateTime(1979, 08, 30));
            InvalidCustomerLastName = InitialiseCustomer.InitCustomer("John", string.Empty, "email.com", new DateTime(1979, 08, 30));
            InvalidCustomerFirstNameAndLastName = InitialiseCustomer.InitCustomer(string.Empty, string.Empty, "email.com", new DateTime(1979, 08, 30));

            GoldCompany = new Company { Classification = Classification.Gold, Id  =1, Name = "GoldCompany" };
            SilverCompany = new Company { Classification = Classification.Silver, Id = 2, Name = "SilverCompany" };
            BrozneCompany = new Company { Classification = Classification.Bronze, Id = 3, Name = "BronzeCompany" };
        }