/// <summary>
        /// FirstName, LastName and Email must have a value. Email must not exist already.
        /// </summary>
        /// <param name="newPerson"></param>
        private void CheckDataValidity(PersonAddressModel newPerson)
        {
            List <PersonAddressModel> savedPeople = _dataAccess.LoadData <PersonAddressModel>(SQLProceedures.LoadPeopleAddresses());

            foreach (PersonAddressModel savedPerson in savedPeople)
            {
                if (newPerson.FirstName == "")
                {
                    throw new Exception("First name is required");
                }
                if (newPerson.LastName == "")
                {
                    throw new Exception("Last name is required");
                }
                if (savedPerson.Email == "" || savedPerson.Email == newPerson.Email)
                {
                    throw new Exception("Email already exists", null);
                }
            }
        }
 public void SavePerson(PersonAddressModel person)
 {
     CheckDataValidity(person);
     _dataAccess.SaveData(SQLProceedures.SavePersonAddress(), person);
 }
 public void DeletePersonFromDB(string email)
 {
     _dataAccess.DeleteData(SQLProceedures.DeletePerson(), new { Email = email });
 }
 public IEnumerable <PersonAddressModel> GetPeopleAddresses()
 {
     return(_dataAccess.LoadData <PersonAddressModel>(SQLProceedures.LoadPeopleAddresses()));
 }