コード例 #1
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();
            }
        }
コード例 #2
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();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
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();
            }
        }
コード例 #6
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();
            }
        }