예제 #1
0
        public static List<Restaurant> RecupererTous()
        {
            try
            {
                using (Context db = new Context())
                {
                    return db.Restaurants.ToList();
                }
            }

            catch (Exception e)
            {
                throw new Exception("Erreur repository : erreur de lecture de tous les restaurants", e);
            }
        }
예제 #2
0
        public static Restaurant RecupererParID(int restaurantID)
        {
            try
            {
                using (Context db = new Context())
                {
                    return db.Restaurants.First(c => c.ID == restaurantID);
                }
            }

            catch (Exception e)
            {
                throw new Exception("Erreur repository : erreur de lecture de restaurant par son ID", e);
            }
        }
예제 #3
0
 public static void Ajouter(Restaurant restaurant)
 {
     try
     {
         using (Context db = new Context())
         {
             db.Restaurants.Add(restaurant);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Erreur repository : erreur de creation de restaurant", e);
     }
 }
예제 #4
0
        public static void Supprimer(Restaurant restaurant)
        {
            try
            {
                using (Context db = new Context())
                {
                    db.Restaurants.Remove(restaurant);
                    db.SaveChanges();
                }
            }

            catch (Exception e)
            {
                throw new Exception("Erreur repository : erreur de suppression de restaurant", e);
            }
        }
 public IQueryable<NumbersHelper> GetAllNumbers()
 {
     using (var _context = new Context())
     {
         var number = (from n in _context.Numbers
                 select new NumbersHelper()
                 {
                     randomNumbersHelper = new RandomNumbersHelper()
                     {
                         Numbers = n.randomNumbers.Numbers,
                     },
                     staticNumbersHelper = new StaticNumbersHelper()
                     {
                         Numbers = n.staticNumbers.Numbers
                     }
                 });
         return number;
     }
 }
예제 #6
0
        public static void Supprimer(int restaurantId)
        {
            Restaurant restaurant = null;

            using (Context db = new Context())
            {
                Restaurant_Repo.RecupererParID(restaurantId);

                if (restaurant == null)
                    throw new Exception ("Erreur Respository : SupprimerRestaurant : ");

                    try
                    {
                        db.Restaurants.Remove(restaurant);
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Erreur repository : erreur de suppression de restaurant", e);
                    }
                }
        }