Пример #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);
        }
        public void DeletePerson(string lastName)
        {
            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson == null)
                    return;

                context.DataPersons.Remove(foundPerson);
                context.SaveChanges();
            }
        }
        public Person GetPerson(string lastName)
        {
            Person person = null;

            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson != null)
                    person = GetPersonFromDataPerson(foundPerson);
            }
            return person;
        }
Пример #4
0
        public void DeletePerson(string lastName)
        {
            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson == null)
                {
                    return;
                }

                context.DataPersons.Remove(foundPerson);
                context.SaveChanges();
            }
        }
Пример #5
0
        public Person GetPerson(string lastName)
        {
            Person person = null;

            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson != null)
                {
                    person = GetPersonFromDataPerson(foundPerson);
                }
            }
            return(person);
        }
Пример #6
0
        public IEnumerable <Person> GetPeople()
        {
            using (var ctx = new PeopleEntities())
            {
                var dataPeople = ctx.DataPersons.ToList();

                var people = new List <Person>();
                foreach (var dataPerson in dataPeople)
                {
                    people.Add(new ApplicationPerson(dataPerson));
                }

                return(people);
            }
        }
        public IEnumerable <Person> GetPeople()
        {
            using (var ctx = new PeopleEntities())
            {
                var people = from p in ctx.DataPersons
                             select new Person
                {
                    FirstName = p.FirstName,
                    LastName  = p.LastName,
                    StartDate = p.StartDate.Value,
                    Rating    = p.Rating.Value,
                };

                return(people.ToList());
            }
        }
        public IEnumerable<Person> GetPeople()
        {
            using (var ctx = new PeopleEntities())
            {
                var people = from p in ctx.DataPersons
                             select new Person
                             {
                                 FirstName = p.FirstName,
                                 LastName = p.LastName,
                                 StartDate = p.StartDate.Value,
                                 Rating = p.Rating.Value,
                             };

                return people.ToList();
            }
        }
        public void UpdatePerson(string lastName, Person updatedPerson)
        {
            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson == null)
                    return;

                foundPerson.FirstName = updatedPerson.FirstName;
                foundPerson.LastName = updatedPerson.LastName;
                foundPerson.StartDate = updatedPerson.StartDate;
                foundPerson.Rating = updatedPerson.Rating;

                context.SaveChanges();
            }
        }
Пример #10
0
        public void UpdatePerson(string lastName, Person updatedPerson)
        {
            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson == null)
                {
                    return;
                }

                foundPerson.FirstName = updatedPerson.FirstName;
                foundPerson.LastName  = updatedPerson.LastName;
                foundPerson.StartDate = updatedPerson.StartDate;
                foundPerson.Rating    = updatedPerson.Rating;

                context.SaveChanges();
            }
        }
        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();
            }
        }
Пример #12
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();
            }
        }
Пример #13
0
        public IEnumerable <Person> GetPeople()
        {
            using (var ctx = new PeopleEntities())
            {
                var dataPeople = ctx.DataPersons.ToList();

                var people = new List <Person>();
                foreach (var dataPerson in dataPeople)
                {
                    people.Add(new Person
                    {
                        FirstName = dataPerson.FirstName,
                        LastName  = dataPerson.LastName,
                        StartDate = dataPerson.StartDate.Value,
                        Rating    = dataPerson.Rating.Value,
                    });
                }

                return(people);
            }
        }
        public Person GetPerson(string lastName)
        {
            Person person = null;

            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson != null)
                {
                    person = new Person()
                    {
                        FirstName = foundPerson.FirstName,
                        LastName  = foundPerson.LastName,
                        StartDate = foundPerson.StartDate.Value,
                        Rating    = foundPerson.Rating.Value,
                    }
                }
                ;
            }
            return(person);
        }
Пример #15
0
 private DataPerson GetDataPerson(PeopleEntities context, string lastName)
 {
     throw new NotImplementedException();
 }
 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;
 }