public async Task <IActionResult> Edit(int id, [Bind("DrinkEnthusiastId,FirstName,LastName,Address,City,State,Zipcode,CheckInStatus,ApplicationId")] DrinkEnthusiast drinkEnthusiast) { if (id != drinkEnthusiast.DrinkEnthusiastId) { return(NotFound()); } if (ModelState.IsValid) { try { _db.Update(drinkEnthusiast); await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DrinkEnthusiastExists(drinkEnthusiast.DrinkEnthusiastId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationId"] = new SelectList(_db.Set <ApplicationUser>(), "Id", "Id", drinkEnthusiast.ApplicationId); return(View(drinkEnthusiast)); }
public async Task <IActionResult> Create([Bind("DrinkEnthusiastId,FirstName,LastName,Address,City,State,Zipcode,ApplicationId")] DrinkEnthusiast drinkEnthusiast, ApplicationUser applicationUser) { applicationUser = new ApplicationUser(); if (ModelState.IsValid) { _db.Add(drinkEnthusiast); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationId"] = new SelectList(_db.Set <ApplicationUser>(), "Id", "Id", drinkEnthusiast.ApplicationId); return(View(drinkEnthusiast)); }
//public async Task<IActionResult> GetStatistics() //{ // PossibleCustomers(drinkEnthusiast); //} public ActionResult PossibleCustomers(DrinkEnthusiast drinkEnthusiast) //when people click the the check in box, the potential customers property in bar model will increment { //the method will be a bool, if checked = true else = false, if true add, else leave it alone ViewBag.CheckInStatus = drinkEnthusiast.CheckInStatus; if (drinkEnthusiast.CheckInStatus == true) { IncrementPossibleCustomers(barOwner); } else { return(RedirectToAction("Index", "Home")); } return(View("Index")); }
public async Task <IActionResult> ApiCall([Bind("Id, FirstName, LastName, Address, Latitude, Longitude, City, State, Zipcode")] DrinkEnthusiast drinkEnthusiast) { if (ModelState.IsValid) { // api call //get the long and lat //add long and lat to drinkConsumers string apiCall = "https://maps.googleapis.com/maps/api/geocode/json?address=" + AddPluses(drinkEnthusiast.Address) + ",+" + AddPluses(drinkEnthusiast.City) + ",+" + AddPluses(drinkEnthusiast.State) + "&key=AIzaSyAY94W50Ro6315b5RFNT3TTUKMd3DsUrEU"; HttpClient client = new HttpClient(); //make a request for api call set up base address url client.BaseAddress = new Uri(apiCall); HttpResponseMessage response = await client.GetAsync(apiCall); LocationInfo location = JsonConvert.DeserializeObject <LocationInfo>(await response.Content.ReadAsStringAsync()); //drinkEnthusiast.Latitude = location.Results[0].Geometry.Location.Lat.ToString(); //drinkEnthusiast.Longitude = location.Results[0].Geometry.Location.Lng.ToString(); _db.Add(drinkEnthusiast); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(drinkEnthusiast)); }
public BarOwnersController(ApplicationDbContext db) { _db = db; drinkEnthusiast = new DrinkEnthusiast(); }