public IActionResult Delete(int id) { WeddPlan RetrievedWedding = dbContext.weddPlans.SingleOrDefault(w => w.WeddPlanId == id); dbContext.weddPlans.Remove(RetrievedWedding); dbContext.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult AddWedding(WeddPlan newWedding) { if (ModelState.IsValid) { newWedding.WeddingPlanner = (int)HttpContext.Session.GetInt32("UserId"); dbContext.weddPlans.Add(newWedding); dbContext.SaveChanges(); return(RedirectToAction("DisplayWedd", new { id = newWedding.WeddPlanId })); } return(View("NewWedding")); }
public IActionResult DisplayWedd(int id) { // List<User> AllUsers = dbContext.users.ToList(); // ViewBag.Users = AllUsers; WeddPlan theWedding = dbContext.weddPlans .Include(r => r.GuestList) .ThenInclude(u => u.User) .FirstOrDefault(w => w.WeddPlanId == id); //always need to use YOUR_API_KEY for requests. Do this in App_Start. GoogleSigned.AssignAllServices(new GoogleSigned("AIzaSyAbZ0qvAraIoYDv8iwIXXTRTqgwhvv6eso")); var request = new GeocodingRequest(); request.Address = theWedding.Address; var response = new GeocodingService().GetResponse(request); //The GeocodingService class submits the request to the API web service, and returns the //response strongly typed as a GeocodeResponse object which may contain zero, one or more results. //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); Console.WriteLine("Full Address: " + result.FormattedAddress); // "1600 Pennsylvania Ave NW, Washington, DC 20500, USA" Console.WriteLine("Latitude: " + result.Geometry.Location.Latitude); // 38.8976633 Console.WriteLine("Longitude: " + result.Geometry.Location.Longitude); // -77.0365739 Console.WriteLine(); ViewBag.Lati = result.Geometry.Location.Latitude; ViewBag.Long = result.Geometry.Location.Longitude; } else { Console.WriteLine("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } return(View("DisplayWedd", theWedding)); }