public ActionResult editlodge(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lodges lodge = db.Lodges.Find(id); Addresses adres = db.Addresses.Find(lodge.AdresId); AddLodgeViewModels addLodge = new AddLodgeViewModels { City = adres.City, Streed = adres.Streed, PostCode = adres.PostCode, HouseNumber = adres.HouseNumber, Counrty = adres.Counrty, State = adres.State, Code = lodge.Code, LodgeID = lodge.LodgeId, AddresID = lodge.AdresId, LodgeTypeId = lodge.LodgeTypeId, Disabled = lodge.Disabled }; return(View(addLodge)); }
public IActionResult Lodges() { APIHandler webHandler = new APIHandler(); Lodges lodges = webHandler.GetLodges(); return(View()); }
public ActionResult DeleteConfirmed(int id) { Lodges lodges = db.Lodges.Find(id); db.Lodges.Remove(lodges); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "LodgeID,LodgeTypeID,LodgeNR,LodgeNaam,Bezettingsgraad")] Lodges lodges) { if (ModelState.IsValid) { db.Entry(lodges).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LodgeTypeID = new SelectList(db.LodgeTypes, "LodgeTypeID", "LodgeTypeNaam", lodges.LodgeTypeID); return(View(lodges)); }
// GET: Lodges/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lodges lodges = db.Lodges.Find(id); if (lodges == null) { return(HttpNotFound()); } return(View(lodges)); }
// GET: Lodges/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lodges lodges = db.Lodges.Find(id); if (lodges == null) { return(HttpNotFound()); } ViewBag.LodgeTypeID = new SelectList(db.LodgeTypes, "LodgeTypeID", "LodgeTypeNaam", lodges.LodgeTypeID); return(View(lodges)); }
public ActionResult editlodgeapply(AddLodgeViewModels model) { ViewBag.lodges = db.Lodges.ToList(); if (ModelState.IsValid) { Addresses oldadress = db.Addresses.Find(model.AddresID); oldadress.HouseNumber = model.HouseNumber; oldadress.PostCode = model.PostCode; oldadress.Streed = model.Streed; Lodges oldLodge = db.Lodges.Find(model.LodgeID); oldLodge.Disabled = model.Disabled; db.Entry(oldLodge).State = EntityState.Modified; db.Entry(oldadress).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("lodge")); }
public ActionResult Addlodgessubmit(AddLodgeViewModels model, string LodgeTypes) { if (ModelState.IsValid) { var adress = new Addresses { PostCode = model.PostCode, Streed = model.Streed, HouseNumber = model.HouseNumber, City = "Ubud", Counrty = "Bali", State = "Bali" }; db.Addresses.Add(adress); db.SaveChanges(); Lodges lodges = new Lodges { Code = model.Code, AdresId = (from n in db.Addresses orderby n.AdresId descending select n.AdresId).First(), LodgeTypeId = Convert.ToInt32(LodgeTypes) }; db.Lodges.Add(lodges); db.SaveChanges(); } return(RedirectToAction("lodge")); }
/// <summary> /// Method to receive data from API end point as a collection of objects /// /// JsonConvert parses the JSON string into classes /// </summary> /// <returns></returns> /// public Lodges GetLodges() { string NEW_ORLEANS_API_PATH = BASE_URL; string lodgesData = ""; Lodges lodges = null; httpClient.BaseAddress = new Uri(NEW_ORLEANS_API_PATH); try { HttpResponseMessage response = httpClient.GetAsync(NEW_ORLEANS_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { lodgesData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!lodgesData.Equals("")) { // JsonConvert is part of the NewtonSoft.Json Nuget package lodges = JsonConvert.DeserializeObject <Lodges>(lodgesData); } } catch (Exception e) { // This is a useful place to insert a breakpoint and observe the error message Console.WriteLine(e.Message); } return(lodges); }