Пример #1
0
        public void AddPerson(Person person)
        {
            var db = new PhBContext();

            db.People.Add(person);
            db.SaveChanges();
        }
Пример #2
0
        public void AddCategory(Category category)
        {
            var db = new PhBContext();

            db.Categories.Add(category);
            db.SaveChanges();
        }
Пример #3
0
        public void UpdatePerson(int id, Person person)
        {
            var db      = new PhBContext();
            var operson = db.People.Single(p => p.PersonId == id);

            operson.Name        = person.Name;
            operson.PhoneNumber = person.PhoneNumber;
            db.SaveChanges();
        }
Пример #4
0
        public void UpdateCategory(int id, Category category)
        {
            var db        = new PhBContext();
            var ocategory = db.Categories.Single(c => c.CategoryId == id);

            ocategory.Name = category.Name;

            db.SaveChanges();
        }
Пример #5
0
        public void DeletePerson(int personId)
        {
            var db     = new PhBContext();
            var person = db.People.SingleOrDefault(p => p.PersonId == personId);

            if (person != null)
            {
                db.People.Remove(person);
                db.SaveChanges();
            }
        }
Пример #6
0
        public void DeleteCategory(int categoryId)
        {
            var db       = new PhBContext();
            var category = db.Categories.SingleOrDefault(c => c.CategoryId == categoryId);

            if (category != null)
            {
                db.Categories.Remove(category);
                db.SaveChanges();
            }
        }