public string BookTicket() { string check = "true"; string emails = HttpContext.Current.Request["Email"]; string username = HttpContext.Current.Request["Username"]; int cnic = int.Parse(HttpContext.Current.Request["Cnic"]); int tickets = int.Parse(HttpContext.Current.Request["Tickets"]); int eventId = int.Parse(HttpContext.Current.Request["EventId"]); try { TicketBooking events = new TicketBooking(); events.name = username; events.eventId = (eventId); events.cnic = cnic; events.tickets = tickets; events.status = 1; events.email = emails; obj.TicketBookings.InsertOnSubmit(events); obj.SubmitChanges(); } catch (Exception e) { check = "false"; } return(check); }
public bool AddBookings(long CustomerID, int StockID, Schedule Schedule, List <SeatStatusChange> Seats, Guid MachineID) { long operatorID; SecuredUsers.Items.TryGetValue(Context.ConnectionId, out operatorID); var xmlInputModel = new TicketBooking { OperatorID = operatorID, CustomerID = CustomerID, StockID = StockID, Details = Seats.Select(t => new TicketBookingDetail { ScheduleID = Schedule.ID, SeatID = t.SeatID, IsPaidBooking = t.IsPaidBooking }).ToList() }; var repo = new Order(); repo.TX_Order(2, xmlInputModel.ToXml()); if (!repo.IsError) { Clients.All.RemoteReserveSeats(Schedule, Seats, MachineID); } return(!repo.IsError); }
public ActionResult chairStatus(BookingModel model) { if (ModelState.IsValid) { ShowTimeDAO showTimeDAO = new ShowTimeDAO(); ChairDAO chairDAO = new ChairDAO(); UserDAO userDAO = new UserDAO(); TicketBooking newtick = new TicketBooking(); newtick.ShowTimesID = model.showTimeID; Chair chair = chairDAO.getChairIDByName(model.ChairName); newtick.ChairID = chair.ChairID; var userLogin = (UserLogin)Session[CommonConstants.USER_SESSION]; newtick.UserID = userLogin.UserID; userDAO.Update(chair.Fare, userLogin.UserID); db.TicketBookings.Add(newtick); db.SaveChanges(); return(RedirectToAction("InforUser", "User")); } return(View("Login")); }
public Object GetTicketBooking([FromBody] SupportInput si) { TicketBookingOutput fdop = new TicketBookingOutput(); DataSet SelectedSlots = new DataSet(); string sJSONResponse = ""; DataTable dt_TicketTypes = new DataTable(); List <TicketBooking> ttdetails = new List <TicketBooking>(); try { dt_TicketTypes = getdata(string.Format("Select ID,TicketId,RequestTypeId,BranchCode,MemberShipCode,MemberName,Comments from TicketBooking where BranchCode='{0}' and CreatedOn between '{1}' and '{2}' ", si.BranchCode, si.FromDate, si.ToDate)); for (int i = 0; i < dt_TicketTypes.Rows.Count; i++) { TicketBooking fd = new TicketBooking { ID = Convert.ToInt32(dt_TicketTypes.Rows[i]["ID"].ToString()), TicketId = dt_TicketTypes.Rows[i]["TicketId"].ToString(), RequestTypeId = Convert.ToInt32(dt_TicketTypes.Rows[i]["RequestTypeId"].ToString()), BranchCode = dt_TicketTypes.Rows[i]["BranchCode"].ToString(), MemberShipCode = dt_TicketTypes.Rows[i]["MemberShipCode"].ToString(), MemberName = dt_TicketTypes.Rows[i]["MemberName"].ToString(), Comments = dt_TicketTypes.Rows[i]["Comments"].ToString() }; ttdetails.Add(fd); } fdop.status = "success"; fdop.value = ttdetails; sJSONResponse = JsonConvert.SerializeObject(fdop); } catch (Exception ec) { sJSONResponse = JsonConvert.SerializeObject(fdop); } return(sJSONResponse); }
protected void Button1_Click(object sender, EventArgs e) { try { TicketBooking obj = new TicketBooking(); string userid = (string)Session["userid"]; string busid = (string)Session["busid"]; string routeid = (string)Session["routeid"]; int seatno = Convert.ToInt32(TextBox1.Text); string currdate = System.DateTime.Now.ToString(); string fare = TextBox2.Text.ToString(); int bookingid = obj.BookTicket(userid, routeid, busid, currdate, seatno, fare); Label1.Visible = true; Label1.Text = "Your Ticket Number is:" + bookingid.ToString(); obj = new TicketBooking(); string email = obj.findemail(userid); obj = new TicketBooking(); obj.email(email); obj = new TicketBooking(); string contact = obj.findcontact(userid); obj = new TicketBooking(); string msg = "Thank you for using our service...Happy journey SAM Travels"; string op = TicketBooking.send(msg, contact); Button2.Visible = true; } catch (Exception) { Response.Write("Invalid input"); } }
protected void Button1_Click(object sender, EventArgs e) { try { TicketBooking obj = new TicketBooking(); string userid = (string)Session["userid"]; string busid = (string)Session["busid"]; string routeid = (string)Session["routeid"]; int seatno = Convert.ToInt32(TextBox1.Text); string currdate = System.DateTime.Now.ToString(); string fare = TextBox2.Text.ToString(); int bookingid = obj.BookTicket(userid, routeid, busid, currdate, seatno, fare); Label1.Visible = true; Label1.Text = "Your Ticket Number is:" + bookingid.ToString(); obj = new TicketBooking(); string email = obj.findemail(userid); obj = new TicketBooking(); obj.email(email); obj = new TicketBooking(); string contact = obj.findcontact(userid); obj = new TicketBooking(); string msg = "Thank you for using our service...Happy journey SAM Travels"; string op = TicketBooking.send(msg, contact); Button2.Visible = true; } catch(Exception ) { Response.Write("Invalid input"); } }
protected void Button1_Click(object sender, EventArgs e) { try { TicketBooking obj = new TicketBooking(); string bookingid = TextBox1.Text.ToString(); int noofticket = obj.noofticket(bookingid); int ticketnotocancel = Convert.ToInt32(TextBox2.Text.ToString()); if (ticketnotocancel <= noofticket) { for (int i = 1; i <= ticketnotocancel; i++) { obj.CancelTicket(bookingid); } Label1.Visible = true; Label1.Text = "Booking is cancelled successfully"; } else { Label1.Visible = true; Label1.Text = "Invalid no. of tickets"; } } catch (Exception) { Label1.Visible = true; Label1.Text = "Invalid Input"; } }
public ActionResult BookTicket(TicketBookingViewModel ticketBookingViewModel) // Action to store booking details in DB { ticketBookingViewModel.TrainId = (int)TempData["T_Id"]; ticketBookingViewModel.UserId = Convert.ToInt32(Session["UserId"]); ticketBookingViewModel.ClassId = (int)TempData["C_Id"]; ticketBookingViewModel.BookingTime = DateTime.Now; ticketBookingViewModel.JourneyDate = (DateTime)TempData["Doj"]; int trainNo = (int)TempData["T_No"]; string className = TempData["C_Name"].ToString(); if (ModelState.IsValid) { TicketBooking ticketBooking = AutoMapper.Mapper.Map <TicketBookingViewModel, TicketBooking>(ticketBookingViewModel); if (!ticketBookingBL.AddBookingDetails(ticketBooking)) { return(RedirectToAction("BookTicket")); } TempData["BookingId"] = ticketBooking.BookingId; //TempData["Doj"] = ticketBooking.JourneyDate; TempData["NoOfSeats"] = (int)TempData["Seat"]; //int seat = (int)TempData["Seat"]; TempData["TrainNo"] = trainNo; TempData["ClassName"] = className; //return RedirectToAction("AddPassenger", "TicketBooking", new { @trainNo = trainNo, @className = className}); return(RedirectToAction("AddPassenger", "TicketBooking")); } //TempData["TrainId"] = (int)TempData["T_Id"]; //TempData["ClassId"] = (int)TempData["C_Id"]; return(RedirectToAction("BookTicket")); }
public ActionResult BookSeats(CartModel Model) { var success = false; var message = Resources.ErrorGeneral; if (Model != null && Model.Tickets != null && Model.Tickets.Any()) { var xmlInputModel = new TicketBooking { CustomerID = CurrentUser.ID, StockCode = 1, Details = Model.Tickets.Select(t => new TicketBookingDetail { ScheduleID = t.SessionID, SeatID = t.SeatID, IsPaidBooking = false }).ToList() }; OrderRepo.TX_Order(2, xmlInputModel.ToXml()); if (!OrderRepo.IsError) { success = true; message = Resources.OperationSuccessful; } } return(Json(new { Success = success, Message = message }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteConfirmed(int id) { TicketBooking ticketBooking = db.TicketBookings.Find(id); db.TicketBookings.Remove(ticketBooking); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { TicketBooking obj = new TicketBooking(); TextBox2.Text = obj.paymentmethodaddress(); TicketBooking obj1 = new TicketBooking(); TextBox1.Text = obj1.paymentmethodacno(); Label1.Text = "We wish you a happy journey"; }
public string PostSendMessage() { var check = "true"; string emails = HttpContext.Current.Request["Emails"]; string message = HttpContext.Current.Request["Message"]; string subject = HttpContext.Current.Request["Subject"]; string id = HttpContext.Current.Request["Id"]; if (!emails.Contains(',')) { emails += ','; } if (!id.Contains(',')) { id += ','; } string[] email = emails.Split(','); string[] ids = id.Split(','); for (int i = 0; i < email.Length - 1; i++) { try { var sender = new MailAddress(""); var rec = new MailAddress(email[i]); var pass = ""; var body = message; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(sender.Address, pass) }; System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage(sender, rec); msgMail.IsBodyHtml = false; msgMail.Subject = subject; msgMail.Body = body; smtp.Send(msgMail); TicketBooking events = obj.TicketBookings.First(x => x.Id.Equals(int.Parse(id[i].ToString()))); events.Id = int.Parse(id[i].ToString()); events.status = 2; obj.SubmitChanges(); } catch (Exception) { check = "false"; } } return(check); }
static void Main(string[] args) { Console.WriteLine("Enter Ticket Details"); TicketDetail detail = null; TicketBooking tb = new TicketBooking(); DistanceValidator dv = new DistanceValidator(); List <TicketDetail> l = new List <TicketDetail>(); while (true) { detail = new TicketDetail(); Console.WriteLine("Enter Passenger Id"); string a = Console.ReadLine(); detail.PassengerId = a; Console.WriteLine("Enter Passenger Name"); string b = Console.ReadLine(); detail.PassengerName = b; Console.WriteLine("Enter Travel Date"); string c = Console.ReadLine(); detail.TravelDate = c; Console.WriteLine("Enter Distance Travelled"); int d = int.Parse(Console.ReadLine()); while (dv.ValidateTravelDistance(d) != null) { Console.WriteLine(dv.ValidateTravelDistance(d)); Console.WriteLine("Enter Distance Travelled:"); d = int.Parse(Console.ReadLine()); } detail.DistanceTravel = d; tb.AddTicket(detail); l.Add(detail); Console.WriteLine("Book Another Ticket:(y/n)"); //string ch = Console.ReadLine(); char ch = Console.ReadLine()[0]; if (ch == 'y') { continue; } else { break; } } foreach (var v in l) { Console.WriteLine(v.PassengerId + "\n" + v.PassengerName + "\n" + v.TravelDate + "\n" + v.DistanceTravel + "\n" + "ticket cost=" + v.TicketCost); } Console.Read(); }
public ActionResult Edit([Bind(Include = "TicketBookingID,ShowTimesID,ChairID,UserID")] TicketBooking ticketBooking) { if (ModelState.IsValid) { db.Entry(ticketBooking).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ChairID = new SelectList(db.Chairs, "ChairID", "Name", ticketBooking.ChairID); ViewBag.ShowTimesID = new SelectList(db.ShowTimes, "ShowTimesID", "ShowTimesID", ticketBooking.ShowTimesID); ViewBag.UserID = new SelectList(db.Users, "UserID", "Name", ticketBooking.UserID); return(View(ticketBooking)); }
public async Task SetTicket(TicketBooking ticketBooking) { if (State.ReservedTickets.ContainsKey(ticketBooking.TicketId)) { State.ReservedTickets[ticketBooking.TicketId] = true; var message = new ShowTicketLogMessage(ticketBooking.ShowId, "", ticketBooking.TicketId); await _messageBatchGrain.TicketNotification(message); } await WriteStateAsync(); return; }
public ActionResult DeleteConfirmed(string id) { var seatinfot = db.SeatInformation.Where(x => x.TicketId == id).Select(e => e.SeatId).ToList(); TicketBooking teckir = db.TicketBooking.Find(id); for (int i = 0; i < seatinfot.Count; i++) { var seatinfotupdate = db.SeatInformation.FirstOrDefault(x => x.TicketId == id); seatinfotupdate.TicketId = null; seatinfotupdate.Status = false; seatinfotupdate.CommentAdmin = "Ghế đang bán"; db.Entry(seatinfotupdate).State = EntityState.Modified; db.SaveChanges(); } var user = UserManager.FindById(User.Identity.GetUserId()); MailMessage mm = new MailMessage("*****@*****.**", teckir.ApplicationUser.Email); var subject = new StringBuilder(); subject.Append("Hủy Đơn Hàng: " + id); var bodymail = new StringBuilder(); bodymail.AppendLine("Đơn hàng của bạn đã được hủy thành công!"); bodymail.AppendLine(""); bodymail.AppendLine("HoLa Bus!"); mm.Subject = subject.ToString(); mm.Body = bodymail.ToString(); mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; NetworkCredential nc = new NetworkCredential("*****@*****.**", "Hlb@1234"); smtp.UseDefaultCredentials = true; smtp.Credentials = nc; smtp.Send(mm); TicketBooking ticketBooking = db.TicketBooking.Find(id); db.TicketBooking.Remove(ticketBooking); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TicketId,BusId,UserId,StopLocationNumber,TotalSeatNumber,PaymentMethodId,PaymentStatusId,Confim,SeatName,DateBuy,ConfimDelivery,UserName,DeliveryMoney,Discount,Total,DateCheck")] TicketBooking ticketBooking) { if (ModelState.IsValid) { db.Entry(ticketBooking).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Address", ticketBooking.UserId); ViewBag.BusId = new SelectList(db.Directions, "BusId", "RoadName", ticketBooking.BusId); ViewBag.PaymentMethodId = new SelectList(db.PaymentMethod, "PaymentId", "Payment", ticketBooking.PaymentMethodId); ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", ticketBooking.PaymentStatusId); return(View(ticketBooking)); }
// GET: OrderManageAdmin/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(RedirectToAction("Index", "OrderManageAdmin")); } TicketBooking ticketBooking = db.TicketBooking.Find(id); if (ticketBooking == null) { return(RedirectToAction("Index", "OrderManageAdmin")); } return(View(ticketBooking)); }
// GET: OrderTicketManageUser/Details/5 public ActionResult Details(string id) { if (id == null) { return(RedirectToAction("Index", "OrderTicketManageUser")); } TicketBooking ticketBooking = db.TicketBooking.Find(id); if (ticketBooking == null) { return(RedirectToAction("Index", "OrderTicketManageUser")); } return(View(ticketBooking)); }
// GET: TicketBookings/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TicketBooking ticketBooking = db.TicketBookings.Find(id); if (ticketBooking == null) { return(HttpNotFound()); } return(View(ticketBooking)); }
// GET: OrderManageAdmin/Details/5 public ActionResult Details(string id) { if (id == null) { return(RedirectToAction("Index", "OrderManageAdmin")); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } TicketBooking ticketBooking = db.TicketBooking.Find(id); if (ticketBooking == null) { return(RedirectToAction("Index", "OrderManageAdmin")); } return(View(ticketBooking)); }
public bool AddBookingDetails(TicketBooking ticketBooking) // Method to add booking details to db { try { using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext()) { dbContext.TicketBooking.Add(ticketBooking); //dbContext.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [dbo].[TrainDetails] ON"); dbContext.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
protected void TextBox1_TextChanged(object sender, EventArgs e) { try { int noofseats = Convert.ToInt32(TextBox1.Text); TicketBooking obj = new TicketBooking(); string rid = (string)Session["routeid"]; int amount = obj.amount(rid); int amountfinal = amount * Convert.ToInt32(TextBox1.Text); TextBox2.Text = amountfinal.ToString(); } catch (Exception) { Label1.Visible = true; Label1.Text = "Invalid input"; } }
protected void TextBox1_TextChanged(object sender, EventArgs e) { try { int noofseats = Convert.ToInt32(TextBox1.Text); TicketBooking obj = new TicketBooking(); string rid = (string)Session["routeid"]; int amount = obj.amount(rid); int amountfinal = amount * Convert.ToInt32(TextBox1.Text); TextBox2.Text = amountfinal.ToString(); } catch (Exception) { Label1.Visible=true; Label1.Text="Invalid input"; } }
// GET: TicketBookings/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TicketBooking ticketBooking = db.TicketBookings.Find(id); if (ticketBooking == null) { return(HttpNotFound()); } ViewBag.ChairID = new SelectList(db.Chairs, "ChairID", "Name", ticketBooking.ChairID); ViewBag.ShowTimesID = new SelectList(db.ShowTimes, "ShowTimesID", "ShowTimesID", ticketBooking.ShowTimesID); ViewBag.UserID = new SelectList(db.Users, "UserID", "Name", ticketBooking.UserID); return(View(ticketBooking)); }
// GET: OrderManageAdmin/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(RedirectToAction("Index", "OrderManageAdmin")); } TicketBooking ticketBooking = db.TicketBooking.Find(id); if (ticketBooking == null) { return(RedirectToAction("Index", "OrderManageAdmin")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Address", ticketBooking.UserId); ViewBag.BusId = new SelectList(db.Directions, "BusId", "RoadName", ticketBooking.BusId); ViewBag.PaymentMethodId = new SelectList(db.PaymentMethod, "PaymentId", "Payment", ticketBooking.PaymentMethodId); ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", ticketBooking.PaymentStatusId); return(View(ticketBooking)); }
public async Task <bool> CheckForUnsupportedCinema(ITurnContext context, TicketBooking luisResult, CancellationToken cancellationToken) { var cinemaEntities = luisResult.CinemaEntities; if (!string.IsNullOrEmpty(cinemaEntities.Cinema)) { if (string.IsNullOrEmpty(cinemaEntities.AvailableCinema)) { var messageText = $"Sorry, but the following cinema is not supported: {cinemaEntities.Cinema}"; var message = MessageFactory.Text(messageText, messageText, InputHints.IgnoringInput); await context.SendActivityAsync(message, cancellationToken); return(false); } return(true); } return(false); }
// GET: OrderTicketManageUser/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(RedirectToAction("Index", "OrderTicketManageUser")); } TicketBooking ticketBooking = db.TicketBooking.Find(id); if (ticketBooking == null) { return(RedirectToAction("Index", "OrderTicketManageUser")); } if (ticketBooking.PaymentStatusId != 1) { return(RedirectToAction("Index", "OrderTicketManageUser")); } return(View(ticketBooking)); }
public ActionResult Edit([Bind(Include = "TicketId,BusId,UserId,StopLocationNumber,TotalSeatNumber,PaymentMethodId,PaymentStatusId,Confim,SeatName,DateBuy,ConfimDelivery,UserName,DeliveryMoney,Total,NoteAdmin,DateCheck")] TicketBooking ticketBooking) { if (ticketBooking.PaymentStatusId != 1) { var user = UserManager.FindById(ticketBooking.UserId); MailMessage mm = new MailMessage("*****@*****.**", user.Email); var subject = new StringBuilder(); subject.Append("Xác Nhận Đơn Hàng: " + ticketBooking.TicketId); var bodymail = new StringBuilder(); bodymail.AppendLine("Đơn Hàng Đã Đặt Thành Công"); bodymail.AppendLine(""); bodymail.AppendLine("HoLa Bus!"); mm.Subject = subject.ToString(); mm.Body = bodymail.ToString(); mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; NetworkCredential nc = new NetworkCredential("*****@*****.**", "Hlb@1234"); smtp.UseDefaultCredentials = true; smtp.Credentials = nc; smtp.Send(mm); } if (ModelState.IsValid) { db.Entry(ticketBooking).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Address", ticketBooking.UserId); ViewBag.BusId = new SelectList(db.Directions, "BusId", "RoadName", ticketBooking.BusId); ViewBag.PaymentMethodId = new SelectList(db.PaymentMethod, "PaymentId", "Payment", ticketBooking.PaymentMethodId); ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", ticketBooking.PaymentStatusId); return(View(ticketBooking)); }
public ActionResult DisplayPassengerDetails() { TicketBooking ticketBooking = ticketBookingBL.GetNoOfPassengers(Convert.ToInt32(TempData["BookingId"])); // Getting no of passengers from booking table TempData["NOP"] = ticketBooking.NoOfPassengers; TempData["Count"] = ticketBookingBL.GetPassengerCountByID(Convert.ToInt32(TempData["BookingId"])); // Getting count of passengers in passenger table based on current booking ID List <PassengerDetails> passengerList = ticketBookingBL.GetPassengerDetails(Convert.ToInt32(TempData["BookingId"])); List <PassengerDetailsViewModel> passengerViewModelList = new List <PassengerDetailsViewModel>(); foreach (PassengerDetails details in passengerList) { //Display passenger Details PassengerDetailsViewModel passengerDetailsViewModel = AutoMapper.Mapper.Map <PassengerDetails, PassengerDetailsViewModel>(details); passengerViewModelList.Add(passengerDetailsViewModel); } if ((int)TempData["NOP"] == (int)TempData["Count"]) //Condition to check & get total cost { int totalMoney = ticketBookingBL.GetTotalCost(Convert.ToInt32(TempData["BookingId"])); TempData["TotalCost"] = totalMoney; } return(View(passengerViewModelList)); }
public void ShouldSaveToDatabase() { // Arrange TicketBooking savedTicketBooking = null; _ticketBookingRepositoryMock.Setup(x => x.Save(It.IsAny <TicketBooking>())) .Callback <TicketBooking>((ticketBooking) => { savedTicketBooking = ticketBooking; }); // Act _processor.Book(_request); // Assert _ticketBookingRepositoryMock.Verify(x => x.Save(It.IsAny <TicketBooking>()), Times.Once); Assert.NotNull(savedTicketBooking); Assert.Equal(_request.FirstName, savedTicketBooking.FirstName); Assert.Equal(_request.LastName, savedTicketBooking.LastName); Assert.Equal(_request.Email, savedTicketBooking.Email); }
public ActionResult Payment([Bind(Include = "CardNumber,NameOnCard,ExpiryDate")] CardDetails card) { if (ModelState.IsValid) { int userId = (int)Session["UserId"]; int?bookingId = db3.TicketBookings.Max(t => (int?)t.Id); if (bookingId == null) { bookingId = 1; } TransactionReference.Transaction trxn = new TransactionReference.Transaction { id = bookingId, quantity = (int)Session["TicketCount"], expDate = card.ExpiryDate, cardNo = card.CardNumber, nameOnCard = card.NameOnCard }; object ticketDay = Session["TicketDay"]; // Entry Fee: 10 CAD for weekdays and 12 CAD for weekends if (ticketDay != null && (((DateTime)ticketDay).DayOfWeek == DayOfWeek.Saturday || ((DateTime)ticketDay).DayOfWeek == DayOfWeek.Sunday)) { trxn.unitPrice = 12; } else { trxn.unitPrice = 10; } TransactionReference.TransactionWebserviceImplClient trxnClient = new TransactionReference.TransactionWebserviceImplClient(); trxnClient.Endpoint.Address = new EndpointAddress("http://dev.cs.smu.ca:9090/Assignment3/services/TransactionWebserviceImpl"); bool success = trxnClient.createTransaction(trxn); if (success) { TicketBooking ticketBooking = new TicketBooking { Id = (int)bookingId, BookedTicketDate = (DateTime)ticketDay, UserId = userId, SeatsCount = (int)Session["TicketCount"], TransactionId = (int)bookingId }; db3.TicketBookings.Add(ticketBooking); db3.SaveChanges(); //TransactionReference.Transaction transaction = trxnClient.getTransaction((int)bookingId); //SendEmailToCust(userId, transaction); SendEmailToCust(userId, trxn.id, trxn.unitPrice * trxn.quantity); Response.Write("<script>alert('Ticket/s Booked Successfully and Email Notification Sent!')</script>"); return(View("Payment")); } Response.Write("<script>alert('Unsuccessful Payment!')</script>"); return(View("Payment")); } return(View()); }