Пример #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);
        }
Пример #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);
        }
Пример #3
0
        public void AddItem(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();
            }
        }