Esempio n. 1
0
 public ActionResult AddLocation(Location i_location)
 {
     if (ModelState.IsValid)
     {
         using (Context con = new Context())
         {
             con.Locations.Add(i_location);
             con.SaveChanges();
         }
         return RedirectToAction("DisplayAllLocation");
     }
     return View(i_location);
 }
Esempio n. 2
0
 public ActionResult Delete(Location i_locationId )
 {
     using (Context con = new Context())
     {
         Location loactionToRemove= GetLocationById(i_locationId.Id);
         if (loactionToRemove != null)
         {
             con.Locations.Attach(loactionToRemove);
             con.Locations.Remove(loactionToRemove);
             con.SaveChanges();
         }
     }
     return RedirectToAction("DisplayAllLocation");
 }
Esempio n. 3
0
 public ActionResult Edit(Location i_location)
 {
     if (Request.HttpMethod== "POST")
     {
         using (Context con = new Context())
         {
             Location loc = con.Locations.Where(l => l.Id == i_location.Id).FirstOrDefault();
             if (loc !=null )
             {
                 loc.Addreass = i_location.Addreass;
                 loc.Latitude = i_location.Latitude;
                 loc.Longitude = i_location.Longitude;
             }
             con.SaveChanges();
             return RedirectToAction("DisplayAllLocation");
         }
     }
     Location location = GetLocationById(i_location.Id);
     return View(location);
 }
Esempio n. 4
0
 public ActionResult Details(Location i_locationId)
 {
     Location location = GetLocationById(i_locationId.Id);
     return View(location);
 }
Esempio n. 5
0
 public ActionResult AddLocation()
 {
     Location location = new Location();
     return View(location);
 }