public ActionResult Book(int Id) { if (User.IsInRole("Student")) { var ClassinCampus = db.ClassinCampuses.Include("Classtype").Where(be => be.Id == Id).FirstOrDefault(); var UserId = User.Identity.GetUserId(); var check = db.BookEvents.Where(be => be.ClassinCampusId == Id && be.ApplicationUserId == UserId).FirstOrDefault(); if (check == null) { var bookEvent = new BookEvent { ApplicationUserId = UserId, ClassinCampusId = Id }; db.BookEvents.Add(bookEvent); db.SaveChanges(); string toEmail = User.Identity.GetUserName(); string subject = "Booking class confirm"; string content = "You have already book the" + ClassinCampus.Classtype.Name.ToString() + "class at" + ClassinCampus.StartTime.ToString(); EmailSender es = new EmailSender(); es.SendSingle(toEmail, subject, content); } else { ViewBag.Error = "You have already book this class"; } return(View("Index")); } else { return(View("Error")); } }
public ActionResult Book(int id) { // id = branch Event Id //var user = db.Users.Find(User.Identity.GetUserId()); var branchEvent = db.BranchEvents.Where(be => be.Id == id).FirstOrDefault(); //var bookEvent = new BookEvent {ApplicationUser = user,BranchEvent = BranchEvent, } var userId = User.Identity.GetUserId(); var check = db.BookEvents.Where(be => be.BranchEventId == id && be.ApplicationUserId.Equals(userId)).FirstOrDefault(); if (check == null) { var bookEvent = new BookEvent { ApplicationUserId = User.Identity.GetUserId(), BranchEventId = id }; db.BookEvents.Add(bookEvent); db.SaveChanges(); string toEmail = User.Identity.GetUserName(); string subject = "Book Event Confirm"; string content = "This is the content of test email. Start time: " + branchEvent.StartTime.ToString(); EmailSender es = new EmailSender(); es.SendSingle(toEmail, subject, content); // send email } else { ViewBag.Error = "You have already bookend this event!"; // return error page } return(View("index")); }
public void SetUp() { IDataFiller dataFiller = new ConstantFiller(); IDataRepository dataRepository = new Task1.Data.DataRepository(dataFiller, dataContext); bookEvent1 = new BookRent(dataContext.ReadersList[3], dataContext.BookStatesList[0], new DateTime(2017, 11, 14)); bookEvent2 = new BookReturn(dataContext.ReadersList[3], dataContext.BookStatesList[0], new DateTime(2017, 11, 14)); }
public void HashCodeBookEventTest() { Assert.AreNotEqual(bookEvent1.GetHashCode(), bookEvent2.GetHashCode()); bookEvent2 = new BookRent(dataContext.ReadersList[3], dataContext.BookStatesList[0], new DateTime(2017, 11, 14)); Assert.AreEqual(bookEvent1.GetHashCode(), bookEvent2.GetHashCode()); }
public ActionResult DeleteConfirmed(int id) { BookEvent bookEvent = db.BookEvents.Find(id); db.BookEvents.Remove(bookEvent); db.SaveChanges(); return(RedirectToAction("Index")); }
public void EqualsBookEventTest() { Assert.IsFalse(bookEvent1.Equals(bookEvent2)); Assert.AreNotEqual(bookEvent1, bookEvent2); bookEvent2 = new BookRent(dataContext.ReadersList[3], dataContext.BookStatesList[0], new DateTime(2017, 11, 14)); Assert.IsTrue(bookEvent1.Equals(bookEvent2)); Assert.AreEqual(bookEvent1, bookEvent2); }
public ActionResult OnceOff() { var onceOffRequest = new PayFastRequest(this.payFastSettings.PassPhrase); int eventId = int.Parse(Session["event"].ToString()); BookEvent èvent = new BookEvent(); èvent = db.BookEvents.Find(eventId); var userName = User.Identity.Name; var guest = db.students.Where(x => x.StudentEmail == userName).FirstOrDefault(); var attachments = new List <Attachment>(); attachments.Add(new Attachment(new MemoryStream(GeneratePDF(eventId)), "Events Booking", "application/pdf")); var mailTo = new List <MailAddress>(); mailTo.Add(new MailAddress(User.Identity.Name, guest.StudentName + guest.StudentSurname)); var body = $"Hello {guest.StudentName + guest.StudentSurname}, Please see attached receipt for the recent rental you made. <br/>Make sure you bring along your receipt when you pick up your car.<br/>"; DGSappSem2.Models.Events.EmailService emailService = new DGSappSem2.Models.Events.EmailService(); emailService.SendEmail(new EmailContent() { mailTo = mailTo, mailCc = new List <MailAddress>(), mailSubject = "Application Statement | Ref No.:" + èvent.RefNum, mailBody = body, mailFooter = "<br/> Many Thanks, <br/> <b>Explorer</b>", mailPriority = MailPriority.High, mailAttachments = attachments }); // Merchant Details onceOffRequest.merchant_id = this.payFastSettings.MerchantId; onceOffRequest.merchant_key = this.payFastSettings.MerchantKey; onceOffRequest.return_url = this.payFastSettings.ReturnUrl; onceOffRequest.cancel_url = this.payFastSettings.CancelUrl; onceOffRequest.notify_url = this.payFastSettings.NotifyUrl; // Buyer Details onceOffRequest.email_address = "*****@*****.**"; //onceOffRequest.email_address = "*****@*****.**"; // Transaction Details //onceOffRequest.m_payment_id = ""; onceOffRequest.m_payment_id = èvent.RefNum; onceOffRequest.amount = Convert.ToDouble(èvent.getEventPrice()); onceOffRequest.item_name = "Car Rental payment"; onceOffRequest.item_description = "Some details about the once off payment"; onceOffRequest.email_confirmation = true; onceOffRequest.confirmation_address = "*****@*****.**"; var redirectUrl = $"{this.payFastSettings.ProcessUrl}{onceOffRequest.ToString()}"; return(Redirect(redirectUrl)); }
public ActionResult Edit([Bind(Include = "BookEventId,Quantiy,RefNum,eventID,UserEmail,Quantiy,dateBooked,DateBookinFor,BookingPrice")] BookEvent bookEvent) { if (ModelState.IsValid) { db.Entry(bookEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.eventID = new SelectList(db.Events, "eventID", "eventName", bookEvent.eventID); return(View(bookEvent)); }
public ActionResult Create([Bind(Include = "BookEventId,Quantiy,RefNum,eventID,UserEmail,Quantiy,DateBookinFor,BookingPrice")] BookEvent bookEvent) { if (ModelState.IsValid) { bookEvent.DateBookinFor = DateTime.Now.Date; db.BookEvents.Add(bookEvent); db.SaveChanges(); Session["event"] = bookEvent.BookEventId; return(RedirectToAction("Index", new { id = bookEvent.BookEventId })); } ViewBag.eventID = new SelectList(db.Events, "eventID", "eventName", bookEvent.eventID); return(View(bookEvent)); }
public ActionResult Create([Bind(Include = "ID,FName,CEmail,LName,Cell,Date,Quantity,locationID")] BookEvent bookEvent) { var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); ApplicationUser currentUser = UserManager.FindById(User.Identity.GetUserId()); string ID = currentUser.Id; string Email = currentUser.Email; string Name = currentUser.Name; string SName = currentUser.Surname; string phone = currentUser.PhoneNumber; if (!db.BookEvents.Any(b => b.Date >= bookEvent.Date && b.Date <= bookEvent.Date || (b.Date <= bookEvent.Date && b.Date >= bookEvent.Date) || (b.Date <= bookEvent.Date && b.Date >= bookEvent.Date)) && // no booking in a booking bookEvent.Date.Date > DateTime.Today && //no previous dates bookEvent.Date.Date != DateTime.Today) // no booking today { try { if (ModelState.IsValid) { //int quantities = bookEvent.Quantity; //List<EventCart> lstCart = (List<EventCart>)Session[strCart]; bookEvent.CEmail = Email; bookEvent.FName = Name; bookEvent.LName = SName; bookEvent.Cell = phone; bookEvent.DateOfOrder = DateTime.Now; bookEvent.ReminderDayBefore = bookEvent.Date.AddDays(-1); bookEvent.Reminder = bookEvent.Date.Date; db.BookEvents.Add(bookEvent); db.SaveChanges(); return(RedirectToAction("CusIndex", "Packages")); } } catch (Exception ex) { ViewBag.Message = $" Date is Unavailable {ex.Message}"; } } else { ViewBag.Message = "Date is Unavailable"; } //ViewBag.Key = new SelectList(db.NumberOfGuests, "Key", "NumberOfPeople", bookEvent.Key); ViewBag.locationID = new SelectList(db.Locations, "locationID", "hallName", bookEvent.locationID); return(View(bookEvent)); }
// GET: BookEvents/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookEvent bookEvent = db.BookEvents.Find(id); if (bookEvent == null) { return(HttpNotFound()); } return(View(bookEvent)); }
// GET: BookEvents/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookEvent bookEvent = db.BookEvents.Find(id); if (bookEvent == null) { return(HttpNotFound()); } ViewBag.eventID = new SelectList(db.Events, "eventID", "eventName"); return(View(bookEvent)); }
public override void AddBookEvent(BookEvent bookEvent) { var y = bookEvent ?? throw new ArgumentNullException(); if (_dataContext.BookEvents.Where(x => x.Equals(y)).Count() == 0) { if (y is Rent) { rentOperation(y as Rent); } else if (y is Return) { returnOperation(y as Return); } } }
public abstract void DeleteBookEvent(BookEvent bookEvent);
public abstract void AddBookEvent(BookEvent bookEvent);
public override void DeleteBookEvent(BookEvent bookEvent) { _dataContext.BookEvents.Remove(bookEvent ?? throw new ArgumentNullException()); }
private void CheckBookEvent(BookEvent bookEvent) { CheckCustomerExistance(bookEvent.Customer); CheckBookCopyExistance(bookEvent.Copy); }
public byte[] GeneratePDF(int EventBookingID) { MemoryStream memoryStream = new MemoryStream(); Document document = new Document(PageSize.A5, 0, 0, 0, 0); PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); document.Open(); BookEvent bookEvent = new BookEvent(); bookEvent = db.BookEvents.Find(EventBookingID); var userName = User.Identity.GetUserName(); var student = db.students.Where(x => x.StudentEmail == userName).FirstOrDefault(); iTextSharp.text.Font font_heading_3 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.RED); iTextSharp.text.Font font_body = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.BaseColor.BLUE); // Create the heading paragraph with the headig font PdfPTable table1 = new PdfPTable(1); PdfPTable table2 = new PdfPTable(5); PdfPTable table3 = new PdfPTable(1); iTextSharp.text.pdf.draw.VerticalPositionMark seperator = new iTextSharp.text.pdf.draw.LineSeparator(); seperator.Offset = -6f; // Remove table cell table1.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; table3.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; table1.WidthPercentage = 80; table1.SetWidths(new float[] { 100 }); table2.WidthPercentage = 80; table3.SetWidths(new float[] { 100 }); table3.WidthPercentage = 80; PdfPCell cell = new PdfPCell(new Phrase("")); cell.Colspan = 3; table1.AddCell("\n"); table1.AddCell(cell); table1.AddCell("\n\n"); table1.AddCell( "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + "Blue Sky Car Rental \n" + "Email :[email protected]" + "\n" + "\n" + "\n"); table1.AddCell("------------Personal Details--------------!"); table1.AddCell("First Name : \t" + student.StudentName); table1.AddCell("Last Name : \t" + student.StudentSurname); table1.AddCell("Email : \t" + student.StudentEmail); table1.AddCell("Phone Number : \t" + student.StudentContact); table1.AddCell("Gender : \t" + student.StudentGender); table1.AddCell("Address : \t" + student.StudentAddress); table1.AddCell("\n------------Rental details--------------!\n"); table1.AddCell("Booking Ref. # : \t" + bookEvent.RefNum); table1.AddCell("Date Booked : \t" + bookEvent.DateBookinFor.ToShortDateString()); //table1.AddCell("Number Of days : \t" + @event.Duration); //table1.AddCell("Total Rental Cost Due: \t" + @event.Amount.ToString("C")); //table1.AddCell("Amount Paid: \t" + @event.AmountPaid.ToString("C")); //table1.AddCell("Status : \t" + @event.Status); //table1.AddCell("Deposit Payed date : \t" + DateTime.Now); table1.AddCell("\n"); table3.AddCell("------------Looking forward to hear from you soon--------------!"); //////Intergrate information into 1 document //var qrCode = iTextSharp.text.Image.GetInstance(reservation.QrCodeImage); //qrCode.ScaleToFit(200, 200); table1.AddCell(cell); document.Add(table1); //document.Add(qrCode); document.Add(table3); document.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); return(bytes); }
public void DeleteBookEvent(BookEvent bookEvent) { _dataRepository.DeleteBookEvent(bookEvent); }
public bool isBookEventInDataRepository(BookEvent bookEvent) { return(GetAllBookEvents().Where(x => x.Equals(bookEvent)).Count() != 0); }