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);
        }
 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 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);
            }
        }
        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;
            }
        }