Exemple #1
0
        private DataPerson GetDataPerson(PeopleEntities context, string lastName)
        {
            DataPerson foundPerson = null;

            foundPerson = (from p in context.DataPersons
                           where p.LastName == lastName
                           select p).FirstOrDefault();
            return(foundPerson);
        }
Exemple #2
0
        private Person GetPersonFromDataPerson(DataPerson dataPerson)
        {
            var person = new Person()
            {
                FirstName = dataPerson.FirstName,
                LastName  = dataPerson.LastName,
                StartDate = dataPerson.StartDate.Value,
                Rating    = dataPerson.Rating.Value,
            };

            return(person);
        }
        public void AddPerson(Person newPerson)
        {
            using (var context = new PeopleEntities())
            {
                if (GetDataPerson(context, newPerson.LastName) != null)
                    return;

                var person = new DataPerson()
                {
                    FirstName = newPerson.FirstName,
                    LastName = newPerson.LastName,
                    StartDate = newPerson.StartDate,
                    Rating = newPerson.Rating,
                };
                context.DataPersons.Add(person);
                context.SaveChanges();
            }
        }
Exemple #4
0
        public void AddPerson(Person newPerson)
        {
            using (var context = new PeopleEntities())
            {
                if (GetDataPerson(context, newPerson.LastName) != null)
                {
                    return;
                }

                var person = new DataPerson()
                {
                    FirstName = newPerson.FirstName,
                    LastName  = newPerson.LastName,
                    StartDate = newPerson.StartDate,
                    Rating    = newPerson.Rating,
                };
                context.DataPersons.Add(person);
                context.SaveChanges();
            }
        }
Exemple #5
0
 private Person GetPersonFromDataPerson(DataPerson dataPerson)
 {
     throw new NotImplementedException();
 }
 private Person GetPersonFromDataPerson(DataPerson dataPerson)
 {
     var person = new Person()
     {
         FirstName = dataPerson.FirstName,
         LastName = dataPerson.LastName,
         StartDate = dataPerson.StartDate.Value,
         Rating = dataPerson.Rating.Value,
     };
     return person;
 }