public JsonResult Delete(int id) { try { TourPackage tourpackage = db.TourPackages.Find(id); if (tourpackage == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(new { Result = "Error" })); } //delete files from the file system foreach (var item in tourpackage.FileDetails) { String path = Path.Combine(Server.MapPath("~/Images/packageImg/"), item.FileDetailsId + item.Extension); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } db.TourPackages.Remove(tourpackage); db.SaveChanges(); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public async Task <IActionResult> CreatePackage(TourPackage tourPackage) { if (ModelState.IsValid) { tourPackage.Id = Guid.NewGuid(); tourPackage.PackageCode = GeneralUtilityMethods.GeneratePackageCode(); tourPackage.Availability = AvailabilityStatus.Available.ToString(); var Spots = tourPackage.Spots; tourPackage.Spots = null; // creates PK_Spot conflict otherwise // Create the tourPackage first. await _companyService.CreateTourPackage(tourPackage); // Add the spots foreach (var spot in Spots) { spot.TourPackage = null; // Create PK_Company conflict otherwise spot.TourPackageId = tourPackage.Id; await _tourPackageService.AddSpot(spot); } return(RedirectToAction("CompanyPublicView", "Company", new { companyId = tourPackage.CompanyId })); } return(View(tourPackage)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["userName"] != null) //if logged in, display all necessary infomation { var id = Request.QueryString["purchaseId"]; //which row LblUsername.Text = Session["userName"].ToString(); TourPackage tp = new TourPackage(); tp = tp.GetPackageById(id); string originalcost = ""; string discountedcost = ""; if (tp != null) { LblPackagename.Text = tp.TourPackageName; //updateImageLink.Text = tp.ImageFile; LblDuration.Text = tp.Duration; originalcost = tp.OriginalPrice; discountedcost = tp.DiscountPrice; } } else { Session["errormsg"] = "Please log in to make purchases"; Response.Redirect("tourpackage.aspx"); } }
public static TourPackage Read(SqlDataReader rd) { string tourid = rd["tourpackageId"].ToString(); string tourname = rd["tourName"].ToString(); string image = rd["imageFile"].ToString(); string tourdescription = rd["tourDescription"].ToString(); string tourduration = rd["tourDuration"].ToString(); string tourlocation = rd["tourLocation"].ToString(); string touroriginalprice = rd["tourOriginalPrice"].ToString(); string tourdiscountprice = rd["tourDiscountPrice"].ToString(); string purchasecount = rd["tourPurchaseCount"].ToString(); TourPackage tp = new TourPackage { TourPackageId = tourid, TourPackageName = tourname, ImageFile = image, Description = tourdescription, Duration = tourduration, Location = tourlocation, OriginalPrice = touroriginalprice, DiscountPrice = tourdiscountprice, PurchaseCount = purchasecount }; return(tp); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Destination,TransportationPrice,AccomodationPrice,AdventuresPrice")] TourPackage tourPackage) { if (id != tourPackage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _tourPackages.Update(tourPackage); } catch (DbUpdateConcurrencyException) { if (!await TourPackageExists(tourPackage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tourPackage)); }
public async Task <ActionResult> Edit([Bind(Include = "TourPackageID,TourPackageTitle,Highlights,InclusionExclusion,TourDestination,SpecialNotes,TourCostPrice,TourSalesPrice,TourDiscountPrice,TotalNights,HotelStar,HotelInUse,DayWiseItienary,TearmsAndConditions,Allotment,Adults,Childrens,CreatedOn,DepartingDate,ValidityDate,DayOne,DayTwo,DayThree,DayFour,DayFive,DaySix,DaySeven,DayEight,DayNine,DayTen")] TourPackage tourPackage) { if (ModelState.IsValid) { //New Files for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); FileDetail fileDetail = new FileDetail() { FileName = fileName, Extension = Path.GetExtension(fileName), FileDetailsId = Guid.NewGuid(), TourPackageId = tourPackage.TourPackageID }; var path = Path.Combine(Server.MapPath("~/Images/packageImg/"), fileDetail.FileDetailsId + fileDetail.Extension); file.SaveAs(path); db.Entry(fileDetail).State = EntityState.Added; } } //tourPackage.ModifiedOn = DateTime.Now; db.Entry(tourPackage).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tourPackage)); }
public void InitializeTourPackage() { p = new TourPackage("Europe"); t1 = new Tour("Paris", 3400, 3); t2 = new Tour("London", 3200, 3); t3 = new Tour("Munich", 3100, 2); t4 = new Tour("Milan", 3500, 3); }
public async Task <IActionResult> Create([FromBody] TourPackage tourPackage) { await _context.TourPackages.AddAsync(tourPackage); await _context.SaveChangesAsync(); return(Ok(tourPackage)); }
public async Task <IActionResult> Update([FromRoute] int id, [FromBody] TourPackage tourPackage) { _context.Update(tourPackage); await _context.SaveChangesAsync(); return(Ok(tourPackage)); }
public ActionResult DeleteConfirmed(int id) { TourPackage tourpackage = db.TourPackages.Find(id); db.TourPackages.Remove(tourpackage); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Name,Destination,TransportationPrice,AccomodationPrice,AdventuresPrice")] TourPackage tourPackage) { if (ModelState.IsValid) { _tourPackages.Add(tourPackage); return(RedirectToAction(nameof(Index))); } return(View(tourPackage)); }
public async Task <ActionResult> DeleteConfirmed(int id) { TourPackage tourPackage = await db.TourPackages.FindAsync(id); db.TourPackages.Remove(tourPackage); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(Guid id) { TourPackage TourPackage = db.TourPackages.Find(id); TourPackage.IsDelete = true; TourPackage.DeleteDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index", new { id = TourPackage.TourId })); }
public async Task <ActionResult> Edit([Bind(Include = "TourPackageID,TourPackageTitle,Highlights,InclusionExclusion,TourDestination,SpecialNotes,TourCostPrice,TourSalesPrice,TourDiscountPrice,TotalNights,HotelStar,HotelInUse,DayWiseItienary,TearmsAndConditions,Allotment,Adults,Childrens,CreatedOn,DepartingDate,ValidityDate,DayOne,DayTwo,DayThree,DayFour,DayFive,DaySix,DaySeven,DayEight,DayNine,DayTen")] TourPackage tourPackage) { if (ModelState.IsValid) { db.Entry(tourPackage).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tourPackage)); }
public ActionResult Edit([Bind(Include = "Id,AgentName,AgentNo,CompanyName,PackageTypeId,CategoryId,TourPlace,Days,Amount")] TourPackage tourpackage) { if (ModelState.IsValid) { db.Entry(tourpackage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", tourpackage.CategoryId); ViewBag.PackageTypeId = new SelectList(db.PackageTypes, "Id", "PackageName", tourpackage.PackageTypeId); return(View(tourpackage)); }
public async Task <IActionResult> CreatePackage(string companyId) { await GetLoggedInUser(); TourPackage tourPackage = new TourPackage() { CompanyId = new Guid(companyId) }; ViewBag.companyId = companyId; return(View(tourPackage)); }
public ActionResult Edit(TourPackage tourPackage) { if (ModelState.IsValid) { tourPackage.IsDelete = false; db.Entry(tourPackage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = tourPackage.TourId })); } ViewBag.id = tourPackage.TourId; ViewBag.HotelId = new SelectList(db.Hotels.Where(current => current.IsDelete == false).OrderBy(current => current.Title), "Id", "Title", tourPackage.HotelId); return(View(tourPackage)); }
// GET: /TourPackage/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackage tourpackage = db.TourPackages.Find(id); if (tourpackage == null) { return(HttpNotFound()); } return(View(tourpackage)); }
// GET: Supplier/TourPackages/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackage tourPackage = await db.TourPackages.FindAsync(id); if (tourPackage == null) { return(HttpNotFound()); } return(View(tourPackage)); }
protected void Btn_SubmitReview_Click(object sender, EventArgs e) { UserRating ur = new UserRating(); ur = new UserRating(); int result = ur.CreateReview(Lbl_Name.Text, Ddl_Tp.SelectedItem.Value, Tb_Feedback.Value, Rating1.CurrentRating.ToString()); if (result == 1) { Lbl_Msg.Text = "Thank you for your feedback"; Validation.CssClass = "alert alert-dismissable alert-success"; Lbl_Msg.ForeColor = Color.Green; } else { Lbl_Msg.Text = "Error in adding record! Inform System Administrator!"; Lbl_Msg.ForeColor = Color.Red; } // insert avg int Total = 0; string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(connStr); myConn.Open(); SqlCommand cmd = new SqlCommand("SELECT rating FROM UserRating", myConn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Total += Convert.ToInt32(dt.Rows[i][0].ToString()); } int Average = Total / (dt.Rows.Count); TourPackage tp = new TourPackage(); tp = new TourPackage(); int avg = tp.AverageRating(Ddl_Tp.SelectedItem.Value, Average.ToString()); } }
private static void SeedTourPackages(MatinloAdventuresDbContext context) { if (context.TourPackages.Any()) { return; } var packagesToSeed = new TourPackage[] { new TourPackage() { Destination = "Phillipines", Name = "Budget", TransportationPrice = 50, AccomodationPrice = 40, AdventuresPrice = 20 }, new TourPackage() { Destination = "Phillipines", Name = "Normal", TransportationPrice = 83, AccomodationPrice = 60, AdventuresPrice = 40 }, new TourPackage() { Destination = "Phillipines", Name = "Luxury", TransportationPrice = 125, AccomodationPrice = 115, AdventuresPrice = 215 }, new TourPackage() { Destination = "Kaspichan,Bulgaria", Name = "Евтинджос", TransportationPrice = 1.60m, AccomodationPrice = 15.99m, AdventuresPrice = 0 } }; context.TourPackages.AddRange(packagesToSeed); context.SaveChanges(); }
public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackage TourPackage = db.TourPackages.Find(id); if (TourPackage == null) { return(HttpNotFound()); } ViewBag.id = TourPackage.TourId; return(View(TourPackage)); }
// GET: /TourPackage/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackage tourpackage = db.TourPackages.Find(id); if (tourpackage == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", tourpackage.CategoryId); ViewBag.PackageTypeId = new SelectList(db.PackageTypes, "Id", "PackageName", tourpackage.PackageTypeId); return(View(tourpackage)); }
public void TestAddTourPackage() { TestAddTour(); TourPackage p = new TourPackage("Europe"); p.ConsistsOf(t.FindTour("London")); p.ConsistsOf(t.FindTour("Paris")); t.Add(p); Assert.AreEqual(5, t.Tours.Count); Assert.AreEqual("Europe", t.Tours[4].Name); Assert.AreEqual(5940, t.Tours[4].Cost); Assert.AreEqual(6, t.Tours[4].Duration); }
public ActionResult Create(TourPackage TourPackage, Guid id) { if (ModelState.IsValid) { TourPackage.IsDelete = false; TourPackage.SubmitDate = DateTime.Now; TourPackage.Id = Guid.NewGuid(); TourPackage.TourId = id; db.TourPackages.Add(TourPackage); db.SaveChanges(); return(RedirectToAction("Index", new { id = id })); } ViewBag.HotelId = new SelectList(db.Hotels.Where(current => current.IsDelete == false).OrderBy(current => current.Title), "Id", "Title"); return(View(TourPackage)); }
// GET: TourPackages/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TourPackage TourPackage = db.TourPackages.Find(id); if (TourPackage == null) { return(HttpNotFound()); } ViewBag.HotelId = new SelectList(db.Hotels.Where(current => current.IsDelete == false).OrderBy(current => current.Title), "Id", "Title", TourPackage.HotelId); ViewBag.id = TourPackage.TourId; return(View(TourPackage)); }
public async Task <int> Handle(CreateTourPackageCommand request, CancellationToken cancellationToken) { var entity = new TourPackage { ListId = request.ListId, Name = request.Name, WhatToExpect = request.WhatToExpect, MapLocation = request.MapLocation, Price = request.Price, Duration = request.Duration, InstantConfirmation = request.InstantConfirmation, Currency = request.Currency }; await _context.TourPackages.AddAsync(entity, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(entity.Id); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var id = Request.QueryString["id"]; //which row TourPackage tp = new TourPackage(); tp = tp.GetPackageById(id); if (tp != null) { updateTourName.Text = tp.TourPackageName; updateDescription.Text = tp.Description; updateImageLink.Text = tp.ImageFile; ImageDisplay.ImageUrl = tp.ImageFile; updateLocation.Text = tp.Location; updateDuration.Text = tp.Duration; updateOriginalPrice.Text = tp.OriginalPrice; updateDiscountPrice.Text = tp.DiscountPrice; } } }
protected void BtnUpdate_Click(object sender, EventArgs e) { var id = Request.QueryString["id"]; //which row TourPackage td = new TourPackage(); int upd = td.UpdateTourPackage(id, updateTourName.Text, updateImageLink.Text, updateDescription.Text, updateLocation.Text, updateDuration.Text, updateOriginalPrice.Text, updateDiscountPrice.Text); if (upd == 1) { GotoTourpackage.Visible = true; Validation.Visible = true; Lbl_Msg.Text = "Tour Package Sucessfully Updated !"; Lbl_Msg.ForeColor = Color.Green; } else { Validation.Visible = true; Lbl_Msg.Text = "Error in updating"; Lbl_Msg.ForeColor = Color.Red; } }
protected void BtnCreateTour_Click(object sender, EventArgs e) { TourPackage tp = new TourPackage(); tp = new TourPackage(); int result = tp.CreateTourPackage(adminPackage.Text, adminImageLink.Text, adminDescription.Text, adminDuration.Text, adminLocation.Text, adminOriginal.Text, adminDiscounted.Text); Validation.Visible = true; if (result == 1) { Lbl_Msg.Text = "Tour Package is created"; Validation.CssClass = "alert alert-dismissable alert-success"; Lbl_Msg.ForeColor = Color.Green; } else { Lbl_Msg.Text = "Error in adding record! Inform System Administrator!"; Lbl_Msg.ForeColor = Color.Red; } }