Esempio n. 1
0
        public bool CrashReport(Exception e)
        {
            if (this == Clients.NoClient)
            {
                return(false);
            }
            if (e is ThreadAbortException)
            {
                return(false);
            }
            var st    = new StackTrace(e, true);
            var frame = st.GetFrame(0);
            var line  = frame.GetFileLineNumber();

            Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth));
            Console.WriteLine(ConsoleColor.Red, "OpenYS Has encountered an error");
            Console.WriteLine(ConsoleColor.Red, "Thus, client &e" + Username + "&c has been disconnected.");
            Console.WriteLine();
            Console.WriteLine(Debug.GetStackTrace(e));
            Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth));
            //Console.WriteLine("Preparing Email.");
            string[] Email = Emailing.PrepareBugReportEmail(e);
            Emailing.SendEmail(Email[0], Email[1]);
            Disconnect("Crash Detected, Disconnecting due to CrashReport(e)");
            return(true);
        }
        public ActionResult ChangeEmployeeStatus(string id, EmploymentAction EmploymentAction)
        {
            AppUser Employee = db.Users.Find(id);

            if (EmploymentAction == EmploymentAction.Hire)
            {
                String Message = "Hello " + Employee.FirstName + ",\n" + "congratulations on your renewed employment with Longhorn Cinemas." +
                                 "\n\n" + "Love,\n" + "Dan";
                Emailing.SendEmail(Employee.Email, "Welcome Back to Longhorn Cinemas", Message);
                Employee.Archived = false;
            }
            if (EmploymentAction == EmploymentAction.Fire)
            {
                String Message = "Hello " + Employee.FirstName + ",\n\n" + "Your employment with Longhorn Cinemas has ended. We're sorry to hear you're leaving the Longhorn Family." +
                                 "\n\n" + "Love,\n" + "Dan";
                Emailing.SendEmail(Employee.Email, "Goodbye, Longhorn Cinemas", Message);
                Employee.Archived = true;
            }

            if (ModelState.IsValid)
            {
                db.Entry(Employee).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("EmployeeHome"));
            }

            ViewBag.AllEmployees = GetAllEmployees();

            // If we got this far, something failed, redisplay form
            return(View());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Showing showing = db.Showings.Find(id);

            // saves showing's schedule to return to page
            int ScheduleID = showing.Schedule.ScheduleID;

            // if schedule is published
            // showing is canceled not delete
            if (showing.Schedule.Published && DateTime.Now < showing.ShowDate)
            {
                // go to the cancelling a showing controller
                showing.Schedule = null;
                db.SaveChanges();

                // returns and loops through each user that bought tickets to the showing
                foreach (UserTicket t in showing.UserTickets)
                {
                    // change status of tickets for canceled showing
                    t.Status     = Status.Cancelled;
                    t.SeatNumber = Seat.Seat;
                    db.SaveChanges();

                    // return popcorn points if showing is canceled
                    if (t.Transaction.Payment == Payment.PopcornPoints)
                    {
                        t.Transaction.User.PopcornPoints += t.Transaction.PopcornPointsSpent;
                        t.CurrentPrice = 0;
                        db.SaveChanges();
                    }
                    else
                    {
                        // take back popcorn points received from credit card payment if showing is canceled
                        t.Transaction.User.PopcornPoints -= Convert.ToInt32(t.CurrentPrice);
                        t.CurrentPrice = 0;
                        db.SaveChanges();
                    }
                    // emails the buyer that the showing has been canceled
                    String Message = "Hello " + t.Transaction.User.FirstName + ",\n" + "The " + showing.ShowDate + showing.Movie.Title
                                     + "showing has been canceled.\n\n" + "Love,\n" + "Dan";
                    Emailing.SendEmail(t.Transaction.User.Email, "Showing Canceled", Message);
                }
                // returns to Schedule's Detail page
                return(RedirectToAction("Details", "Schedules", new { id = ScheduleID }));
            }

            // schedule is unpublished
            if (showing.Schedule.Published == false)
            {
                // delete showing from table
                db.Showings.Remove(showing);
                db.SaveChanges();
                // returns to Schedule's Detail page
                return(RedirectToAction("Details", "Schedules", new { id = ScheduleID }));
            }

            return(View(showing));
        }
        public async Task <ActionResult> RegisterEmployee(RegisterViewModel model)
        {
            var age = DateTime.Now.Year - model.Birthday.Year;

            if (age < 18)
            {
                ViewBag.Error = "Employees must be at least 18 years of age";
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                //Add fields to user here so they will be saved to do the database
                var user = new AppUser
                {
                    UserName = model.Email,
                    Email    = model.Email,
                    //Firstname is an example - you will need to add the rest
                    FirstName     = model.FirstName,
                    MiddleInitial = model.MiddleInitial,
                    LastName      = model.LastName,
                    Street        = model.Street,
                    City          = model.City,
                    State         = model.State,
                    Zip           = model.Zip,
                    PhoneNumber   = model.PhoneNumber,
                    Birthday      = model.Birthday
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                //Once you get roles working, you may want to add users to roles upon creation
                //await UserManager.AddToRoleAsync(user.Id, "Customer");
                // --OR--
                await UserManager.AddToRoleAsync(user.Id, "Employee");


                if (result.Succeeded)
                {
                    ////await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    String Message = "Hello " + model.FirstName + "!\n\ns" + "Welcome to the Longhorn Cinemas family!" +
                                     "\n\n" + "Love,\n" + "Dan";
                    Emailing.SendEmail(model.Email, "Welcome new Longhorn Cinemas Employee!", Message);

                    return(RedirectToAction("EmployeeHome"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult ConfirmTransaction([Bind(Include = "TransactionID,Payment,TransactionDate")] Transaction transaction)
        {
            Transaction t = db.Transactions.Find(transaction.TransactionID);

            //if (t.Payment == Payment.CreditCardNumber1)
            //{
            //    String ccType = (CreditCard.GetCreditCardType(t.User.CreditCardNumber1));
            //    ViewBag.Payment = String.Format("{0}{1}{2}", "**** **** **** ", (t.User.CreditCardNumber1.Substring(t.User.CreditCardNumber1.Length - 4, 4)), " " + ccType);

            //}
            //else if (t.Payment == Payment.CreditCardNumber2)
            //{
            //    String ccType = (CreditCard.GetCreditCardType(t.User.CreditCardNumber2));
            //    ViewBag.Payment = String.Format("{0}{1}{2}", "**** **** **** ", (t.User.CreditCardNumber2.Substring(t.User.CreditCardNumber1.Length - 4, 4)), " " + ccType);
            //}
            //else if (t.Payment == Payment.PopcornPoints)
            //{
            //    ViewBag.Payment = "PopcornPoints";
            //}
            //else
            //{
            //    ViewBag.Payment = "Other credit card";
            //}
            if (Utilities.TransactionValidation.TicketValidation(t) == true)
            {
                if (ModelState.IsValid)
                {
                    foreach (UserTicket ut in t.UserTickets)
                    {
                        ut.Status = Status.Active;
                        db.SaveChanges();
                    }

                    // add popcorn points from transaction
                    if (t.Payment != Payment.PopcornPoints)
                    {
                        Decimal decPopPoints = t.UserTickets.Sum(ut => ut.CurrentPrice);

                        Int32 intPopPoints = Convert.ToInt32(decPopPoints - (decPopPoints % 1));

                        Int32 CurPopPoints = t.User.PopcornPoints;

                        t.User.PopcornPoints = CurPopPoints + intPopPoints;
                    }
                    // save changes to database
                    db.Entry(t).State = EntityState.Modified;
                    db.SaveChanges();

                    String Message = "Hello " + t.User.FirstName + ",\n\n" + "Your order number " + t.TransactionNumber + " has been placed.\n\n" + "Love,\n" + "Dan";
                    Emailing.SendEmail(t.User.Email, "Order Placed", Message);
                    return(RedirectToAction("FinalCheckoutPage", new { id = t.TransactionID }));
                }
            }

            return(View(transaction));
        }
Esempio n. 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Transaction transaction = db.Transactions.Find(id);

            if (transaction.Payment == Payment.PopcornPoints)
            {
                Int32 CurPopPoints = transaction.User.PopcornPoints;
                Int32 intTickets   = transaction.UserTickets.Count();
                Int32 PPTickets    = intTickets * 100;
                transaction.PopcornPointsSpent = 0;
                transaction.User.PopcornPoints = CurPopPoints + PPTickets;
                db.SaveChanges();
            }

            if (transaction.Payment != Payment.PopcornPoints)
            {
                Decimal decPopPoints = transaction.UserTickets.Sum(ut => ut.CurrentPrice);

                Int32 intPopPoints = Convert.ToInt32(decPopPoints - (decPopPoints % 1));

                //Int32 CurPopPoints = transaction .User.PopcornPoints;

                // TODO: Subtract popcorn points or add?
                transaction.User.PopcornPoints -= intPopPoints;
                db.SaveChanges();

                //TODO: DAN - email customers that used credit card that their $ has been refunded
                String Message = "Hello " + transaction.User.FirstName + ",\n\n" + "The transaction number " + transaction.TransactionNumber + " has been cancelled.\n\n" + "Love,\n" + "Dan";
                Emailing.SendEmail(transaction.User.Email, "Transaction Cancelled", Message);
            }

            foreach (UserTicket t in transaction.UserTickets)
            {
                t.CurrentPrice = 0;
                t.Status       = Status.Returned;
                t.SeatNumber   = Seat.Seat;
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public bool BugReport(Exception e)
        {
            if (this == Clients.NoClient)
            {
                return(false);
            }
            if (e is ThreadAbortException)
            {
                return(false);
            }
            var st    = new StackTrace(e, true);
            var frame = st.GetFrame(0);
            var line  = frame.GetFileLineNumber();

            Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth));
            Console.WriteLine(ConsoleColor.Yellow, "OpenYS Has encountered an error");
            Console.WriteLine(ConsoleColor.Yellow, "Thus, clients Packet Processing has been ignored.");
            Console.WriteLine();
            Console.WriteLine(Debug.GetStackTrace(e));
            Console.WriteLine(Strings.Repeat("=", System.Console.WindowWidth));
            string[] Email = Emailing.PrepareBugReportEmail(e);
            Emailing.SendEmail(Email[0], Email[1]);
            return(true);
        }
        public ActionResult Reschedule([Bind(Include = "ShowingID,ShowDate,StartHour,StartMinute,Theater, ShowingPrice")] Showing showing)
        {
            Showing showingToChange = db.Showings.Include(x => x.Schedule)
                                      .FirstOrDefault(x => x.ShowingID == showing.ShowingID);

            DateTime oldShowDate = showingToChange.ShowDate;

            //Alina added things here
            DateTime newShowDate = showing.ShowDate;
            DateTime newEndTime  = newShowDate.Add(showingToChange.Movie.Runtime);
            Theater  newTheater  = showing.Theater;

            String ValResults = Utilities.ScheduleValidation.RescheduleValidation(newShowDate, newEndTime, newTheater);


            // take back to Schedules/Details if Schedule is unpublished
            if (showingToChange.Schedule.Published == false)
            {
                ViewBag.RescheduleError = "Schedule is unpublished. Click 'Edit' to change showings.";
                return(RedirectToAction("Details", "Schedules", new { id = showingToChange.Schedule.ScheduleID }));
            }

            if (ModelState.IsValid)
            {
                showingToChange.ShowDate    = showing.ShowDate;
                showingToChange.ShowDate    = showingToChange.ShowDate.AddHours(showing.StartHour).AddMinutes(showing.StartMinute).AddSeconds(0);
                showingToChange.StartHour   = showing.StartHour;
                showingToChange.StartMinute = showing.StartMinute;
                showingToChange.EndTime     = showingToChange.ShowDate.Add(showingToChange.Movie.Runtime);

                showingToChange.ShowingPrice = Utilities.DiscountPrice.GetBasePrice(showingToChange);

                // check if showing is range of current schedule

                if (ScheduleValidation.ShowingInRange(showingToChange))
                {
                    String ValidationMessage = ScheduleValidation.ShowingValidation(showingToChange);
                    // checks is showing fits into current schedule

                    if (ValidationMessage == "ok" && ValResults == "ok")
                    {
                        db.Entry(showingToChange).State = EntityState.Modified;
                        db.SaveChanges();
                        // email each user who bought a ticket that showing has been rescheduled
                        foreach (UserTicket t in showingToChange.UserTickets)
                        {
                            String Message = "Hello " + t.Transaction.User.FirstName + ",\n\n" + "The " + oldShowDate + " " + showingToChange.Movie.Title
                                             + " showing has been rescheduled to " + showingToChange.ShowDate + ".\n\n" + "Love,\n" + "Dan";
                            Emailing.SendEmail(t.Transaction.User.Email, "Showing Rescheduled", Message);
                        }

                        return(RedirectToAction("Details", "Schedules", new { id = showingToChange.Schedule.ScheduleID }));
                    }
                    else
                    {
                        ViewBag.ErrorMessage  = ValidationMessage;
                        ViewBag.ErrorMessage2 = ValResults;
                    }
                }
                else
                {
                    ViewBag.OutOfRange = "Show date is out of schedule date range";
                }
            }

            return(View(showing));
        }
        public async Task <ActionResult> RegisterCustomer(RegisterViewModel model)
        {
            var age = DateTime.Now.Year - model.Birthday.Year;

            if (age < 13)
            {
                ViewBag.Error = "Customers must be 13 years of age.";
                return(View(model));
            }

            List <String> AllEmails = new List <String>();

            foreach (AppUser user in db.Users)
            {
                AllEmails.Add(user.Email);
            }

            if (AllEmails.Contains(model.Email))
            {
                ViewBag.Error = "An account already exists for that email address.";
                return(View(model));
            }
            if (ModelState.IsValid)
            {
                //Add fields to user here so they will be saved to do the database
                var user = new AppUser
                {
                    UserName      = model.Email,
                    Email         = model.Email,
                    FirstName     = model.FirstName,
                    MiddleInitial = model.MiddleInitial,
                    LastName      = model.LastName,
                    Street        = model.Street,
                    City          = model.City,
                    State         = model.State,
                    Zip           = model.Zip,
                    PhoneNumber   = model.PhoneNumber,
                    Birthday      = model.Birthday
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                //Once you get roles working, you may want to add users to roles upon creation
                await UserManager.AddToRoleAsync(user.Id, "Customer");

                // --OR--
                // await UserManager.AddToRoleAsync(user.Id, "Employee");


                if (result.Succeeded)
                {
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    String Message = "Hello " + model.FirstName + ",\n" + "a Longhorn Cinemas account has been created for you." +
                                     ".\n\n" + "Love,\n" + "Dan";
                    Emailing.SendEmail(model.Email, "Your Longhorn Cinemas Account", Message);

                    return(RedirectToAction("EmployeeHome"));
                }
                AddErrors(result);
            }


            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 10
0
        //TODO: Removing tickets
        public ActionResult DeleteConfirmed(int id)
        {
            UserTicket userTicket = db.UserTickets.Find(id);

            if (userTicket.Status == Status.Pending)
            {
                // delete ticket
                Transaction t = userTicket.Transaction;
                t.UserTickets.Remove(userTicket);
                db.UserTickets.Remove(userTicket);
                db.SaveChanges();

                // recaculate prices for all tickets in transaction
                foreach (UserTicket ticket in t.UserTickets)
                {
                    ticket.CurrentPrice    = DiscountPrice.GetTicketPrice(ticket);
                    db.Entry(ticket).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("PendingDetails", "Transactions", new { id = t.TransactionID }));
            }
            else
            {
                Transaction t = userTicket.Transaction;

                if (userTicket.Showing.ShowDate > DateTime.Now.AddHours(1))
                {
                    userTicket.CurrentPrice = 0;
                    userTicket.Status       = Status.Returned;
                    userTicket.SeatNumber   = Seat.Seat;
                    db.SaveChanges();

                    if (t.Payment == Payment.PopcornPoints)
                    {
                        t.User.PopcornPoints += 100;
                        t.PopcornPointsSpent -= 100;
                        db.SaveChanges();
                    }

                    if (t.Payment != Payment.PopcornPoints)
                    {
                        Int32 intPopPoints = Convert.ToInt32(userTicket.CurrentPrice - (userTicket.CurrentPrice % 1));

                        t.User.PopcornPoints -= intPopPoints;
                        db.SaveChanges();

                        String Message = "Hello " + userTicket.Transaction.User.FirstName + ",\n\n" + "The ticket for " + userTicket.Showing.ShowDate +
                                         userTicket.Showing.Movie.Title + " has been canceled.\n\n" + "Love,\n" + "Dan";
                        Emailing.SendEmail(userTicket.Transaction.User.Email, "Ticket Canceled", Message);
                    }
                    return(RedirectToAction("Details", "Transactions", new { id = t.TransactionID }));
                }
                else
                {
                    ViewBag.Error = "Tickets for movies less than one hour from the current time may not be cancelled";
                }

                return(View(userTicket));
            }
        }