Esempio n. 1
0
        public void FindTopic()
        {
            TopicDal a  = new TopicDal(connectionString);
            var      gl = a.Find("Title");

            Assert.IsTrue(gl.Count == 0 || gl[0].ID != -1);
        }
Esempio n. 2
0
        public void DeleteTopic()
        {
            TopicDal a   = new TopicDal(connectionString);
            var      res = a.Delete(3);

            Assert.IsTrue(res != -1);
        }
Esempio n. 3
0
        public void GetSortTopic()
        {
            TopicDal a  = new TopicDal(connectionString);
            var      gl = a.GetSort();

            Assert.IsTrue(gl.Count >= 2 && String.Compare(gl[0].Title, gl[1].Title) < 0);
        }
Esempio n. 4
0
        public void GetAllTopic()
        {
            TopicDal a  = new TopicDal(connectionString);
            var      gl = a.GetAll();

            Assert.IsTrue(gl.Count == 0 || gl[0].ID != -1);
        }
 public UserManager(UserDTO user)
 {
     currentUser = user;
     userDal     = new UserDal(user.Email);
     topicDal    = new TopicDal(user.Email);
     commentDal  = new CommentDal(user.Email);
 }
Esempio n. 6
0
        public void AddTopic()
        {
            TopicDal a   = new TopicDal(connectionString);
            TopicDTO top = new TopicDTO();

            top.ID        = -1;
            top.Title     = "Title";
            top.Text      = "text";
            top.CommentID = 99999999;
            var res = a.Add(top);

            Assert.IsTrue(res.ID == -1);
        }
Esempio n. 7
0
        public void AddTopic()
        {
            UserDTO user = new UserDTO();

            user.Email    = connectionString;
            user.Login    = login;
            user.Password = login;
            user.IDUser   = -1;
            UserManager um = new AdminManager(user);

            TopicDal a   = new TopicDal(connectionString);
            TopicDTO top = new TopicDTO();

            top.ID        = -1;
            top.Title     = "Title";
            top.Text      = "text";
            top.CommentID = 99999999;
            var res = um.AddTopic("Topic", "Text", "Comm");

            Assert.IsTrue(res);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Default;

            //string connStr = ConfigurationManager.ConnectionStrings["ManagerNews"].ConnectionString;

            string connectionString = "Data Source=localhost;Initial Catalog=ManagerNews;Integrated Security=True";

            topicDal   = new TopicDal(connectionString);
            userDal    = new UserDal(connectionString);
            commentDal = new CommentDal(connectionString);

            uint isLogIn = LogIn();

            while (isLogIn != 0)
            {
                //Console.Clear();
                Console.WriteLine("\n\n What do you want to DO?");
                Console.WriteLine("\ntype 'l' to get List of entities");
                Console.WriteLine("type 's' to Sort entity");
                Console.WriteLine("type 'f' to Find entity");
                if (isLogIn == 2)
                {
                    Console.WriteLine("type 'a' to Add entity");
                    Console.WriteLine("type 'r' to Remove entity");
                }
                //...
                Console.WriteLine("type 'o' to logOut");
                Console.WriteLine("type 'q' to Quit");
                try
                {
                    char c = char.Parse(Console.ReadLine());

                    switch (c)
                    {
                    case 'l':     //show list of entities
                    {
                        Console.WriteLine("\nList of all entity:");
                        PrintAll();
                    }
                    break;

                    case 's':     //
                    {
                        Console.WriteLine("\nSorted by Title:");
                        PrintSorted();
                    }
                    break;

                    case 'a':     //create new entity
                    {
                        Console.WriteLine("Add:");
                        AddUser();
                    }
                    break;

                    case 'r':     //remove entity
                    {
                        Console.WriteLine("If you are the Owner or Administrator you can delete the user.\nEnter ID:");
                        if (isLogIn == 2)
                        {
                            int id = int.Parse(Console.ReadLine());
                            topicDal.Delete(id);
                        }
                        else
                        {
                            throw new Exception("Not permission");
                        }
                    }
                    break;

                    case 'f':
                    {
                        Console.WriteLine("Please, enter a word or letters or a price: ");         // find by Title
                        string ttl = Console.ReadLine().ToString();
                        Find(ttl);
                    }
                    break;

                    case 'o':
                    {
                        isLogIn = LogIn();
                    }
                    break;

                    case 'q':
                        return;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }