예제 #1
0
        private void CheckValidations(InformationCapture person)
        {
            if (string.IsNullOrEmpty(person.FirstName))
            {
                throw new ArgumentNullException("First Name", "Please enter FirstName");
            }
            else if (string.IsNullOrEmpty(person.LastName))
            {
                throw new ArgumentNullException("Last Name", "Please enter LastName");
            }

            else if (string.IsNullOrEmpty(person.Email))
            {
                throw new ArgumentNullException("Email", "Please enter Email");
            }
        }
예제 #2
0
        internal void Update(InformationCapture updatedPerson)
        {
            CheckValidations(updatedPerson);
            if (updatedPerson.Id > 0)
            {
                InformationCapture selectedPerson = _dbContext.Person.First(p => p.Id == updatedPerson.Id);
                selectedPerson.FirstName       = updatedPerson.FirstName;
                selectedPerson.LastName        = updatedPerson.LastName;
                selectedPerson.CityOfResidence = updatedPerson.CityOfResidence;
                // selectedPerson.Profession = updatedPerson.Profession;
                selectedPerson.Email = updatedPerson.Email;
            }
            else
            {
                _dbContext.Person.Add(updatedPerson);
            }

            _dbContext.SaveChanges();
        }
예제 #3
0
 internal void Delete(InformationCapture person)
 {
     _dbContext.Person.Remove(person);
 }