예제 #1
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public void AddPerson(Person person)
        {
            var db = new PhBContext();

            db.People.Add(person);
            db.SaveChanges();
        }
예제 #2
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public Person GetPerson(int id)
        {
            var db = new PhBContext();
            var q  = db.People.Include("Category").Single(p => p.PersonId == id);

            return(q);
        }
예제 #3
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public Category GetCategory(int categoryId)
        {
            var db = new PhBContext();
            var q  = db.Categories.Single(p => p.CategoryId == categoryId);

            return(q);
        }
예제 #4
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public void AddCategory(Category category)
        {
            var db = new PhBContext();

            db.Categories.Add(category);
            db.SaveChanges();
        }
예제 #5
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        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();
        }
예제 #6
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        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();
        }
예제 #7
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        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();
            }
        }
예제 #8
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        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();
            }
        }
예제 #9
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public IEnumerable <Person> GetPeople()
        {
            var db = new PhBContext();

            return(db.People);
        }
예제 #10
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public IEnumerable <Category> GetCategories()
        {
            var db = new PhBContext();

            return(db.Categories.Include("People"));
        }
예제 #11
0
파일: PhBService.cs 프로젝트: eugbor/PhBE
        public void DeleteDb()
        {
            var db = new PhBContext();

            db.Database.Delete();
        }