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); } }
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; } }
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); }
public static RestaurantModelDTO Create(TblRestaurant restaurant) { return(new RestaurantModelDTO() { Id = restaurant.Id, Name = restaurant.Name, City = restaurant.City }); }
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); }