public JsonResult BookTicket([FromBody] CustomerModel customer) { try { CommonMail common = new CommonMail(); List <TblCustomer> tblCustomers = new List <TblCustomer>(); string SeatNumber = ""; for (int i = 0; i < customer.SeatNumber.Count; i++) { SeatNumber += Convert.ToString(customer.SeatNumber[i]) + ','; } var customerName = new SqlParameter("CustomerName", customer.UserName); var Email = new SqlParameter("Email", customer.Email); var SeatNumbers = new SqlParameter("SeatNumbers", SeatNumber); var CustomerLst = cinemaBookingDBContext.TblCustomer .FromSqlRaw("EXECUTE dbo.SP_BookSheet @customerName,@Email,@SeatNumbers", customerName, Email, SeatNumbers) .ToList(); if (CustomerLst.Count != 0) { string MsgBody = ""; MsgBody += "Dear " + customer.UserName; MsgBody += "<br/>"; MsgBody += "Greetings!!"; MsgBody += "<br/>"; MsgBody += "Thank you for choosing our Booking Cinema System. Your Ticket Has Been Booked."; MsgBody += "<br/><table border=" + 1 + " cellpadding=" + 0 + " cellspacing=" + 0 + " width = " + 400 + "><tr><th>Seat Number</th><th>Secret Key</th></tr>"; for (int i = 0; i < CustomerLst.Count; i++) { MsgBody += "<tr><td>" + CustomerLst[i].SeatNumber + "</td><td>" + CustomerLst[i].SecretKey + "</td><tr>"; } MsgBody += "</table><br/>"; MsgBody += "Thanks<br/>Cinema Booking System"; common.SendMail(customer.Email, MsgBody, "Confirmation Ticket Booking"); return(Json(1)); } else { return(Json(0)); } } catch (Exception ex) { LogException(ex, "BookTicket"); return(Json(0)); } }
public JsonResult UnBookTicket(int SeatNumber) { try { var TicketStatus = repository.GetById(SeatNumber); string UserMail = ""; CommonMail common = new CommonMail(); string UserName = ""; string MsgBody = ""; if (TicketStatus != null && TicketStatus.BookingStatus == true) { var CustomerInform = repositoryCustomer.GetById(TicketStatus.CustomerId); UserMail = CustomerInform.Email; UserName = CustomerInform.CustomerName; repositoryCustomer.Delete(TicketStatus.CustomerId); repositoryCustomer.Save(); TicketStatus.BookingStatus = false; TicketStatus.CustomerId = 0; repository.Update(TicketStatus); repository.Save(); MsgBody += "Dear " + UserName; MsgBody += "<br/>"; MsgBody += "Greetings!!"; MsgBody += "<br/><br/>"; MsgBody += "Your Ticket (Seat Number) " + SeatNumber + " Has Been Cancelled."; MsgBody += "<br/><br/>"; MsgBody += "Thanks <br/>"; MsgBody += "Cinema Booking System"; common.SendMail(UserMail, MsgBody, "Cancelled Ticket Update"); } return(Json(1)); } catch (Exception ex) { LogException(ex, "UnBookTicket"); return(Json(0)); } }