コード例 #1
0
        public TblRestaurant GetResturantDetails(int restaurantID)
        {
            TblRestaurant resturantInformation = new TblRestaurant();

            try
            {
                if (db != null)
                {
                    resturantInformation = (from restaurant in db.TblRestaurant
                                            join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                            where restaurant.Id == restaurantID
                                            select new TblRestaurant
                    {
                        Id = restaurant.Id,
                        Name = restaurant.Name,
                        Address = restaurant.Address,
                        ContactNo = restaurant.ContactNo,
                        TblLocation = location,
                        CloseTime = restaurant.CloseTime,
                        OpeningTime = restaurant.OpeningTime,
                        Website = restaurant.Website
                    }).FirstOrDefault();
                }

                return(resturantInformation);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
コード例 #2
0
 public RestaurantInformation GetResturantDetails(int restaurantID)
 {
     try
     {
         TblRestaurant restaurant = new TblRestaurant();
         restaurant = search_Repository.GetResturantDetails(restaurantID);
         RestaurantInformation resturant_Information = new RestaurantInformation
         {
             restaurant_ID        = restaurant.Id,
             restaurant_Name      = restaurant.Name,
             restaurant_Address   = restaurant.Address,
             restaurant_ContactNo = restaurant.ContactNo,
             closing_Time         = restaurant.CloseTime,
             opening_Time         = restaurant.OpeningTime,
             website = restaurant.Website,
             xaxis   = (double)restaurant.TblLocation.X,
             yaxis   = (double)restaurant.TblLocation.Y
         };
         return(resturant_Information);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        public void GetReviewsandRatings()
        {
            var options = new DbContextOptionsBuilder <RestaurantManagementContext>()
                          .UseInMemoryDatabase(databaseName: "ReviewManagement")
                          .Options;
            RestaurantManagementContext context          = new RestaurantManagementContext(options);
            TblRatingandReviews         ratingandReviews = new TblRatingandReviews
            {
                Id              = 1,
                Rating          = 5,
                Reviews         = "Amazing",
                TblRestaurantId = 3
            };

            context.TblRatingandReviews.Add(ratingandReviews);
            TblRestaurant tblRestaurant = new TblRestaurant
            {
                Id   = 3,
                Name = "Frotinar"
            };

            context.TblRestaurant.Add(tblRestaurant);
            ReviewRepository reviewRepository = new ReviewRepository(context);
            var restaurantratings             = reviewRepository.GetRestaurantRating("Frotinar");

            Assert.NotNull(restaurantratings);
        }
コード例 #4
0
 public static RestaurantModelDTO Create(TblRestaurant restaurant)
 {
     return(new RestaurantModelDTO()
     {
         Id = restaurant.Id,
         Name = restaurant.Name,
         City = restaurant.City
     });
 }
コード例 #5
0
        public RestaurantModelDTO AddRestaurant(RestaurantModelDTO newRestaurant)
        {
            RestaurantModelDTO ret = null;

            using (var db = new RestaurantReviewsContext())
            {
                TblRestaurant restaurant = ModelFactory.Create(newRestaurant);
                db.TblRestaurant.Add(restaurant);
                db.SaveChanges();
                ret = ModelFactory.Create(restaurant);
            }

            return(ret);
        }