public ActionResult AddBusService(BusService busService, HttpPostedFileBase UpdateImage, HttpPostedFileBase Image)
 {
     if (busService.Id > 0)
     {
         if (UpdateImage != null)
         {
             string filename = UpdateImage.FileName;
             busService.Image = filename;
             string path = Path.Combine(Server.MapPath("/Images"), filename);
             UpdateImage.SaveAs(path);
         }
         _context.Entry(busService).State = EntityState.Modified;
         _context.SaveChanges();
         return(RedirectToAction("BusService"));
     }
     else
     {
         string filename = Image.FileName;
         busService.Image = filename;
         string path = Path.Combine(Server.MapPath("/Images"), filename);
         Image.SaveAs(path);
         _context.BusServices.Add(busService);
         _context.SaveChanges();
         return(RedirectToAction("BusService"));
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "BookingId,Date,From,To,Passenger,Status")] Booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(booking));
 }