Exemple #1
0
        public CareTakerSettings UpdateCareTaker(CareTakerSettings careTaker)
        {
            using (SqlConnection conn = new SqlConnection(this.connectionString))
            {
                conn.Open();


                // Address insert done first
                SqlCommand cmd = new SqlCommand("dbo.updateCareTaker", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@caretaker_id", careTaker.CareTakerId);
                cmd.Parameters.AddWithValue("@street", careTaker.Address.Street);
                cmd.Parameters.AddWithValue("@city", careTaker.Address.City);
                cmd.Parameters.AddWithValue("@state", careTaker.Address.State);
                cmd.Parameters.AddWithValue("@zip", careTaker.Address.Zip);
                cmd.Parameters.AddWithValue("@county", careTaker.Address.County);
                cmd.Parameters.AddWithValue("@country", careTaker.Address.Country);
                cmd.Parameters.AddWithValue("@first_name", careTaker.FirstName);
                cmd.Parameters.AddWithValue("@last_name", careTaker.LastName);
                cmd.Parameters.AddWithValue("@email_address", careTaker.EmailAddress);
                cmd.Parameters.AddWithValue("@phone_number", careTaker.PhoneNumber);

                // Finally, executes the caretaker insert
                careTaker.CareTakerId = Convert.ToInt32(cmd.ExecuteScalar());

                return(careTaker);
            }
        }
Exemple #2
0
        public void TestUpdateCareTaker()
        {
            // Arrange
            CareTakerSqlDAO   dao           = new CareTakerSqlDAO(this.connectionString);
            CareTakerSettings testCareTaker = new CareTakerSettings()
            {
                CareTakerId  = ruth,
                AddressId    = berkshire,
                FirstName    = "Ru",
                LastName     = "Howie",
                EmailAddress = "askdfja",
                PhoneNumber  = "342342432",
            };

            testCareTaker.Address.Street  = "34243243";
            testCareTaker.Address.City    = "sdlktgj";
            testCareTaker.Address.State   = "akedgihj";
            testCareTaker.Address.Zip     = 324234;
            testCareTaker.Address.County  = "asf";
            testCareTaker.Address.Country = "ertwseg";

            // Act
            dao.UpdateCareTaker(testCareTaker);
            CareTaker careTaker = dao.GetCareTakerById(ruth);


            // Assert
            Assert.AreEqual("Ru", careTaker.FirstName);
        }
        public ActionResult <CareTakerSettings> UpdateCareTaker(CareTakerSettings careTaker)
        {
            CareTaker careTakerCheck = careTakerDao.GetCareTakerById(userId);

            if (careTakerCheck == null)
            {
                return(NotFound());
            }

            careTaker.CareTakerId = userId;
            return(Created($"api/caretakers/{careTaker.CareTakerId}", careTakerDao.UpdateCareTaker(careTaker)));
        }