예제 #1
0
        // GET: Branchs
        public ActionResult Index()
        {
            Context con = new Context();
            Branch bb = con.Branchs.Where(b => b.Id == 1).First();

            return View(con.Branchs);
        }
예제 #2
0
 public ActionResult AddCarType(CarType i_carType)
 {
     using (Context con = new Context())
     {
         con.CarTypes.Add(i_carType);
         con.SaveChanges();
     }
     return RedirectToAction("index");
 }
예제 #3
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);
 }
예제 #4
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");
 }
예제 #5
0
 public ActionResult Delete(CarType i_carType)
 {
     using (Context context = new Context())
     {
         CarType carTypeToDelete = context.CarTypes.Where(ct => ct.Id == i_carType.Id).FirstOrDefault();
         if (carTypeToDelete != null)
         {
             context.CarTypes.Attach(carTypeToDelete);
             context.CarTypes.Remove(carTypeToDelete);
             context.SaveChanges();
         }
     }
     return RedirectToAction("index");
 }
예제 #6
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);
 }
예제 #7
0
 public ActionResult Edit(CarType i_carType)
 {
     if (Request.HttpMethod == "POST")
     {
         using (Context con = new Context())
         {
             CarType carTypeToChange = con.CarTypes.Where(c => c.Id == i_carType.Id).FirstOrDefault();
             if (carTypeToChange != null)
             {
                 carTypeToChange.DailyCost = i_carType.DailyCost;
                 carTypeToChange.DelayDailyCost = i_carType.DelayDailyCost;
                 carTypeToChange.GearBox = i_carType.GearBox;
                 carTypeToChange.Manufacturer = i_carType.Manufacturer;
                 carTypeToChange.Model = i_carType.Model;
             }
             con.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     CarType carT = GetCarTypeById(i_carType.Id);
     return View(carT);
 }
예제 #8
0
 private Location GetLocationById(int i_locationId)
 {
     using (Context con = new Context())
     {
         Location location = con.Locations.Where(l => l.Id == i_locationId).FirstOrDefault();
         if (location!=null)
         {
             return location;
         }
         return null;
     }
 }
예제 #9
0
 // GET: Location
 public ActionResult DisplayAllLocation()
 {
     Context con = new Context();
     return View(con.Locations);
 }
예제 #10
0
 // GET: Home
 public ActionResult Index()
 {
     Context con = new Context();
     return View();
 }
예제 #11
0
 public ActionResult DisplayAllBranchs()
 {
     Context con = new Context();
     return View(con.Branchs);
 }
예제 #12
0
 private CarType GetCarTypeById(int i_carTypeId)
 {
     using (Context con = new Context())
     {
         CarType ret_carT = new CarType();
         ret_carT= con.CarTypes.Where(carT => carT.Id == i_carTypeId).FirstOrDefault();
         return ret_carT;
     }
 }
예제 #13
0
 // GET: CarType
 public ActionResult Index()
 {
     Context con = new Context();
     return View(con.CarTypes);
 }