protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            IUser UserServices = new UserServices();
            UserModelDTO NewUser = new UserModelDTO();
            if (PersonalInfoContainer.FindControl("FirstName") is TextBox)
            {
                NewUser.FirstName = ((TextBox)PersonalInfoContainer.FindControl("FirstName")).Text;
            }
            if (PersonalInfoContainer.FindControl("LastName") is TextBox)
            {
                NewUser.LastName = ((TextBox)PersonalInfoContainer.FindControl("LastName")).Text;
            }
            NewUser.UserName = RegisterUser.UserName;
            NewUser.UserID = UserServices.GetUserID(NewUser.UserName);
            NewUser.personTypeID = UserServices.GetUserType("User");
            NewUser.Password = RegisterUser.Password;
            bool check = UserServices.CreateNewUser(NewUser);

            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }
            Response.Redirect(continueUrl);
        }
        //Method that extracts all data to populate the tables
        private void LoadData(LoadDataArgs e)
        {
            IUser UserServices = new UserServices();
            //UserID extraction from DataBase
            Guid UserID = UserServices.GetUserID(e.UserName);

            IList<UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserID);
            IList<UserRatingDTO> ListOfRatings = UserServices.GetAllUserRatings(UserID);
            IList<UserFavoriteMovieDTO> ListOfFavoriteMovies = UserServices.GetFavoriteMoviesByUser(UserID);
            IList<String> ListOfMovies = UserServices.GetMoviesToWhichTheUserCommented(UserID);

            //Data transfer to MyAre MODEL
            Myview.Model.ListOfComments = new List<CommentLine>();
            Myview.Model.ListOfRatings = new List<RatingLine>();
            Myview.Model.ListOfFavorites = new List<FavoriteLine>();
            Myview.Model.ListOfMovies = new List<String>();
            foreach (var item in ListOfComments)
            {
                CommentLine row = new CommentLine();
                row.CommentID = item.commentID;
                row.MovieTitle = item.MovieTitle;
                row.CommentContent = item.Content;
                row.MovieID = item.movieID;
                Myview.Model.ListOfComments.Add(row);
            }

            foreach (var item in ListOfMovies)
            {
                String row1 = null;
                row1 = item;
                bool check = Myview.Model.ListOfMovies.Contains(row1);
                if (!check)
                {
                    Myview.Model.ListOfMovies.Add(row1);
                }
            }

            foreach (var item in ListOfRatings)
            {
                RatingLine row = new RatingLine();
                row.MovieTitle = item.MovieTitle;
                row.Rating = item.rate.ToString();
                Myview.Model.ListOfRatings.Add(row);

            }

            foreach (var item in ListOfFavoriteMovies)
            {
                FavoriteLine row = new FavoriteLine();
                row.MovieTitle = item.MovieTitle;
                Myview.Model.ListOfFavorites.Add(row);
            }
        }
        //Method that extracts all data to populate the tables
        private void LoadData(EventArgs e)
        {
            //Data Extraction from the database
               Guid UserIDTemp = new Guid();
               UserIDTemp=Guid.Parse( "e441de1f-9877-4074-bcd7-7b46bf3a7143");

               IUser UserServices = new UserServices();
               IList<UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserIDTemp);
               IList<UserRatingDTO> ListOfRatings = UserServices.GetAllUserRatings(UserIDTemp);
               IList<UserFavoriteMovieDTO> ListOfFavoriteMovies = UserServices.GetFavoriteMoviesByUser(UserIDTemp);

               //Data transfer to MyAre MODEL
               Myview.Model.ListOfComments = new List<CommentLine>();
               Myview.Model.ListOfRatings = new List<RatingLine>();
               Myview.Model.ListOfFavorites = new List<FavoriteLine>();
               foreach (var item in ListOfComments)
               {
               CommentLine row = new CommentLine();
               row.MovieTitle = item.MovieTitle;
               row.CommentContent = item.Content;
               Myview.Model.ListOfComments.Add(row);
               }

               foreach (var item in ListOfRatings)
               {
               RatingLine row = new RatingLine();
               row.MovieTitle = item.MovieTitle;
               row.Rating = item.rate.ToString();
               Myview.Model.ListOfRatings.Add(row);

               }

               foreach (var item in ListOfFavoriteMovies)
               {
               FavoriteLine row = new FavoriteLine();
               row.MovieTitle = item.MovieTitle;
               Myview.Model.ListOfFavorites.Add(row);
               }

               Myview.Model.ChosenMovie = "It works";
        }
        private void LoadData(PerformanceDataArgs pda)
        {
            String PerformanceID = pda.PerformanceID;
            IUser UserServices = new UserServices();
            int performanceID;
            bool isInt = int.TryParse(PerformanceID, out performanceID);
            if (isInt)
            {
                UserPerformanceDTO CurrentPerformance = new UserPerformanceDTO();
                CurrentPerformance = UserServices.GetPerformanceByID(performanceID);
                this.PaymentView.Model.MovieTitle = CurrentPerformance.MovieTitle;
                string theaterDetails = string.Format("{0}, {1}.", CurrentPerformance.TheaterName, CurrentPerformance.TheaterAddress);
                this.PaymentView.Model.TheaterDetails = theaterDetails;
                string performance = string.Format("Date: {0}, Starting Time: {1}, Duration: {2}, Hall: {3}.",
                    CurrentPerformance.Date,
                    CurrentPerformance.StartingTime,
                    CurrentPerformance.Duration,
                    CurrentPerformance.roomNumber);
                this.PaymentView.Model.PerformanceDetails = performance;
                this.PaymentView.Model.Price = CurrentPerformance.price.ToString();

            }
        }
 private void Submit(OrderArgs or)
 {
     IUser UserServices = new UserServices();
     int performanceID = or.PerformanceID;
     UserOrderDTO NewOrder = new UserOrderDTO();
     NewOrder.PerformanceID = performanceID;
     Guid UserID = UserServices.GetUserID(or.UserName);
     NewOrder.UserID = UserID;
     NewOrder.NumberOfSeats = or.NumberOfSeats;
     NewOrder.TotalPrice = or.TotalPrice;
     UserOrderDTO OrderOut = new UserOrderDTO();
     OrderOut = UserServices.CreateOrder(NewOrder);
     if (OrderOut.isValid)
     {
         this.PaymentView.Model.ValidOrder = string.Format("The order was processed correctely, your order number: {0}, Enjoy the movie.",
             OrderOut.OrderID.ToString());
         this.PaymentView.Model.IsValidOrder = true;
     }
     else
     {
         this.PaymentView.Model.ValidOrder = string.Format("The order was not saved, please try again or contact cutomer service.");
         this.PaymentView.Model.IsValidOrder = false;
     }
 }
 //Method that processes the City Selection
 private void CitySelection(SelectedParamterArgs esp)
 {
     IUser UserServices = new UserServices();
     IList <UserTheaterDTO> ListOfTheters = new List<UserTheaterDTO>();
     String SelectedCity = esp.SelectedValue;
     String SelectedMovie = esp.OptionalSlectedValue;
     int movieID = int.Parse(SelectedMovie);
     ListOfTheters = UserServices.GetTheatersByCity(SelectedCity,movieID);
     TicketView.Model.TheaterList = new List<TheaterLine>();
     foreach (var item in ListOfTheters)
     {
         TheaterLine row = new TheaterLine();
         row.TheaterID = item.TheaterID.ToString();
         row.TheaterName = item.TheaterName;
         row.Address = item.TheaterAddress;
         TicketView.Model.TheaterList.Add(row);
     }
 }
        //Method that processes Theater selection
        private void TheaterSelection(SelectedParamterArgs esp)
        {
            IUser UserServices = new UserServices();
            IList<UserPerformanceDTO> ListOfPerformances = new List<UserPerformanceDTO>();

            Guid TheaterID = new Guid();
            String SelectedTheaterID = esp.SelectedValue;
            bool isGuid = Guid.TryParse(SelectedTheaterID, out TheaterID);

            int movieID = 0;
            String SelectedMovieID = esp.OptionalSlectedValue;
            bool isInt = int.TryParse(SelectedMovieID, out movieID);

            if (isGuid&&isInt)
            {
                ListOfPerformances = UserServices.GetPerformancesByTheaterIDandMovieID(TheaterID, movieID);
                TicketView.Model.PerformanceList = new List<PerformanceLine>();
                foreach (var item in ListOfPerformances)
                {
                    PerformanceLine row = new PerformanceLine();
                    row.PerformanceID = item.performanceID.ToString();
                    row.PerformaceDate = item.Date;
                    row.StartingTime = item.StartingTime;
                    row.Duration = item.Duration;
                    row.Price = item.price.ToString();
                    TicketView.Model.PerformanceList.Add(row);
                }
            }
        }
        //Method that process Movie selection - the movie was selected by pressing the button
        private void MovieWasSelected(SelectedParamterArgs esp)
        {
            int movieID = 0;
            bool checkIfInt = int.TryParse(esp.SelectedValue.ToString(), out movieID);
            if (checkIfInt)
            {
                IUser UserServices = new UserServices();
                IList<String> ListOfCities = new List<String>();
                ListOfCities = UserServices.GetCitiesByMovieID(movieID);
                List<String> ListOfCitiesRevised = new List<String>();
                TicketView.Model.CityList = new List<CityLine>();
                //Running loop in order to remove repeation of cities in the list
                foreach (var item in ListOfCities)
                {
                    if(!ListOfCitiesRevised.Contains(item))
                    {
                        ListOfCitiesRevised.Add(item);
                    }
                }

                TicketView.Model.CityList = new List<CityLine>();
                //Adding first value to CityList that will be dispalyed
                CityLine row1 = new CityLine();
                row1.CityID = "None";
                row1.CityName = "Select city...";
                TicketView.Model.CityList.Add(row1);
                //Loop to transfer data from City Revised to List that will be displayed= List<CityLine>
                foreach (var item in ListOfCitiesRevised)
                {
                    CityLine row = new CityLine();
                    row.CityID = item;
                    row.CityName = item;
                    TicketView.Model.CityList.Add(row);
                }

            }
        }
 //Method that processes Movie selection - presents short description of the movie
 private void MovieSelection(SelectedParamterArgs esp)
 {
     IUser UserServices = new UserServices();
     String Description = null;
     String SelectedMovieID = esp.SelectedValue;
     int movieID = 0;
     bool checkGuid= int.TryParse(SelectedMovieID, out movieID);
     if(checkGuid)
     Description = UserServices.GetMovieDescriptionByMovieID(movieID);
     TicketView.Model.MovieDescription = Description;
 }
        //Method that load data, load movies list
        private void LoadData(EventArgs ex)
        {
            IUser UserServices = new UserServices();
            IList<UserFavoriteMovieDTO> ListOfMovies = UserServices.GetListOfMovies();
            TicketView.Model.MovieList = new List<MovieLine>();
            foreach (var item in ListOfMovies)
            {
                MovieLine row = new MovieLine();
                row.MovieID = item.movieID.ToString();
                row.MovieTitle = item.MovieTitle;
                TicketView.Model.MovieList.Add(row);

            }
        }
        private void UpdateDleteComment(TreeViewUpdateArgs tua)
        {
            IUser UserServices = new UserServices();
            bool check = false;
            if (tua.ActionToPerform == "Delete")
            {
                int commentID = tua.ChildID;
                check = UserServices.DeleteComment(commentID);
            }
            else if (tua.ActionToPerform == "Update")
            {
                UserCommentDTO CommentToUpdate = new UserCommentDTO();
                CommentToUpdate.commentID = tua.ChildID;
                CommentToUpdate.Content = tua.ChildContent;
                check = UserServices.UpdateComment(CommentToUpdate);
            }

            if (check)
            {

                Guid UserID = UserServices.GetUserID(tua.UserName);
                IList<UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserID);
                IList<String> ListOfMovies = UserServices.GetMoviesToWhichTheUserCommented(UserID);
                Myview.Model.IsValidTransastion = true;
                Myview.Model.ListOfComments = new List<CommentLine>();
                Myview.Model.ListOfMovies = new List<String>();
                foreach (var item in ListOfComments)
                {
                    //creating list of comments
                    CommentLine row = new CommentLine();
                    row.CommentID = item.commentID;
                    row.MovieTitle = item.MovieTitle;
                    row.CommentContent = item.Content;
                    row.MovieID = item.movieID;
                    Myview.Model.ListOfComments.Add(row);
                }
                foreach (var item in ListOfMovies)
                {
                    String row1 = null;
                    row1 = item;
                    bool checkIfContains = Myview.Model.ListOfMovies.Contains(row1);
                    if (!checkIfContains)
                    {
                        Myview.Model.ListOfMovies.Add(row1);
                    }
                }
            }
        }
        //Method that removes movie from favorites
        private void RemoveMovieFromFavorites(GridUpdateArgs gua)
        {
            string selectedMovieTitle = gua.ID;
            string userName = gua.UserName;
            IUser UserServices = new UserServices();
            Guid UserID = UserServices.GetUserID(userName);
            bool check = UserServices.RemoveMovieFromFavoriteList(UserID, selectedMovieTitle);

            if (check)
            {
                Myview.Model.IsValidTransastion = true;
            }
            else
            {
                Myview.Model.IsValidTransastion = false;
            }
        }