public ActionResult Payment(string card_type, string card_name, string card_number, string security_number, string expiry_date, string customer_id, string first_name, string last_name, char gender, string age, string email, string phone_number, string address, string city, string vehicle_id, string pickupdate, string dropoffdate, string returncity, string pickupcity) { ViewData["vehicle_id"] = Request.Params["vehicle_id"]; ViewData["customer_id"] = Request.Params["customer_id"]; ViewData["first_name"] = Request.Params["first_name"]; ViewData["last_name"] = Request.Params["last_name"]; ViewData["age"] = Request.Params["age"]; ViewData["gender"] = Request.Params["gender"]; ViewData["email"] = Request.Params["email"]; ViewData["phone_number"] = Request.Params["phone_number"]; ViewData["address"] = Request.Params["address"]; ViewData["city"] = Request.Params["city"]; ViewData["pickupdate"] = Request.Params["pickupdate"]; ViewData["dropoffdate"] = Request.Params["dropoffdate"]; ViewData["pickupcity"] = Request.Params["pickupcity"]; ViewData["returncity"] = Request.Params["returncity"]; int vid; int.TryParse(vehicle_id, out vid); DatabaseWebRef.LINQDatabase ld = new DatabaseWebRef.LINQDatabase(); DatabaseWebRef.ReviewModel rm = ld.GetReview(vid); ViewData["registration_number"] = rm.registration_number; ViewData["manufacturer_name"] = rm.manufacturer_name; ViewData["model_code"] = rm.model_code; ViewData["body_style"] = rm.body_style; ViewData["automatic"] = rm.automatic; ViewData["passenger_capacity"] = rm.passenger_capacity; ViewData["vehicle_category_description"] = rm.vehicle_category_description; ViewData["manufacturing_date"] = rm.manufacturing_date; ViewData["availability"] = rm.availability; ViewData["daily_rental_rate"] = rm.daily_rental_rate; if (string.IsNullOrEmpty(card_type) || string.IsNullOrEmpty(card_number) || string.IsNullOrEmpty(card_name) || string.IsNullOrEmpty(expiry_date) || string.IsNullOrEmpty(security_number)) { ModelState.AddModelError("error", "Please fill all the fields"); } else if (ModelState.IsValid) { CardVerification cv = new CardVerification(); CardVerification.ReturnIndicator ri = cv.CheckCC(card_number); if (ri.CardValid && ri.CardType == card_type) { Receipt t = new Receipt(); t.customer_id = customer_id; t.first_name = first_name; t.last_name = last_name; t.age = age; t.gender = gender; t.email = email; t.address = address; t.city = city; t.phone_number = phone_number; t.vehicle_id = vehicle_id; t.pickupdate = pickupdate; t.dropoffdate = dropoffdate; t.returncity = returncity; t.pickupcity = pickupcity; t.card_type = card_type; t.card_number = card_number; t.card_name = card_name; t.security_number = security_number; t.expiry_date = expiry_date; return RedirectToAction("Receipt", t); } else { ModelState.AddModelError("error", "Incorrect card details. Please enter again"); } } return View(); }
public ActionResult Receipt(string card_type, string card_name, string card_number, string security_number, string expiry_date, string customer_id, string first_name, string last_name, char gender, int age, string email, string phone_number, string address, string city, int vehicle_id, string pickupdate, string dropoffdate, string returncity, string pickupcity) { ViewData["vehicle_id"] = Request.Params["vehicle_id"]; ViewData["customer_id"] = Request.Params["customer_id"]; ViewData["first_name"] = Request.Params["first_name"]; ViewData["last_name"] = Request.Params["last_name"]; ViewData["age"] = Request.Params["age"]; ViewData["gender"] = Request.Params["gender"]; ViewData["email"] = Request.Params["email"]; ViewData["phone_number"] = Request.Params["phone_number"]; ViewData["address"] = Request.Params["address"]; ViewData["city"] = Request.Params["city"]; ViewData["pickupdate"] = Request.Params["pickupdate"]; ViewData["dropoffdate"] = Request.Params["dropoffdate"]; ViewData["pickupcity"] = Request.Params["pickupcity"]; ViewData["returncity"] = Request.Params["returncity"]; int cid; int.TryParse(customer_id, out cid); DatabaseWebRef.Customer c = new DatabaseWebRef.Customer { customer_id = cid, first_name = first_name, last_name = last_name, age = age, gender = gender, email = email, phone_number = phone_number, address = address, city = city }; DatabaseWebRef.LINQDatabase s = new DatabaseWebRef.LINQDatabase(); s.SaveCustomer(c); int vid = vehicle_id; int.TryParse(customer_id, out cid); DatabaseWebRef.Booking b = new DatabaseWebRef.Booking { booking_status_code = "1", customer_id = cid, vehicle_id = vid, pickup_city = pickupcity, return_city = returncity, pickup_date = Convert.ToDateTime(pickupdate), return_date = Convert.ToDateTime(dropoffdate) }; b.booking_id = s.SaveBooking(b); Payment p = new Payment(); p.cardtype = card_type; p.cardnumber = card_number; p.cardname = card_name; p.expirydate = expiry_date; p.securitynumber = security_number; ParentModel pm = new ParentModel(); pm.customer = c; pm.booking = b; pm.reviewmodel = s.GetReview(vehicle_id); pm.payment = p; DateTime end = Convert.ToDateTime(ViewData["dropoffdate"]); DateTime start = Convert.ToDateTime(ViewData["pickupdate"]); double d = ((end - start).TotalDays + 1 ) * Convert.ToDouble(pm.reviewmodel.daily_rental_rate); CarRentalTestApp.SendEmailService ses = new CarRentalTestApp.SendEmailService(); String aString = "<br/>Customer ID:" + pm.customer.customer_id + "<br/>Customer First Name:" + pm.customer.first_name + "<br/>Customer Last Name:" + pm.customer.last_name + "<br/>Age:" + pm.customer.age + "<br/>Gender:" + pm.customer.gender + "<br/>Email:" + pm.customer.email + "<br/>Phone Number:" + pm.customer.phone_number + "<br/>Address:" + pm.customer.address + "<br/>City:" + pm.customer.city; aString += "<br/>Payment Card Type:" + pm.payment.cardtype + "<br/>Payment Card Number:" + pm.payment.cardnumber + "<br/>Payment Card Name:" + pm.payment.cardname + "<br/>Expiry Date:" + pm.payment.expirydate + "<br/>Security Number:" + pm.payment.securitynumber; aString += "<br/>Booking ID:" + pm.booking.booking_id + "<br/>Pickup Date:" + pm.booking.pickup_date + "<br/>Return Date:" + pm.booking.return_date + "<br/>Pickup City:" + pm.booking.pickup_city + "<br/>Drop off city:" + pm.booking.return_city; aString += "<br/>Vehicle ID:" + pm.reviewmodel.registration_number +"<br/>Manufacturing Date:"+ pm.reviewmodel.manufacturing_date+ "<br/>Model:" + pm.reviewmodel.model_code + "<br/>Body style:" + pm.reviewmodel.body_style + "<br/>Passenger Capacity:" + pm.reviewmodel.passenger_capacity + "<br/>Vehicle Category Description:" + pm.reviewmodel.vehicle_category_description + "<br/> Daily Rental:" + pm.reviewmodel.daily_rental_rate + "<br/>Total Cost:" + d.ToString(); ses.SendEmail(pm.customer.email, aString ); return View(pm); }
public ActionResult Payment() { ViewData["vehicle_id"] = Request.Params["vehicle_id"]; ViewData["customer_id"] = Request.Params["customer_id"]; ViewData["first_name"] = Request.Params["first_name"]; ViewData["last_name"] = Request.Params["last_name"]; ViewData["age"] = Request.Params["age"]; ViewData["gender"] = Request.Params["gender"]; ViewData["email"] = Request.Params["email"]; ViewData["phone_number"] = Request.Params["phone_number"]; ViewData["address"] = Request.Params["address"]; ViewData["city"] = Request.Params["city"]; ViewData["pickupdate"] = Request.Params["pickupdate"]; ViewData["dropoffdate"] = Request.Params["dropoffdate"]; ViewData["pickupcity"] = Request.Params["pickupcity"]; ViewData["returncity"] = Request.Params["returncity"]; int vid; int.TryParse(ViewData["vehicle_id"].ToString(), out vid); DatabaseWebRef.LINQDatabase ld = new DatabaseWebRef.LINQDatabase(); DatabaseWebRef.ReviewModel rm = ld.GetReview(vid); ViewData["registration_number"] = rm.registration_number; ViewData["manufacturer_name"] = rm.manufacturer_name; ViewData["model_code"] = rm.model_code; ViewData["body_style"] = rm.body_style; ViewData["automatic"] = rm.automatic; ViewData["passenger_capacity"] = rm.passenger_capacity; ViewData["vehicle_category_description"] = rm.vehicle_category_description; ViewData["manufacturing_date"] = rm.manufacturing_date; ViewData["availability"] = rm.availability; ViewData["daily_rental_rate"] = rm.daily_rental_rate; return View(); }