Пример #1
0
 public void Add(Review model)
 {
     using (var dbcontext = new ResturantDBEntities())
     {
         dbcontext.Reviews.Add(model);
         dbcontext.SaveChanges();
     }
 }
 public void addResturant(Models.Resturant model)
 {
     using (var dbcontext = new ResturantDBEntities())
     {
         dbcontext.Resturants.Add(ModelToData(model));
         dbcontext.SaveChanges();
     }
 }
Пример #3
0
 public void Delete(Resturant model)
 {
     using (var dbcontext = new ResturantDBEntities())
     {
         dbcontext.Resturants.Attach(model);
         dbcontext.Resturants.Remove(model);
         dbcontext.SaveChanges();
     }
 }
Пример #4
0
        public IEnumerable <Review> GetReviews()
        {
            IEnumerable <Review> reviewEntities;

            using (var dbcontext = new ResturantDBEntities())
            {
                reviewEntities = dbcontext.Reviews.ToList();
            }
            return(reviewEntities.ToList());
        }
        public IEnumerable <Models.Resturant> GetResturants()
        {
            IEnumerable <Models.Resturant> result;

            using (var dbcontext = new ResturantDBEntities())
            {
                var entities = dbcontext.Resturants.ToList();
                result = entities.Select(x => DataToModel(x)).ToList();
            }
            return(result.ToList());
        }
Пример #6
0
 public void Update(Review model)
 {
     using (var dbcontext = new ResturantDBEntities())
     {
         foreach (var rev in dbcontext.Reviews)
         {
             if (rev.rv_id == model.rv_id)
             {
                 rev.Author  = model.Author;
                 rev.Rating  = model.Rating;
                 rev.Comment = model.Comment;
             }
         }
         dbcontext.SaveChanges();
     }
 }
Пример #7
0
 public void Update(Resturant model)
 {
     using (var dbcontext = new ResturantDBEntities())
     {
         foreach (var res in dbcontext.Resturants)
         {
             if (res.rs_id == model.rs_id)
             {
                 res.Name     = model.Name;
                 res.Address  = model.Address;
                 res.City     = model.City;
                 res.State    = model.State;
                 res.FoodType = model.FoodType;
                 break;
             }
         }
         dbcontext.SaveChanges();
     }
 }
Пример #8
0
        public IEnumerable <Resturant> GetResturants()
        {
            // This function takes a long time to run to completion.  Why?
            IEnumerable <Resturant> result;

            using (var dbcontext = new ResturantDBEntities())
            {
                int i        = 0;
                var entities = dbcontext.Resturants.ToList();
                // due to Lazy loading, the Reviews seem to have to
                // be explictly loaded ???
                foreach (var ent in dbcontext.Resturants)
                {
                    entities[i].Reviews = ent.Reviews.ToList();
                    i++;
                }
                result = entities.ToList();
            }
            return(result.ToList());
        }