예제 #1
0
 public static IEnumerable <Customer> GetAll()
 {
     using (var context = new HomeCornerContext())
     {
         return(context.Customers.Include("Customer").ToList());
     }
 }
예제 #2
0
 public static Customer GetById(int Id)
 {
     using (var context = new HomeCornerContext())
     {
         return(context.Customers.Include("Customer").SingleOrDefault(m => m.Id == Id));
     }
 }
예제 #3
0
 public static House GetById(int Id)
 {
     using (var context = new HomeCornerContext())
     {
         return(context.Houses.Include("House").SingleOrDefault(m => m.Id == Id));
     }
 }
예제 #4
0
 public static IEnumerable <House> GetAll()
 {
     using (var context = new HomeCornerContext())
     {
         return(context.Houses.Include("House").ToList());
     }
 }
예제 #5
0
 public static void Add(Customer customer)
 {
     using (var context = new HomeCornerContext())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
     }
 }
예제 #6
0
 public static void Add(House house)
 {
     using (var context = new HomeCornerContext())
     {
         context.Houses.Add(house);
         context.SaveChanges();
     }
 }
예제 #7
0
 public static void Delete(int id)
 {
     using (var context = new HomeCornerContext())
     {
         Customer customer = context.Customers.Find(id);
         context.Customers.Remove(customer);
         context.SaveChanges();
     }
 }
예제 #8
0
 public static void Delete(int id)
 {
     using (var context = new HomeCornerContext())
     {
         House house = context.Houses.Find(id);
         context.Houses.Remove(house);
         context.SaveChanges();
     }
 }
예제 #9
0
 public static void Update(Customer customer)
 {
     using (var context = new HomeCornerContext())
     {
         Customer customerToUpdate = context.Customers.Find(customer.Id);
         customer.Id              = customer.Id;
         customerToUpdate.Name    = customer.Name;
         customerToUpdate.Address = customer.Address;
         context.SaveChanges();
     }
 }
예제 #10
0
        public static void Update(House house)
        {
            using (var context = new HomeCornerContext())
            {
                House houseToUpdate = context.Houses.Find(house.Id);
                house.Id            = house.Id;
                houseToUpdate.Title = house.Title;

                context.SaveChanges();
            }
        }