コード例 #1
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public void DeleteMenu(Menu deletedMenu)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Menus.Attach(deletedMenu);
            context.Entry(deletedMenu).State = EntityState.Deleted;
            context.SaveChanges();
        }
コード例 #2
0
        public void DeleteRestaurant(Restaurant deletedRestaurant)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Restaurants.Attach(deletedRestaurant);
            context.Entry(deletedRestaurant).State = EntityState.Deleted;
            context.SaveChanges();
        }
コード例 #3
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public Menu UpdateMenu(Menu updatedEntity)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Menus.Attach(updatedEntity);
            context.Entry(updatedEntity).State = EntityState.Modified;
            context.SaveChanges();
            return(updatedEntity);
        }
コード例 #4
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public Menu CreateMenu(Menu newEntity)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Menus.Attach(newEntity);
            context.Entry(newEntity).State = EntityState.Added;
            context.SaveChanges();
            return(newEntity);
        }
コード例 #5
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public IQueryable <Menu> GetByRestaurantId(long restaurantId)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);
            var          query   = from sc in context.Menus
                                   where sc.RestaurantId == restaurantId
                                   select sc;

            return(query);
        }
コード例 #6
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public Menu GetById(long menuId)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);
            var          query   = from sc in context.Menus
                                   where sc.Id == menuId
                                   select sc;

            return(query.FirstOrDefault());
        }
コード例 #7
0
ファイル: MenuRepository.cs プロジェクト: marcosvape/cedro
        public IQueryable <Menu> GetAll()
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);
            var          query   = from sc in context.Menus
                                   orderby sc.Id ascending
                                   select sc;

            return(query);
        }
コード例 #8
0
        public Restaurant CreateRestaurant(Restaurant newEntity)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Restaurants.Attach(newEntity);
            context.Entry(newEntity).State = EntityState.Added;
            context.SaveChanges();
            return(newEntity);
        }
コード例 #9
0
        public Restaurant GetById(long restaurantId)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);
            var          query   = from sc in context.Restaurants
                                   where sc.Id == restaurantId
                                   select sc;

            return(query.FirstOrDefault());
        }
コード例 #10
0
        public Restaurant UpdateRestaurant(Restaurant updatedEntity)
        {
            CedroContext context = new CedroContextFactory().CreateDbContext(args);

            context.Restaurants.Attach(updatedEntity);
            context.Entry(updatedEntity).State = EntityState.Modified;
            context.SaveChanges();

            return(updatedEntity);
        }