/// <summary> /// Added by: Matt H. on 4/26/17 /// </summary> // GET: MyAccount/ViewTab/5 public ActionResult ViewTab() { try { string email = User.Identity.Name; int id = _memberManager.RetrieveMemberByEmail(email); MemberTab memberTab = _memberTabManager.RetrieveActiveMemberTabByMemberID(id); List <MemberTabLine> memberTabLines = _memberTabLineManager.RetrieveMemberTabLineByMemberID(memberTab.MemberTabID); ViewTabMixer viewTabMixer = new ViewTabMixer { MemberTab = memberTab, MemberTabLines = memberTabLines }; return(View(viewTabMixer)); } catch (Exception ex) { TempData["error"] = new ErrorViewModel( Title: "Your Tab", Message: "We could not pull up your tab!", ExceptionMessage: ex.Message, ButtonMessage: "Back to Account", ReturnController: "MyAccount", ReturnAction: "Index" ); return(RedirectToAction("Index", "Error")); } }
/// <summary> /// Author: Jared Greenfield /// Created On: 2019-04-30 /// Creates the customer receipt in html /// </summary> private string generateReportHTML() { String filepath = AppDomain.CurrentDomain.BaseDirectory + @"../../../Receipts"; Reservation reservation = _reservationManager.RetrieveReservation(_reservationID); Member member = _memberManager.RetrieveMember(reservation.MemberID); List <OfferingVM> allOfferings = _offeringManager.RetrieveAllOfferingViewModels(); MemberTab tab = _tabManager.RetrieveLastMemberTabByMemberID(member.MemberID); // Removed because CSS wouldn't be included if they didn't choose correct folder. // Possible future feature, maybe specify static CSS location. //Instead of using a static folder, let the user pick folder //CommonOpenFileDialog dialog = new CommonOpenFileDialog(); //dialog.InitialDirectory = "C:\\Users"; //dialog.IsFolderPicker = true; //if (dialog.ShowDialog() == CommonFileDialogResult.Ok) //{ // filepath = dialog.FileName; //} // Create the file name string fileName = @"\" + reservation.DepartureDate.ToShortDateString().Replace("/", "-") + member.Email + ".html"; var result = _checkoutReceiptManager.generateMemberTabReceipt(reservation, member, allOfferings, tab, filepath + fileName, _allGuests); System.Diagnostics.Process.Start("IExplore.exe", filepath + fileName); return(filepath + fileName); }
public ActionResult Buy(BuyTicketModel model) { if (ModelState.IsValid) { try { Guest guest = new Guest(); string email = User.Identity.Name; int memberId = _memberManager.RetrieveMemberByEmail(email); guest = _guestManager.RetrieveGuestByEmail(email); MemberTab memberTab = _memberTabManager.RetrieveActiveMemberTabByMemberID(memberId); Offering offering = _offeringManager.RetrieveOfferingByID(model.OfferingID); MemberTabLine tab = new MemberTabLine() { MemberTabID = memberTab.MemberTabID, OfferingID = model.OfferingID, Quantity = model.Quantity, Price = model.Price, EmployeeID = offering.EmployeeID, Discount = 0, GuestID = guest.GuestID, DatePurchased = DateTime.Now }; if (_memberTabManager.CreateMemberTabLine(tab) != 0) { TempData["success"] = new SuccessViewModel( Title: "an Event!", dateTime: model.Date.ToShortDateString(), type: model.EventTitle, time: " the greatest time of your life", ButtonMessage: "Go to Account", ReturnController: "MyAccount", ReturnAction: "Index" ); return(RedirectToAction("Index", "Success")); } } catch (Exception ex) { TempData["error"] = new ErrorViewModel( Title: "Events", Message: "We could not purhcase your ticket at this time ", ExceptionMessage: ex.Message, ButtonMessage: "Try again", ReturnController: "Event", ReturnAction: "Index" ); return(RedirectToAction("Index", "Error")); } } return(View(model)); }
public void TestRetrieveLastMemberTabByMemberIDIDNotValid() { //Arrange int memberID = -1; MemberTab tab = null; // Act tab = _memberTabManager.RetrieveLastMemberTabByMemberID(memberID); //Assert Assert.IsNull(tab); }
public void TestRetrieveLastMemberTabByMemberIDValidID() { //Arrange int memberID = 100000; MemberTab tab = null; // Act tab = _memberTabManager.RetrieveLastMemberTabByMemberID(memberID); //Assert Assert.IsNotNull(tab); Assert.AreEqual(memberID, tab.MemberID); }
public void TestGenerateMemberTabReceiptNullOfferings() { //Arrange bool result = false; Reservation reservation = new Reservation(); Member member = new Member(); MemberTab tab = new MemberTab(); string filePath = "C:\\Users"; List <GuestRoomAssignmentVM> guests = new List <GuestRoomAssignmentVM>(); // Act result = _receiptManager.generateMemberTabReceipt(reservation, member, null, tab, filePath, guests); }
public void TestGenerateMemberTabReceiptNullGuests() { //Arrange bool result = false; Reservation reservation = new Reservation(); Member member = new Member(); List <OfferingVM> offerings = new List <OfferingVM>(); MemberTab tab = new MemberTab(); string filePath = "C:\\Users"; // Act result = _receiptManager.generateMemberTabReceipt(reservation, member, offerings, tab, filePath, null); }
public void TestGenerateMemberTabReceiptNullFilePath() { //Arrange bool result = false; Reservation reservation = new Reservation(); Member member = new Member(); List <OfferingVM> offerings = new List <OfferingVM>(); MemberTab tab = new MemberTab(); List <GuestRoomAssignmentVM> guests = new List <GuestRoomAssignmentVM>(); // Act result = _receiptManager.generateMemberTabReceipt(reservation, member, offerings, tab, null, guests); }
/// <summary> /// Author: Jared Greenfield /// Date Created: 2019-04-30 /// Returns last tab of a member /// </summary> public MemberTab SelectLastMemberTabByMemberID(int memberID) { MemberTab tab = null; foreach (MemberTab Tab in _memberTabs) { if (Tab.MemberID == memberID) { tab = Tab; } } return(tab); }
/// <summary> /// James Heim /// Created 2019-04-25 /// /// Select all Tabs for all Members. /// </summary> /// <returns></returns> public IEnumerable <MemberTab> SelectMemberTabs() { List <MemberTab> tabs = new List <MemberTab>(); var conn = DBConnection.GetDbConnection(); var cmdText = @"sp_select_membertabs"; SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; try { conn.Open(); // Retrieve the MemberTab Attributes. var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); MemberTab tab = new MemberTab() { MemberTabID = reader.GetInt32(0), MemberID = reader.GetInt32(1), Active = reader.GetBoolean(2), TotalPrice = (decimal)reader.GetSqlMoney(3) }; tabs.Add(tab); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } // Get the tablines for each tab. foreach (var tab in tabs) { tab.MemberTabLines = SelectMemberTabLinesByMemberTabID(tab.MemberTabID).ToList(); } return(tabs); }
/// <summary> /// James Heim /// Created 2019-04-18 /// /// Select the only active MemberTab for the specified MemberID. /// </summary> /// <param name="memberID"></param> /// <returns>The only active Tab for the specified Member.</returns> public MemberTab SelectActiveMemberTabByMemberID(int memberID) { MemberTab memberTab = null; var conn = DBConnection.GetDbConnection(); var cmdText = @"sp_select_active_membertab_by_member_id"; SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MemberID", memberID); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); memberTab = new MemberTab() { MemberTabID = reader.GetInt32(0), MemberID = reader.GetInt32(1), Active = reader.GetBoolean(2), TotalPrice = (decimal)reader.GetSqlMoney(3) }; } } catch (Exception) { throw; } finally { conn.Close(); } // If there is an active tab for the Member, // Retrieve the tab lines. if (memberTab != null) { memberTab.MemberTabLines = SelectMemberTabLinesByMemberTabID(memberTab.MemberTabID).ToList(); } return(memberTab); }
/// <summary author="James Heim" created="2019/04/18"> /// Retrieve the only active MemberTab by the specified Member's ID. /// </summary> /// <param name="memberID"></param> /// <returns>The only active MemberTab</returns> public MemberTab RetrieveActiveMemberTabByMemberID(int memberID) { MemberTab memberTab = null; try { memberTab = _memberTabAccessor.SelectActiveMemberTabByMemberID(memberID); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } return(memberTab); }
/// <summary> /// Jared Greenfield /// Created 2019-04-30 /// /// Select last tab member had. /// </summary> /// <param name="memberID"></param> /// <returns></returns> public MemberTab SelectLastMemberTabByMemberID(int memberID) { MemberTab memberTabs = new MemberTab(); var conn = DBConnection.GetDbConnection(); var cmdText = @"sp_select_last_membertab_by_member_id"; SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MemberID", memberID); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { memberTabs = new MemberTab() { MemberTabID = reader.GetInt32(0), MemberID = reader.GetInt32(1), Active = reader.GetBoolean(2), TotalPrice = (decimal)reader.GetSqlMoney(3) }; } memberTabs.MemberTabLines = SelectMemberTabLinesByMemberTabID(memberTabs.MemberTabID).ToList(); } } catch (Exception) { throw; } finally { conn.Close(); } return(memberTabs); }
/// <summary> /// James Heim /// Created 2019-04-26 /// /// View all tabs for the Member. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnViewPreviousTabs_Click(object sender, RoutedEventArgs e) { MemberTabList tabListWindow = new MemberTabList(_member.MemberID); var result = tabListWindow.ShowDialog(); if (result == true && tabListWindow.SelectedItem != null) { // Retrieve the selected Tab. _memberTab = _memberTabManager.RetrieveMemberTabByID(tabListWindow.SelectedItem.MemberTabID); // Supply a date for the "previous tab" title. _date = tabListWindow.SelectedItem.Date; // Update the form. updateLabels(); loadTabLines(); } }
/// <summary> /// James Heim /// Created 2019-04-25 /// /// Constructor that displays the specified Member's /// active tab. /// </summary> /// <param name="memberID"></param> public MemberTabDetail(int memberID) { InitializeComponent(); // Get the list of Offering Types. _offeringTypes = _offeringManager.RetrieveAllOfferingTypes(); try { _member = _memberManager.RetrieveMember(memberID); _memberTab = _memberTabManager.RetrieveActiveMemberTabByMemberID(memberID); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Retrieving Tab Details."); DialogResult = false; } updateLabels(); loadTabLines(); }
/// <summary> /// Author: Jared Greenfield /// Created On: 2019-05-01 /// Creates a receipt for the user and stores it as HTML /// <paramref name="allGuests">All guests in this reservation</paramref> /// <paramref name="allOfferings">All Offerings</paramref> /// <paramref name="filePath">Path to file being stored in</paramref> /// <paramref name="member">Member who owns the reservation</paramref> /// <paramref name="reservation">The reservation being checked out</paramref> /// <paramref name="tab">The tab of purchases</paramref> /// </summary> /// <returns>True if succeeded, False if failed</returns> public bool generateMemberTabReceipt(Reservation reservation, Member member, List <OfferingVM> allOfferings, MemberTab tab, string filePath, List <GuestRoomAssignmentVM> allGuests) { bool success = false; decimal totalMember = 0; //The member's Total List <decimal> guestTotals = new List <decimal>(); // List of all guest totals // Start Creating the file StreamWriter writer = null; try { writer = new StreamWriter(filePath); //Header Information writer.WriteLine("<!DOCTYPE html>"); writer.WriteLine("<html>"); writer.WriteLine("<head>"); writer.WriteLine("<meta charset='utf - 8'>"); writer.WriteLine("<meta http - equiv = 'X-UA-Compatible' content = 'IE=edge'>"); writer.WriteLine("<title>" + reservation.DepartureDate.ToShortDateString().Replace("/", "-") + member.Email + "</title>"); writer.WriteLine("<link rel='stylesheet' type='text/css' href='css/main.css'>"); writer.WriteLine("</head>"); // Header End //Body Start writer.WriteLine("<body>"); writer.WriteLine("<header class='middle' id='summaryTitle'>Millenial Resorts Summary of Charges</header>"); // Member Information writer.WriteLine("<h1 class='middle'>Member Information</h1>"); writer.WriteLine("<div class='middle memberInfo'>"); writer.WriteLine("<div class='left'>"); writer.WriteLine("<h2><bold>Member Name:</bold> " + member.FirstName + " " + member.LastName + "</h2>"); writer.WriteLine("<h2><bold>Email:</bold> " + member.Email + "</h2>"); writer.WriteLine("</div>"); writer.WriteLine("<div class='right'>"); writer.WriteLine("<h2><bold>Phone Number:</bold> " + member.PhoneNumber.ToFormattedPhoneNumber() + "</h2>"); writer.WriteLine("<h2><bold>Reservation Date:</bold> " + reservation.ArrivalDate.ToShortDateString() + " - " + reservation.DepartureDate.ToShortDateString() + "</h2>"); writer.WriteLine("</div>"); writer.WriteLine("</div>"); // Member Purchases writer.WriteLine("<section>"); writer.WriteLine("<h1 class='middle'>Member Purchases</h1>"); writer.WriteLine("<table>"); writer.WriteLine("<tr>"); writer.WriteLine("<th class='offeringPurchased tableHeader'>Offering Purchased</th>"); writer.WriteLine("<th class='datePurchased tableHeader'>Date Purchased</th>"); writer.WriteLine("<th class='price tableHeader'>Price</th>"); writer.WriteLine("<th class='quantity tableHeader'>Quantity</th>"); writer.WriteLine("<th class='totalColumn tableHeader'>Total</th>"); writer.WriteLine("</tr>"); List <MemberTabLine> memberLine = new List <MemberTabLine>(); foreach (MemberTabLine item in tab.MemberTabLines) { // Only add Member's items (this means no guestID) if (item.GuestID == null) { memberLine.Add(item); } } memberLine = memberLine.OrderByDescending(x => x.DatePurchased).ToList(); // Sort in chronological order //Table Items foreach (MemberTabLine item in memberLine) { writer.WriteLine("<tr>"); writer.WriteLine("<th>" + allOfferings.Find(x => x.OfferingID == item.OfferingID).OfferingName + "</th>"); writer.WriteLine("<th>" + item.DatePurchased.ToUniversalTime() + "</th>"); writer.WriteLine("<th>" + item.Price.ToString("c") + "</th>"); writer.WriteLine("<th>" + item.Quantity + "</th>"); writer.WriteLine("<th>" + (item.Price * item.Quantity).ToString("c") + "</th>"); writer.WriteLine("</tr>"); totalMember += item.Price * item.Quantity; } writer.WriteLine("</table>"); writer.WriteLine("<h2 class='total'> Member Total: " + totalMember.ToString("c") + "</h2>"); writer.WriteLine("</section>"); // Guest Purchases writer.WriteLine("<section>"); writer.WriteLine("<h1 class='middle'>Guest Purchases</h1>"); foreach (GuestRoomAssignmentVM guest in allGuests) { decimal guestTotal = 0; // Rewrite a new section for each Guest involved writer.WriteLine("<div class='guestTab'>"); writer.WriteLine("<h3 class='guestName'> Guest: " + guest.FirstName + " " + guest.LastName + "</h3>"); writer.WriteLine("<table>"); writer.WriteLine("<tr>"); writer.WriteLine("<th class='offeringPurchased tableHeader'>Offering Purchased</th>"); writer.WriteLine("<th class='datePurchased tableHeader'>Date Purchased</th>"); writer.WriteLine("<th class='price tableHeader'>Price</th>"); writer.WriteLine("<th class='quantity tableHeader'>Quantity</th>"); writer.WriteLine("<th class='totalColumn tableHeader'>Total</th>"); writer.WriteLine("</tr>"); List <MemberTabLine> guestLine = new List <MemberTabLine>(); foreach (MemberTabLine item in tab.MemberTabLines) { // Only add Member's items (this means no guestID) if (item.GuestID == guest.GuestID) { guestLine.Add(item); } } guestLine = guestLine.OrderByDescending(x => x.DatePurchased).ToList(); // Sort in chronological order //Table Items foreach (MemberTabLine item in guestLine) { writer.WriteLine("<tr>"); writer.WriteLine("<th>" + allOfferings.Find(x => x.OfferingID == item.OfferingID).OfferingName + "</th>"); writer.WriteLine("<th>" + item.DatePurchased.ToUniversalTime() + "</th>"); writer.WriteLine("<th>" + item.Price.ToString("c") + "</th>"); writer.WriteLine("<th>" + item.Quantity + "</th>"); writer.WriteLine("<th>" + (item.Price * item.Quantity).ToString("c") + "</th>"); writer.WriteLine("</tr>"); guestTotal += item.Price * item.Quantity; } writer.WriteLine("</table>"); writer.WriteLine("<h2 class='total'> Guest Total: " + guestTotal.ToString("c") + "</h2>"); writer.WriteLine("</div>"); guestTotals.Add(guestTotal); } decimal grandTotal = totalMember; foreach (decimal price in guestTotals) { grandTotal += price; } writer.WriteLine("<h2 class='total'> Grand Total: " + grandTotal.ToString("c") + "</h2>"); writer.WriteLine("</section>"); // Footer Start writer.WriteLine("<footer>"); writer.WriteLine("<p>© Millenial Resorts " + DateTime.Now.Year + "</p>"); writer.WriteLine("</footer>"); //Footer End writer.WriteLine("</body>"); //Body End writer.WriteLine("</html>"); success = true; } catch (Exception) { success = false; } finally { writer.Close(); } return(success); }
/// <summary author="Jared Greenfield" created="2019/05/01"> /// Creates a receipt for the user and stores it as HTML /// <paramref name="allGuests">All guests in this reservation</paramref> /// <paramref name="allOfferings">All Offerings</paramref> /// <paramref name="filePath">Path to file being stored in</paramref> /// <paramref name="member">Member who owns the reservation</paramref> /// <paramref name="reservation">The reservation being checked out</paramref> /// <paramref name="tab">The tab of purchases</paramref> /// </summary> /// <returns>True if succeeded, False if failed</returns> public bool generateMemberTabReceipt(Reservation reservation, Member member, List <OfferingVM> allOfferings, MemberTab tab, string filePath, List <GuestRoomAssignmentVM> allGuests) { bool success = false; try { if (reservation == null || member == null || allOfferings == null || tab == null || filePath == null || filePath == "" || allGuests == null) { throw new ArgumentException("Data provided was null, please provide all data needed."); } else { success = _checkoutReceiptAccessor.generateMemberTabReceipt(reservation, member, allOfferings, tab, filePath, allGuests); } } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } return(success); }
public bool generateMemberTabReceipt(Reservation reservation, Member member, List <OfferingVM> allOfferings, MemberTab tab, string filePath, List <GuestRoomAssignmentVM> allGuests) { bool result = false; if (reservation == null || member == null || allOfferings == null || tab == null || filePath == null || filePath == "" || allGuests == null) { result = false; } else { result = true; } return(result); }