コード例 #1
0
        public ActionResult SubRemoveMovie(Movie obj)
        {
            MovieDal  dal  = new MovieDal();
            TicketDal tdal = new TicketDal();

            string       name  = obj.MovieName.ToString();
            string       date  = obj.date.ToString();
            string       time  = obj.time.ToString();
            List <Movie> exist = (from x in dal.Movies where x.MovieName.Equals(name) && x.date.Equals(date) && x.time.Equals(time)  select x).ToList <Movie>();

            if (exist.Count == 0)
            {
                TempData["msg"]   = "Movie doesn't exist !!!";
                TempData["color"] = "red";
                return(View("RemoveMovie", obj));
            }
            string        hid    = exist[0].HallId;
            List <Ticket> Texist = (from x in tdal.Tickets where x.MovieName.Equals(name) && x.date.Equals(date) && x.time.Equals(time) && x.HallId.Equals(hid) select x).ToList <Ticket>();

            if (Texist.Count != 0)
            {
                TempData["msg"]   = "You can't remove this movie , someone buy it!!!";
                TempData["color"] = "red";
                return(View("RemoveMovie", obj));
            }
            dal.Movies.Remove(exist[0]);
            dal.SaveChanges();
            TempData["msg"]   = "Movie Removed Successfully !!!";
            TempData["color"] = "blue";
            return(View("RemoveMovie"));
        }
コード例 #2
0
        public ActionResult SubShoppingCart()
        {
            TicketDal dal       = new TicketDal();
            string    MovieName = (string)Session["MovieName"];
            int       MovieId;

            Int32.TryParse(Request.Form["MovieId"], out MovieId);
            string        date   = Request.Form["date"];
            string        time   = Request.Form["time"];
            string        HallId = Request.Form["HallId"];
            string        price  = Request.Form["price"];
            string        seat   = Request.Form["seat"];
            List <Ticket> exist  = (from x in dal.Tickets where x.MovieName.Equals(MovieName) &&
                                    x.date.Equals(date) && x.time.Equals(time) &&
                                    x.HallId.Equals(HallId) && x.seat.Equals(seat) select x).ToList <Ticket>();

            if (exist.Count == 0)
            {
                Ticket obj = new Ticket();
                obj.MovieName = MovieName;
                obj.date      = date;
                obj.time      = time;
                obj.HallId    = HallId;
                obj.price     = price;
                obj.seat      = seat;
                obj.MovieId   = MovieId;
                obj.email     = (string)Session["email"];
                dal.Tickets.Add(obj);
                dal.SaveChanges();
                return(RedirectToAction("ShoppingCart", "User"));
            }

            TempData["testmsg"] = "Seat Is Occupied !!!";
            return(View("SelectSeat", GetSeats(MovieId)));
        }
コード例 #3
0
        public ActionResult SubManagingSeats(Hall obj)
        {
            HallDal     dal       = new HallDal();
            List <Hall> HallExist = (from x in dal.Halls where x.HallId.Equals(obj.HallId) select x).ToList <Hall>();

            if (HallExist.Count == 0)
            {
                TempData["msg"]   = "Hall not exist !!!";
                TempData["color"] = "red";
                return(View("ManagingSeats", obj));
            }

            TicketDal     Tickdal = new TicketDal();
            List <Ticket> exist   = (from x in Tickdal.Tickets where x.HallId.Equals(obj.HallId) select x).ToList <Ticket>();

            if (exist.Count != 0)
            {
                TempData["msg"]   = "You cant change number of hall's seats , Someone buy ticket in this hall !!!";
                TempData["color"] = "red";
                return(View("ManagingSeats", obj));
            }

            HallExist[0].NumSeats = obj.NumSeats;
            dal.SaveChanges();

            TempData["msg"]   = "Number of hall's seats  updated successfully !!!";
            TempData["color"] = "blue";
            return(View("ManagingSeats"));
        }
コード例 #4
0
        public ActionResult PaymentSuccess()
        {
            int           TicketId;
            TicketDal     dal = new TicketDal();
            List <Ticket> exist;
            string        email = (string)Session["email"];

            if (Request.Form["TicketId"] != "")
            {
                Int32.TryParse(Request.Form["TicketId"], out TicketId);
                exist = (from x in dal.Tickets where x.id.Equals(TicketId) select x).ToList <Ticket>();
            }
            else
            {
                exist = (from x in dal.Tickets where x.email.Equals(email) select x).ToList <Ticket>();
            }

            foreach (Ticket t in exist)
            {
                t.paid = "yes";
            }

            dal.SaveChanges();
            TempData["success"] = Request.Form["TicketId"];
            return(RedirectToAction("MovieGallery", "User"));
        }
コード例 #5
0
        public ActionResult SubChangeSeat()
        {
            int TicketId;

            Int32.TryParse(Request.Form["change"], out TicketId);
            string        seat   = Request.Form["seat"];
            TicketDal     dal    = new TicketDal();
            Ticket        exist  = (from x in dal.Tickets where x.id == TicketId select x).ToList <Ticket>()[0];
            string        HallId = exist.HallId;
            string        date   = exist.date;
            string        time   = exist.time;
            List <Ticket> temp   = (from x in dal.Tickets where  x.date.Equals(date) && x.time.Equals(time) &&
                                    x.HallId.Equals(HallId) && x.seat.Equals(seat) select x).ToList <Ticket>();

            if (temp.Count != 0)
            {
                TempData["testmsg"]    = "Seat Is Occupied !!!";
                TempData["ChangeSeat"] = Request.Form["change"];
                return(View("SelectSeat", GetSeats(exist.MovieId)));
            }

            dal.Tickets.Remove(exist);
            dal.SaveChanges();
            exist.seat = seat;
            dal.Tickets.Add(exist);
            dal.SaveChanges();

            return(RedirectToAction("ShoppingCart", "User"));
        }
コード例 #6
0
        public ActionResult MovieGallery()
        {
            TicketDal      temp    = new TicketDal();
            MovieViewModel y       = new MovieViewModel();
            List <Ticket>  tickets = (from x in temp.Tickets where x.email.Equals("1") select x).ToList <Ticket>();

            if (tickets.Count == 0)
            {
                Ticket obj = new Ticket()
                {
                    date = "None", time = "None", email = "1", HallId = "None", seat = "None"
                };
                temp.Tickets.Add(obj);
                temp.SaveChanges();
            }
            List <string> emails = (from x in temp.Tickets select x.email).ToList <string>();
            string        key    = MaxKey(emails);

            if (Session["email"] == null)
            {
                Session["email"] = key;
            }

            MovieDal       dal    = new MovieDal();
            MovieViewModel cvm    = new MovieViewModel();
            List <Movie>   movies = dal.Movies.ToList <Movie>();

            cvm.movie  = new Movie();
            cvm.movies = movies;
            return(View(cvm));
        }
コード例 #7
0
 public ActionResult Delete(int id)
 {
     using (TicketDal mdb = new TicketDal())
     {
         return(View(mdb.Tickets.Where(x => x.Id == id).FirstOrDefault()));
     }
 }
コード例 #8
0
        public void SubmitTicket(IncidentTicket incidentTicket)
        {
            incidentTicket.Status = false;

            TicketDal ticketDal = new TicketDal();

            ticketDal.InsertTicket(incidentTicket);
        }
コード例 #9
0
        public int GetPopular(string name)
        {
            TicketDal       dal     = new TicketDal();
            TicketViewModel cvm     = new TicketViewModel();
            List <Ticket>   tickets = (from x in dal.Tickets where x.MovieName.Equals(name) select x).ToList <Ticket>();

            return(tickets.Count);
        }
コード例 #10
0
        public TicketViewModel GetTickets(string key)
        {
            TicketDal       temp    = new TicketDal();
            List <Ticket>   tickets = (from x in temp.Tickets where x.email.Equals(key) select x).ToList <Ticket>();
            TicketViewModel cvm     = new TicketViewModel();

            cvm.tickets = tickets;
            return(cvm);
        }
コード例 #11
0
        public ActionResult ShoppingCart()
        {
            string          email   = (string)Session["email"];
            TicketDal       dal     = new TicketDal();
            TicketViewModel cvm     = new TicketViewModel();
            List <Ticket>   tickets = (from x in dal.Tickets where x.email.Equals(email) select x).ToList <Ticket>();

            cvm.ticket  = new Ticket();
            cvm.tickets = tickets;
            return(View(cvm));
        }
コード例 #12
0
        public void DeleteIncidentTicket()
        {
            if (MessageBox.Show("Are you sure you want to delete a incident?",
                                "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                TicketDal ticketDal = new TicketDal();

                ticketDal.DeleteTicket(SelectedIncidentTicket);

                IncidentTickets = new BindableCollection <IncidentTicket>(ticketDal.GetTickets());
            }

            SelectedIncidentTicket = null;
        }
コード例 #13
0
        public ActionResult Cart()
        {
            if (Session["idUser"] == null)
            {
                Random rnd = new Random();
                int    id  = rnd.Next(1000);
                Session["idUser"] = id;
            }

            using (TicketDal mdb = new TicketDal())
            {
                int d = (int)Session["idUser"];
                return(View(mdb.Tickets.ToList <Ticket>().Where(x => x.Userid == d)));
            }
        }
コード例 #14
0
        public ActionResult ChangeSeat()
        {
            TempData["ChangeSeat"] = Request.Form["MovieId"];
            int TicketId;

            Int32.TryParse(Request.Form["MovieId"], out TicketId);

            TicketDal     dal  = new TicketDal();
            List <Ticket> temp = (from x in dal.Tickets
                                  where x.id.Equals(TicketId)
                                  select x).ToList <Ticket>();


            return(View("SelectSeat", GetSeats(temp[0].MovieId)));
        }
コード例 #15
0
        private void InitialiseTickets()
        {
            _logger.Information("Initialising Tickets");
            IEnumerable <TicketPOCO> tickets = new List <TicketPOCO>();

            try
            {
                tickets = new DatabaseHelper(_remoteAutoTaskDatabaseConnection).GetAllTickets(_taskTypeId);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed intialising Tickets");
            }

            if (tickets.Count() > 0)
            {
                _logger.Information($"{tickets.Count()} Tickets found");
                try
                {
                    _logger.Information($"Inserting Tickets");
                    IEnumerable <TicketModel> ticketModels = from ticket in tickets
                                                             select new TicketModel()
                    {
                        AccountId        = ticket.account_id,
                        CompleteDateTime = ticket.date_completed,
                        CreateDateTime   = ticket.create_time,
                        Description      = ticket.task_description,
                        DueDateTime      = ticket.due_time,
                        Id = ticket.task_id,
                        LastActivityDateTime = ticket.last_activity_time,
                        PriorityId           = ticket.priority_id,
                        StatusId             = ticket.task_status_id,
                        TicketTypeId         = ticket.ticket_type_id,
                        Title = ticket.task_name
                    };


                    TicketDal dal = new TicketDal(_configuration, _logger);
                    dal.Truncate();
                    dal.BulkUpload(ticketModels);
                    _logger.Information($"Completed Tickets Bulk insert");
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Failed Bulk upload of tickets");
                }
            }
        }
コード例 #16
0
        public void Save()
        {
            TicketDal ticketDal = new TicketDal();

            if (IncidentTicket.Solution == null || IncidentTicket.Solution == "")
            {
                IncidentTicket.Status = false;
            }
            else
            {
                IncidentTicket.Status = true;
            }

            ticketDal.UpdateTicket(IncidentTicket);

            Back();
        }
コード例 #17
0
 public ActionResult Delete(int id, Ticket c)
 {
     try
     {
         using (TicketDal mdb = new TicketDal())
         {
             Ticket m = mdb.Tickets.Where(x => x.Id == id).FirstOrDefault();
             mdb.Tickets.Remove(m);
             mdb.SaveChanges();
             return(RedirectToAction("Cart"));
         }
     }
     catch
     {
         return(View());
     }
 }
コード例 #18
0
        private void UpdateTickets()
        {
            _logger.Information("Updating Tickets");
            TicketDal dal        = new TicketDal(_configuration, _logger);
            DateTime? lastUpdate = dal.GetLastUpdated();

            if (lastUpdate == null || lastUpdate.Value.Year == 0)
            {
                _logger.Information("No tickets found trying initalisation");
                InitialiseTickets();
            }
            else
            {
                IEnumerable <TicketModel> ticketModels = new SOAPHelper(_autotaskApiUsername, _autotaskApiPassword, _autotaskApiIntegrationCode, _autotaskApiUrl, _logger)
                                                         .RetriveUpdatedTickets(lastUpdate.Value);
                if (ticketModels != null &&
                    ticketModels.Count() > 0)
                {
                    _logger.Information($"{ticketModels.Count()} updated Tickets found");
                    Domain.Enums.CRUDEnums.ActionResult actionResult = dal.PutOrPost(ticketModels).GetAwaiter().GetResult();
                }
            }
        }
コード例 #19
0
        // GET: Home
        public ActionResult Index()
        {
            //removing ended movies and tickets
            using (MovieDal mdb = new MovieDal())
            {
                foreach (Movie movie in mdb.Movies.ToList <Movie>())
                {
                    int res = DateTime.Compare(movie.Date, DateTime.Now);
                    if (res < 0)
                    {
                        mdb.Movies.Remove(movie);
                        mdb.SaveChanges();
                        TicketDal tdb = new TicketDal();
                        foreach (Ticket t in tdb.Tickets.ToList <Ticket>())
                        {
                            if (t.Movietitle == movie.Title && t.Hall == movie.Hall && DateTime.Compare(movie.Date, t.Date) == 0)
                            {
                                tdb.Tickets.Remove(t);
                                tdb.SaveChanges();
                            }
                        }
                    }
                }
            }

            //creating id for user
            if (Session["idUser"] == null)
            {
                Random rnd = new Random();
                int    id  = rnd.Next(1000);
                Session["idUser"] = id;
            }
            using (MovieDal mdb = new MovieDal())
            {
                return(View("Home", mdb.Movies.ToList <Movie>().Where(x => x.Sale == null)));
            }
        }
コード例 #20
0
        public HallViewModel GetSeats(int MovieId)
        {
            MovieDal temp  = new MovieDal();
            Movie    movie = (from x in temp.Movies where x.id.Equals(MovieId) select x).ToList <Movie>()[0];

            HallDal halldal = new HallDal();
            string  num     = (from x in halldal.Halls where x.HallId.Equals(movie.HallId) select x.NumSeats).ToList <string>()[0];

            TicketDal     dal   = new TicketDal();
            HallViewModel cvm   = new HallViewModel();
            List <string> halls = (from x in dal.Tickets
                                   where x.HallId.Equals(movie.HallId) && x.date.Equals(movie.date) && x.time.Equals(movie.time)
                                   select x.seat).ToList <string>();

            cvm.halls            = halls;
            Session["MovieName"] = movie.MovieName;
            TempData["date"]     = movie.date;
            TempData["time"]     = movie.time;
            TempData["HallId"]   = movie.HallId;
            TempData["price"]    = movie.price;
            TempData["MovieId"]  = movie.id;
            TempData["NumSeats"] = num;
            return(cvm);
        }
コード例 #21
0
        // Constructor
        public DashboardViewModel(ShellViewModel shellViewModel)
        {
            this.shellViewModel = shellViewModel;
            TicketDal ticketDal = new TicketDal();

            // Get values from database and put them in a ObservableValue object
            TicketsPastDeadline = new ObservableValue(ticketDal.GetTicketPastDeadlineAmount(shellViewModel.LoggedUser));
            TicketsPastDeadline.PropertyChanged += (obj, args) =>
            { NotifyOfPropertyChange(() => DeadlineLabel); }; // Adding a listener to the object so the label changes with the value

            TicketsOpen = new ObservableValue(ticketDal.GetOpenTicketAmount(shellViewModel.LoggedUser));
            TicketsOpen.PropertyChanged += (obj, args) =>
            { NotifyOfPropertyChange(() => UnresolvedLabel); };

            TicketsTotal = new ObservableValue(ticketDal.GetTotalTicketAmount(shellViewModel.LoggedUser));
            TicketsTotal.PropertyChanged += (obj, args) =>
            { NotifyOfPropertyChange(() => UnresolvedLabel); };

            // Put the Observable in a collection so they can be bound to the gauges
            DeadlineData = new SeriesCollection
            {
                new PieSeries
                {
                    Title  = "Past deadline",
                    Values = new ChartValues <ObservableValue> {
                        TicketsPastDeadline
                    },
                    DataLabels = false,
                    Fill       = System.Windows.Media.Brushes.Red
                },
                new PieSeries
                {
                    Title  = "Not past deadline",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(TicketsOpen.Value - TicketsPastDeadline.Value)
                    },
                    DataLabels = false,
                    Fill       = System.Windows.Media.Brushes.Gray
                }
            };


            SeriesCollection = new SeriesCollection
            {
                new PieSeries
                {
                    Title  = "open",
                    Values = new ChartValues <ObservableValue> {
                        TicketsOpen
                    },
                    DataLabels = false,
                    Fill       = System.Windows.Media.Brushes.Orange
                },
                new PieSeries
                {
                    Title  = "solved",
                    Values = new ChartValues <ObservableValue> {
                        TicketsSolved
                    },
                    DataLabels = false,
                    Fill       = System.Windows.Media.Brushes.Gray
                }
            };
        }
コード例 #22
0
        public ActionResult seats(int id, Movie m, int seat = -1)
        {
            MovieDal mdb = new MovieDal();
            Movie    m1  = mdb.Movies.ToList <Movie>().Where(x => x.mid == id).FirstOrDefault();

            //out of range seats
            HallDal hd = new HallDal();
            Hall    h  = hd.Halls.ToList <Hall>().Where(x => x.HallNumber == m1.Hall).FirstOrDefault();

            if (h.number_of_seats < seat || seat < 1)
            {
                ViewBag.check = "Out of range seat! , please choose a seat from 1 to " + h.number_of_seats.ToString();
                return(View(m1));
            }


            //check if the seat is in occupied
            TicketDal     tdb   = new TicketDal();
            List <Ticket> t     = tdb.Tickets.ToList <Ticket>();
            int           count = 0;

            foreach (Ticket t1 in t)
            {
                if (t1.Seat == seat && t1.Hall == m1.Hall && t1.Date.Equals(m1.Date))
                {
                    count++;
                }
            }
            //create ticket
            if (count == 0)
            {
                Ticket tt = new Ticket();
                tt.Hall = m1.Hall;
                if (m1.Sale == null)
                {
                    tt.Price = m1.Price;
                }
                else
                {
                    tt.Price = (int)m1.Sale;
                }
                tt.Id         = m1.mid;
                tt.Movietitle = m1.Title;
                tt.Date       = m1.Date;
                tt.Seat       = seat;
                tt.Userid     = (int)Session["idUser"];
                tdb.Tickets.Add(tt);
                tdb.SaveChanges();
                ViewBag.check = "added to cart succefully !";
                //add rating to most popular
                MostDal ms   = new MostDal();
                Most    most = ms.Mosts.ToList <Most>().Where(x => x.Title == m1.Title).FirstOrDefault();
                most.rate           += 1;
                ms.Entry(most).State = EntityState.Modified;
                ms.SaveChanges();
            }
            else
            {
                ViewBag.check = "this seat in occupied !";
            }
            return(View(m1));
        }
コード例 #23
0
        public ActionResult SubManagingHalls(Movie obj)
        {
            TicketDal dal      = new TicketDal();
            MovieDal  Mdal     = new MovieDal();
            string    name     = obj.MovieName.ToString();
            string    date     = obj.date.ToString();
            string    time     = obj.time.ToString();
            string    New_hall = obj.HallId.ToString();

            List <Movie> Mexist = (from x in Mdal.Movies where x.MovieName.Equals(name) && x.date.Equals(date) && x.time.Equals(time) select x).ToList <Movie>();

            if (Mexist.Count == 0)
            {
                TempData["msg"]   = "Movie doesn't exist !!!";
                TempData["color"] = "red";
                return(View("ManagingHalls", obj));
            }

            string        Old_hall = Mexist[0].HallId;
            List <Ticket> exist    = (from x in dal.Tickets where x.MovieName.Equals(name) && x.date.Equals(date) && x.time.Equals(time) && x.HallId.Equals(Old_hall) select x).ToList <Ticket>();

            if (exist.Count != 0)
            {
                TempData["msg"]   = "You cant change movie hall , Someone buy ticket for this movie !!!";
                TempData["color"] = "red";
                return(View("ManagingHalls", obj));
            }

            HallDal     halls     = new HallDal();
            List <Hall> HallExist = (from x in halls.Halls where x.HallId.Equals(New_hall) select x).ToList <Hall>();

            if (HallExist.Count == 0)
            {
                TempData["msg"]   = "Hall not exist !!!";
                TempData["color"] = "red";
                return(View("ManagingHalls", obj));
            }

            List <Movie> NewExist = (from x in Mdal.Movies where  x.date.Equals(date) && x.time.Equals(time) && x.HallId.Equals(New_hall) select x).ToList <Movie>();

            if (NewExist.Count != 0)
            {
                TempData["msg"]   = "There is a movie at the same time and the same hall !!!";
                TempData["color"] = "red";
                return(View("ManagingHalls", obj));
            }
            Mdal.Movies.Remove(Mexist[0]);
            obj.poster   = Mexist[0].poster;
            obj.age      = Mexist[0].age;
            obj.price    = Mexist[0].price;
            obj.preprice = Mexist[0].preprice;
            obj.category = Mexist[0].category;
            Mdal.Movies.Add(obj);
            Mdal.SaveChanges();

            List <Movie> ms = (from x in Mdal.Movies where x.MovieName.Equals(name) && x.date.Equals(date) && x.time.Equals(time) && x.HallId.Equals(New_hall) select x).ToList <Movie>();

            foreach (Ticket t in exist)
            {
                t.MovieId = ms[0].id;
            }
            dal.SaveChanges();

            TempData["msg"]   = "Movie hall  updated successfully !!!";
            TempData["color"] = "blue";
            return(View("ManagingHalls"));
        }