public ActionResult Edit(int id) { DBContext context = new DBContext(); Tour_Package tour = context.Tour_Packages.FirstOrDefault(m => m.PackageId == id); return(View(tour)); }
public ActionResult Details(int id) { DBContext db = new DBContext(); Tour_Package package = db.Tour_Packages.FirstOrDefault(m => m.PackageId == id); return(View(package)); }
public ActionResult Edit(Book_Package package) { DBContext context = new DBContext(); context.Book_Packages.FirstOrDefault(m => m.BookingId == package.BookingId).Date_of_Travelling = package.Date_of_Travelling; context.Book_Packages.FirstOrDefault(m => m.BookingId == package.BookingId).Number_of_persons = package.Number_of_persons; Tour_Package pack = context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId); context.SaveChanges(); ViewBag.EditMessage = "Details Updated Successfully"; return(View()); }
public ActionResult Generate_Bill(Book_Package booking) { DBContext context = new DBContext(); Session["BookingID"] = booking.BookingId; Session["BillDate"] = DateTime.Now; int number = booking.Number_of_persons; Tour_Package nop = context.Tour_Packages.FirstOrDefault(m => m.PackageId == booking.PackageId); int amt = Convert.ToInt32(nop.Per_head_cost); Session["TotalAmount"] = number * amt; return(View()); }
public ActionResult CancelBooking(int id) { DBContext context = new DBContext(); context.Book_Packages.FirstOrDefault(m => m.BookingId == id).Status = "Cancelled"; Book_Package book = context.Book_Packages.FirstOrDefault(m => m.BookingId == id); Tour_Package pack = context.Tour_Packages.FirstOrDefault(m => m.PackageId == book.PackageId); ViewBag.CancelMessage = "Booking Cancelled! Your money will soon be refunded to your wallet."; context.SaveChanges(); return(RedirectToAction("View_Booking")); }
public ActionResult Add_Package(Tour_Package package) { DBContext context = new DBContext(); context.Tour_Packages.Add(package); context.SaveChanges(); User_Registeration user = context.User_Registerations.FirstOrDefault(m => m.UserId == package.Travel_Agent_Id); ViewBag.Message = String.Format("Details Added Succesfully"); ViewBag.User = user; //return RedirectToAction("AgentProfile",user); return(View()); }
public ActionResult Edit(Tour_Package package) { DBContext context = new DBContext(); context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId).Package_Name = package.Package_Name; context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId).Source = package.Source; context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId).Destination = package.Destination; context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId).Per_head_cost = package.Per_head_cost; context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId).images = package.images; //Tour_Package pack = context.Tour_Packages.FirstOrDefault(m => m.PackageId == package.PackageId); context.SaveChanges(); ViewBag.EditMessage = "Changes Saved Successfully"; return(View()); }
public string Delete(string Id) { Tour_Package tourPackage = db.Tour_Package.FirstOrDefault(g => g.Id == Id); List <Tour_Reservation> tourReservation = db.Tour_Reservation.Where(r => r.ID_Package == Id).ToList(); if (tourReservation.Count != 0) { return("已有预约"); } if (tourReservation != null) { db.Tour_Package.Remove(tourPackage); if (db.SaveChanges() > 0) { return("删除成功"); } } return("删除失败"); }
public ActionResult View_Package(Tour_Package package) { DBContext context = new DBContext(); /*Tour_Package tour_Package = context.Tour_Packages.FirstOrDefault( * m => m.Source == package.Source && m.Destination == package.Destination);*/ Session["Source"] = package.Source; Session["Destination"] = package.Destination; Session["SearchParam"] = package; var tour_Package = (from d in context.Tour_Packages where d.Source == package.Source && d.Destination == package.Destination select d).ToList(); if (tour_Package == null) { ViewBag.Error = "No Package Exist for these places"; } Session["SearchList"] = tour_Package; return(View(tour_Package)); }
public string Add(FormCollection formCollection) { string photoUrl = "", country = "", date = "", tourId = "", province = "", name = "", description = ""; foreach (var key in formCollection.AllKeys) { province = formCollection["province"]; description = formCollection["description"]; country = formCollection["country"]; tourId = formCollection["tourId"]; date = formCollection["date"]; name = formCollection["name"]; } if (Request.Files.Count > 0) { try { // Get all files from Request object HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/"; //string filename = Path.GetFileName(Request.Files[i].FileName); HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); photoUrl = testfiles[testfiles.Length - 1]; } else { photoUrl = file.FileName; } if (!System.IO.Directory.Exists(Server.MapPath("~/Uploads/"))) { System.IO.Directory.CreateDirectory(Server.MapPath("~/Uploads/")); } // Get the complete folder path and store the file inside it. string fullPathUrl = Path.Combine(Server.MapPath("~/Uploads/"), photoUrl); Tour_Package tourPackage = new Tour_Package() { Id = Guid.NewGuid().ToString(), Description = description, Photo = "/Uploads/" + photoUrl, Tour = db.Tours.FirstOrDefault(t => t.Id == tourId) }; db.Tour_Package.Add(tourPackage); if (db.SaveChanges() > 0) { file.SaveAs(fullPathUrl); return("添加成功"); } } // Returns message that successfully uploaded //return "File Uploaded Successfully!"; } catch (DbEntityValidationException dbEx) { StringBuilder sb = new StringBuilder(); foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { sb.Append("Property:" + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } return(sb.ToString()); } } else { return("No files selected."); } return("添加失败"); }