//Create new Restaurant public void CreateNewRestaurant(Restaurant restaurant) { _logger.LogInformation($"Creating new Restaurant"); _dbContext.Restaurant.Add(restaurant); if (restaurant.Member.MemberEmail.Any() && restaurant.Member.MemberPassword.Any()) { RestaurantMember memberDTO = new RestaurantMember() { RestaurantEmail = restaurant.Member.MemberEmail, RestaurantPassword = restaurant.Member.MemberPassword }; _dbContext.SaveChanges(); } if (restaurant.Location.Any()) { foreach (var location in restaurant.Location) { RestaurantLocation restaurantLocation = new RestaurantLocation { City = location.CityName, Address = location.AddressName }; _dbContext.SaveChanges(); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,RestaurantId,Address,OpeningTime,ClosingTime")] RestaurantLocation restaurantLocation) { if (id != restaurantLocation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(restaurantLocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantLocationExists(restaurantLocation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "RestaurantLocations", new { id = restaurantLocation.RestaurantId, name = _context.Restaurant.Where(c => c.Id == restaurantLocation.RestaurantId).FirstOrDefault().Name })); } ViewData["RestaurantId"] = new SelectList(_context.Restaurant, "Id", "Name", restaurantLocation.RestaurantId); return(View(restaurantLocation)); }
public async Task <IActionResult> Create(int restaurantId, [Bind("Id,RestaurantId,Address,OpeningTime,ClosingTime")] RestaurantLocation restaurantLocation) { restaurantLocation.RestaurantId = restaurantId; if (ModelState.IsValid) { _context.Add(restaurantLocation); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "RestaurantLocations", new { id = restaurantId, name = _context.Restaurant.Where(c => c.Id == restaurantId).FirstOrDefault().Name })); } return(View(restaurantLocation)); }
public void LoadData() { // Load data from Firebase platform and store // into list var firebase = new FirebaseClient(FirebaseURL); var items = firebase.Child("locations") .OnceAsync <RestaurantLocation>().Result; restaurantList.Clear(); foreach (var item in items) { RestaurantLocation restaurant = new RestaurantLocation(); restaurant.id = item.Key; restaurant.latitude = item.Object.latitude; restaurant.longitude = item.Object.longitude; restaurant.title = item.Object.title; restaurantList.Add(restaurant); } }