Пример #1
0
        int IPetCalculator.CalculateSpeed(PetBreed breed, PetQuality quality, int baseValue, int level)
        {
            var breedMultiplier   = SpeedMultipliers[breed];
            var qualityMultiplier = QualityMultipliers[quality];

            return((int)Math.Ceiling((baseValue + breedMultiplier / 10m) * level * qualityMultiplier));
        }
Пример #2
0
        public void DeletePetBreed(PetBreed breed)
        {
            if (breed == null)
                throw new ArgumentNullException("breed");

            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand("usp_DeletePetBreed", connection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure
                };

                command.Parameters.Add(new SqlParameter
                {
                    Direction = ParameterDirection.Input,
                    IsNullable = true,
                    ParameterName = "@ID",
                    SqlDbType = SqlDbType.UniqueIdentifier,
                    SqlValue = breed.ID
                });

                command.ExecuteNonQuery();
            }
        }
Пример #3
0
        public void DeletePetBreed(PetBreed breed)
        {
            if (breed == null)
            {
                throw new ArgumentNullException("breed");
            }

            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand("usp_DeletePetBreed", connection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure
                };

                command.Parameters.Add(new SqlParameter
                {
                    Direction     = ParameterDirection.Input,
                    IsNullable    = true,
                    ParameterName = "@ID",
                    SqlDbType     = SqlDbType.UniqueIdentifier,
                    SqlValue      = breed.ID
                });

                command.ExecuteNonQuery();
            }
        }
Пример #4
0
        public ActionResult GetBreeds(Guid animalId)
        {
            var breeds = from breed in PetBreed.GetBreeds(null, animalId, null)
                         orderby breed.Name ascending
                         select new { value = breed.ID, text = breed.Name };

            return(Json(breeds, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
 public PetAnimal(string name       = "Unknow",
                  PetBreed petBreed = null,
                  PetCharacteristics petCharacteristics = null)
 {
     Name = name;
     PetCharacteristics = petCharacteristics ?? new();
     PetBreed           = petBreed ?? new(DefaultPetBreed.Id);
 }
Пример #6
0
        public void InsertPetBreed(PetBreed breed)
        {
            if (breed == null)
            {
                throw new ArgumentNullException("breed");
            }

            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand("usp_InsertPetBreed", connection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure
                };

                FillCommand(command, breed);

                command.ExecuteNonQuery();
            }
        }
Пример #7
0
 internal void DeletePetBreed(PetBreed breed)
 {
     container.Resolve<IPetMatchRepository>().DeletePetBreed(breed);
 }
Пример #8
0
 internal void InsertPetBreed(PetBreed breed)
 {
     container.Resolve<IPetMatchRepository>().InsertPetBreed(breed);
 }
Пример #9
0
 public void Update(PetBreed petBreed)
 {
     _petBreedDal.Update(petBreed);
 }
Пример #10
0
 public void Add(PetBreed petBreed)
 {
     _petBreedDal.Add(petBreed);
 }
Пример #11
0
 private void FillCommand(SqlCommand command, PetBreed breed)
 {
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = false,
         ParameterName = "@ID",
         SqlDbType = SqlDbType.UniqueIdentifier,
         SqlValue = breed.ID
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = false,
         ParameterName = "@Name",
         SqlDbType = SqlDbType.NVarChar,
         Size = 100,
         SqlValue = breed.Name
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = true,
         ParameterName = "@DateCreated",
         SqlDbType = SqlDbType.DateTime,
         SqlValue = breed.DateCreated
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = true,
         ParameterName = "@CreatedBy",
         SqlDbType = SqlDbType.NVarChar,
         Size = 512,
         SqlValue = breed.CreatedBy
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = true,
         ParameterName = "@LastUpdated",
         SqlDbType = SqlDbType.DateTime,
         SqlValue = breed.LastUpdated
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = true,
         ParameterName = "@LastUpdatedBy",
         SqlDbType = SqlDbType.NVarChar,
         Size = 512,
         SqlValue = breed.LastUpdatedBy
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction = ParameterDirection.Input,
         IsNullable = false,
         ParameterName = "@Visible",
         SqlDbType = SqlDbType.Bit,
         SqlValue = breed.Visible
     });
 }
Пример #12
0
        public void UpdatePetBreed(PetBreed breed)
        {
            if (breed == null)
                throw new ArgumentNullException("breed");

            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand("usp_UpdatePetBreed", connection)
                {
                    CommandType = System.Data.CommandType.StoredProcedure
                };

                FillCommand(command, breed);

                command.ExecuteNonQuery();
            }
        }
Пример #13
0
 private void FillCommand(SqlCommand command, PetBreed breed)
 {
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = false,
         ParameterName = "@ID",
         SqlDbType     = SqlDbType.UniqueIdentifier,
         SqlValue      = breed.ID
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = false,
         ParameterName = "@Name",
         SqlDbType     = SqlDbType.NVarChar,
         Size          = 100,
         SqlValue      = breed.Name
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = true,
         ParameterName = "@DateCreated",
         SqlDbType     = SqlDbType.DateTime,
         SqlValue      = breed.DateCreated
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = true,
         ParameterName = "@CreatedBy",
         SqlDbType     = SqlDbType.NVarChar,
         Size          = 512,
         SqlValue      = breed.CreatedBy
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = true,
         ParameterName = "@LastUpdated",
         SqlDbType     = SqlDbType.DateTime,
         SqlValue      = breed.LastUpdated
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = true,
         ParameterName = "@LastUpdatedBy",
         SqlDbType     = SqlDbType.NVarChar,
         Size          = 512,
         SqlValue      = breed.LastUpdatedBy
     });
     command.Parameters.Add(new SqlParameter
     {
         Direction     = ParameterDirection.Input,
         IsNullable    = false,
         ParameterName = "@Visible",
         SqlDbType     = SqlDbType.Bit,
         SqlValue      = breed.Visible
     });
 }