/// <summary> /// Remove a product record from BookingsDetails /// </summary> /// <param name="bookingDetailsId"></param> /// <param name="prodName"></param> /// <param name="supName"></param> /// <param name="tripStart"></param> /// <returns></returns> public ActionResult CancelProductOrder(int bookingDetailsId, string prodName, string supName, DateTime tripStart) { //Calculate number of days between today and trip start date. //If under 4 days, don't allwow cancel. //4 days, because: if trip starts Monday, don't allow user to cancel on Friday night. DateTime today = DateTime.Today; int daysUntilTripStart = (tripStart - today).Days; if (daysUntilTripStart < 4) { TempData["msg"] = "<script>alert('Today is too close to the trip start date. Please contact your agent.');</script>"; } else { try { BookingDetailsManager.DeleteOrder(bookingDetailsId); TempData["msg"] = "<script>alert('Your order for " + prodName + " provided by " + supName + " has been canceled.');</script>"; } catch { TempData["msg"] = "<script>alert('An issue occured when cancelling your order. Please try again later or contact your agent.');</script>"; } } return(RedirectToAction("Index", "Purchases")); }
/// <summary> /// Add a product to customer's list of ordered products, then redirect to orders spage. /// </summary> /// <param name="customerId"></param> /// <param name="prodName"></param> /// <param name="supName"></param> /// <param name="destination"></param> /// <param name="basePrice"></param> /// <param name="feeName"></param> /// <param name="feeAmt"></param> /// <param name="tripStart"></param> /// <param name="tripEnd"></param> /// <returns></returns> public ActionResult OrderProduct(int customerId, string prodName, string supName, string destination, decimal basePrice, string feeName, decimal feeAmt, DateTime tripStart, DateTime tripEnd) { try { BookingDetailsManager.AddProductOrder(customerId, prodName, supName, destination, basePrice, feeName, feeAmt, tripStart, tripEnd); return(RedirectToAction("Index", "Purchases")); } catch { return(View()); } }
/// <summary> /// Add a package to customer's list of ordered packages, then redirect to orders spage. /// </summary> /// <param name="customerId"></param> /// <param name="pkgName"></param> /// <param name="basePrice"></param> /// <param name="tripStart"></param> /// <param name="tripEnd"></param> /// <returns></returns> public ActionResult OrderPackage(int customerId, string pkgName, decimal basePrice, DateTime tripStart, DateTime tripEnd) { try { BookingDetailsManager.AddPackageOrder(customerId, pkgName, basePrice, tripStart, tripEnd); return(RedirectToAction("Index", "Purchases")); } catch { return(View()); } }
/// <summary> /// Changes the status of ISPAID to REFUND REQUESTED /// </summary> /// <param name="bookingDetailsId"></param> /// <returns></returns> public ActionResult RequestRefund(int bookingDetailsId) { try { BookingDetailsManager.RequestRefund(bookingDetailsId); TempData["msg"] = "<script>alert('Your request for a refund has been submitted.');</script>"; } catch { TempData["msg"] = "<script>alert('An issue occured when requesting your refund. Please try again later or contact your agent.');</script>"; } return(RedirectToAction("Index", "Purchases")); }
public IActionResult Index() { //First get all packages customer has ordered, then pass to ViewData. var packagesPurchased = BookingDetailsManager.GetPurchasedPackages((int)TempData.Peek("CustomerId")); ViewData["Packages"] = packagesPurchased.Select(pkg => new PurchaseViewModel { BookingDetailId = pkg.BookingDetailId, BookingNo = pkg.BookingNo, Destination = pkg.Destination, IsPaid = pkg.IsPaid, PkgName = pkg.PkgName, ProdName = pkg.ProdName, SupName = pkg.SupName, TotalPrice = pkg.TotalPrice, TripEnd = pkg.TripEnd, TripStart = pkg.TripStart }); //Then get all products customer has ordered, then pass to ViewData. var productsPurchased = BookingDetailsManager.GetPurchasedProducts((int)TempData.Peek("CustomerId")); ViewData["Products"] = productsPurchased.Select(prod => new PurchaseViewModel { BookingDetailId = prod.BookingDetailId, BookingNo = prod.BookingNo, Destination = prod.Destination, IsPaid = prod.IsPaid, PkgName = prod.PkgName, ProdName = prod.ProdName, SupName = prod.SupName, TotalPrice = prod.TotalPrice, TripEnd = prod.TripEnd, TripStart = prod.TripStart }); //Then calculate customer's amount owing, and pass to TempData. TempData["Amount Owing"] = BookingDetailsManager.GetTotalOwing((int)TempData.Peek("CustomerId")); return(View()); }