//Gets all the extra information that we have in our database about the restaurants public RestaurantDetails GetRestaurantDetails(int restaurantId) { RestaurantDetails returnRestaurantDetails = null; try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT restaurant_id, restaurant_description, restaurant_phonenumber, " + "covid_message, map_url FROM restaurant_details WHERE restaurant_id = @restaurantId", conn); cmd.Parameters.AddWithValue("@restaurantId", restaurantId); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows && reader.Read()) { returnRestaurantDetails = GetRestaurantDetailsFromReader(reader); } } } catch (SqlException) { throw; } return(returnRestaurantDetails); }
public List <RestaurantDetails> GetRestaurantDetails(string cs, int RestaurantID) { using var con = new MySqlConnection(cs); con.Open(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.Connection = con; cmd.CommandText = "spGetRestaurantDetails"; // The name of the Stored Proc cmd.CommandType = CommandType.StoredProcedure; // It is a Stored Proc cmd.Parameters.AddWithValue("@RestaurantID", RestaurantID); IList <RestaurantDetails> wsl = new List <RestaurantDetails>(); var reader = cmd.ExecuteReader(); while (reader.Read()) { var ws = new RestaurantDetails(); ws.RestaurantID = reader.GetInt32("RestaurantID"); ws.RestaurantName = reader.GetString("RestaurantName"); wsl.Add(ws); } reader.Close(); return((List <RestaurantDetails>)wsl); } }
public IViewComponentResult Invoke() { RestaurantDetails restaurantDetails = new RestaurantDetails(); restaurantDetails.AuthorFirstName = "Dheeman"; restaurantDetails.AuthorLastName = "Chakravorty"; restaurantDetails.RestaurantCount = restaurantData.GetCountOfRestaurants(); var count = restaurantData.GetCountOfRestaurants(); return(View(restaurantDetails)); }
public ActionResult <RestaurantDetails> GetRestaurantDetails(int id) { RestaurantDetails restaurantDetails = restaurantDAO.GetRestaurantDetails(id); if (restaurantDetails != null) { return(Ok(restaurantDetails)); } else { return(NotFound()); } }
private RestaurantDetails GetRestaurantDetailsFromReader(SqlDataReader reader) { RestaurantDetails rd = new RestaurantDetails() { RestaurantId = Convert.ToInt32(reader["restaurant_id"]), RestaurantDescription = Convert.ToString(reader["restaurant_description"]), RestaurantPhonenumber = Convert.ToString(reader["restaurant_phonenumber"]), CovidMessage = Convert.ToString(reader["covid_message"]), MapUrl = Convert.ToString(reader["map_url"]) }; return(rd); }
public async Task <IActionResult> Details(int id) { String cuisineChoices = (String)TempData["cuisinechoices"]; // save temp data so it can be reused if user clicks back button in browser TempData.Keep(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "api/v2.1/restaurant?res_id=" + id); String response = await APIbuilderAsync(request); RestaurantDetails restaurantDetails = RestaurantDetails.FromJson(response); return(View(restaurantDetails)); }
private Restaurants SaveRestaurantOperations(string fileBase64, MultipartFormDataStreamProvider provider) { //get restaurant details model RestaurantDetailsModel model = JsonConvert.DeserializeObject <RestaurantDetailsModel>(provider.FormData[0]); model.RestaurantThumbnail = fileBase64; Restaurants restaurant = new Restaurants() { RestaurantName = model.RestaurantName }; _restaurantOperations.AddRestaurant(ref restaurant); RestaurantAdministrators restAdmin = new RestaurantAdministrators() { RestaurantId = restaurant.RestaurantId, UserID = model.UserId }; _restaurantOperations.SaveRestaurantAdministrator(restAdmin); RestaurantLocations restLoc = new RestaurantLocations() { RestaurantCity = model.RestaurantCity, RestaurantCounty = model.RestaurantCounty, RestaurantAddress = model.RestaurantAddress, RestaurantId = restaurant.RestaurantId }; _restaurantOperations.SaveRestaurantLocation(restLoc); RestaurantDetails restDetails = Mapper.Map <RestaurantDetailsModel, RestaurantDetails>(model); restDetails.RestaurantId = restaurant.RestaurantId; restDetails.RestaurantDirectoryGuid = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), "Restaurant_" + restaurant.RestaurantId); _restaurantOperations.SaveRestaurantDetails(restDetails); RestaurantTypes restType = new RestaurantTypes() { TypeName = RestTypesEnum.RestaurantTypes[model.RestaurantTypeId], RestaurantId = restaurant.RestaurantId }; _restaurantOperations.SaveRestaurantType(restType); return(restaurant); }