Пример #1
0
        public void DeleteRestaurant(ModelLibrary.Restaurant restaurant)
        {
            var db = new JustFeastDbDataContext();

            db.Restaurants.DeleteOnSubmit(RestaurantCtrl.ConvertRestaurantToDatabase(restaurant));
            db.SubmitChanges();
        }
Пример #2
0
        public void CreateRestaurant(ModelLibrary.Restaurant restaurant)
        {
            JustFeastDbDataContext db = new JustFeastDbDataContext();
            var res = RestaurantCtrl.ConvertRestaurantToDatabase(restaurant);

            if (restaurant.Category != null)
            {
                res.ResCat = db.ResCats.FirstOrDefault(x => x.id == restaurant.Category.Id);
            }
            db.Restaurants.InsertOnSubmit(res);
            db.SubmitChanges();
        }
Пример #3
0
        public void UpdateRestaurant(ModelLibrary.Restaurant restaurant)
        {
            var db  = new JustFeastDbDataContext();
            var res = db.Restaurants.FirstOrDefault(x => x.id == restaurant.Id);

            var mRes = RestaurantCtrl.ConvertRestaurantToDatabase(restaurant);

            res.name         = mRes.name;
            res.phoneNo      = mRes.phoneNo;
            res.verified     = mRes.verified;
            res.zipcode      = mRes.zipcode;
            res.address      = mRes.address;
            res.discontinued = mRes.discontinued;
            res.email        = mRes.email;
            res.resCatId     = mRes.resCatId;

            db.SubmitChanges();
        }