Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            lblOutput.Text = "";
            if (MessageBox.Show("Adding row to the database discards changes\nDo you wish to proceed?",
                "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;
            try
            {
                //refresh connection to client
                client = new EFlatsServiceReference.WcfEFlatsServiceClient("WSHttpBinding_IWcfEFlatsService");
                int profileScore = client.GetStudentData(tbStudentEmail.Text.Trim()).Score;
                bool output = client.AddToWishlist(tbStudentEmail.Text.Trim(),
                    Convert.ToInt32(tbFlatId.Text.Trim()), profileScore);

                if (output)
                    lblOutput.Text = "Application was successfully added";
                else
                    lblOutput.Text = "An Error has accured - Unable to add application";
                RefreshTable();
            }
            catch(Exception e2)
            {
                lblOutput.Text = "Unable to connect to the Database";
            }
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            lblOutput.Text = "";
            if (MessageBox.Show("Adding row to the database discards changes\nDo you wish to proceed?",
                                "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            try
            {
                //refresh connection to client
                client = new EFlatsServiceReference.WcfEFlatsServiceClient("WSHttpBinding_IWcfEFlatsService");
                int  profileScore = client.GetStudentData(tbStudentEmail.Text.Trim()).Score;
                bool output       = client.AddToWishlist(tbStudentEmail.Text.Trim(),
                                                         Convert.ToInt32(tbFlatId.Text.Trim()), profileScore);

                if (output)
                {
                    lblOutput.Text = "Application was successfully added";
                }
                else
                {
                    lblOutput.Text = "An Error has accured - Unable to add application";
                }
                RefreshTable();
            }
            catch (Exception e2)
            {
                lblOutput.Text = "Unable to connect to the Database";
            }
        }
Пример #3
0
        private bool AddFlat()
        {
            try
            {
                //refresh connection to wcf
                client = new EFlatsServiceReference.WcfEFlatsServiceClient("WSHttpBinding_IWcfEFlatsService");
                string result = client.AddFlat(tbLandlordEmail.Text, tbType.Text, tbAddress.Text, tbPostCode.Text, tbCity.Text, Convert.ToDouble(tbRent.Text),
                    Convert.ToDouble(tbDeposit.Text), tbAvailableFrom.Text, tbDescription.Text);

                if (!result.Trim().Equals("Successfully added."))
                    return false;

                GetDataSetToGrid();
                return true;
            }
            catch(Exception e)
            {
                return false;
            }
        }
Пример #4
0
        private bool AddFlat()
        {
            try
            {
                //refresh connection to wcf
                client = new EFlatsServiceReference.WcfEFlatsServiceClient("WSHttpBinding_IWcfEFlatsService");
                string result = client.AddFlat(tbLandlordEmail.Text, tbType.Text, tbAddress.Text, tbPostCode.Text, tbCity.Text, Convert.ToDouble(tbRent.Text),
                                               Convert.ToDouble(tbDeposit.Text), tbAvailableFrom.Text, tbDescription.Text);

                if (!result.Trim().Equals("Successfully added."))
                {
                    return(false);
                }

                GetDataSetToGrid();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            EFlatsServiceReference.WcfEFlatsServiceClient client = new EFlatsServiceReference.WcfEFlatsServiceClient();
            /*
            //register (new) Student Test
            bool registerStudentTest = false;
            registerStudentTest = client.AddStudent("*****@*****.**", "mypassword", false, false, 0, 0, false, 0, false, DateTime.Now, null, null, null, null, null, null, null);
            Console.WriteLine("register student          | result: " + registerStudentTest.ToString());

            //register (same) Student Again and fail Test
            bool registerStudentFailTest = false;
            registerStudentFailTest = client.AddStudent("*****@*****.**", "mypassword", false, false, 0, 0, false, 0, false, DateTime.Now, null, null, null, null, null, null, null);
            Console.WriteLine("register student  (fail)  | result: " + registerStudentFailTest.ToString());

            //register (new landlord with existing student email) Landlord Test
            bool registerLandlordSTTest = false;
            registerLandlordSTTest = client.AddLandlord("*****@*****.**", "mypassword", false, DateTime.Now, null, null, null, null, null, null, null);
            Console.WriteLine("register landlord (fail)  | result: " + registerLandlordSTTest.ToString());

            //register (new) Landlord Test
            bool registerLandlordTest = false;
            registerLandlordTest = client.AddLandlord("*****@*****.**", "mypassword", false, DateTime.Now, null, null, null, null, null, null, null);
            Console.WriteLine("register landlord         | result: " + registerLandlordTest.ToString());

            //register (same) Landlord Again and fail Test
            bool registerLandlordFailTest = false;
            registerLandlordFailTest = client.AddLandlord("*****@*****.**", "mypassword", false, DateTime.Now, null, null, null, null, null, null, null);
            Console.WriteLine("register landlord (fail)  | result: " + registerLandlordFailTest.ToString());

            Console.WriteLine();

            //add flat (new) with exisitng landlord email Test
            bool addFlatTest = false;
            addFlatTest = client.AddApartment("*****@*****.**", "flat", "address", "zipCode", 2000.0, 6000.0, DateTime.Now, DateTime.Now);
            Console.WriteLine("add flat                  | result: " + addFlatTest.ToString());

            //add flat (new) with non exisitng landlord email Test
            bool addFlatNonExistingLandlordTest = false;
            addFlatNonExistingLandlordTest = client.AddApartment("*****@*****.**", "flat", "address", "zipCode", 2000.0, 6000.0, DateTime.Now, DateTime.Now);
            Console.WriteLine("add flat (fail)           | result: " + addFlatNonExistingLandlordTest.ToString());

            //very good catch to set address as PK
            Console.WriteLine();

            //login student with existing account, correct password Test
            bool loginStudentExistingTest = false;
            loginStudentExistingTest = client.Login("*****@*****.**", "mypassword");
            Console.WriteLine("login student             | result: " + loginStudentExistingTest.ToString());

            //login student with non existing account, correct password Test
            bool loginStudentNonExistingTest = false;
            loginStudentNonExistingTest = client.Login("*****@*****.**", "mypassword");
            Console.WriteLine("login student (fail acc)  | result: " + loginStudentNonExistingTest.ToString());

            //login student with existing account, incorrect password Test
            bool loginStudentIncorrectPassTest = false;
            loginStudentIncorrectPassTest = client.Login("*****@*****.**", "mypasswordIncorrect");
            Console.WriteLine("login student (fail pass) | result: " + loginStudentIncorrectPassTest.ToString());

            //get data from existing user (student)
            object[] listStudent = new object[18];
            client.GetData("*****@*****.**").CopyTo(listStudent, 0);
            Console.Write("\n\nFetching student data from database: \n");
            for (int i = 0; i < listStudent.Length; i++)
            {
                Console.Write(listStudent[i] + " ,");
            }
            //userData = initialize...(userData)

            //get data from existing user (landlord)
            object[] listLandlord = new object[18];
            client.GetData("*****@*****.**").CopyTo(listLandlord, 0);
            Console.Write("\n\nFetching landlord data from database: \n");
            for (int i = 0; i < listLandlord.Length; i++)
            {
                Console.Write(listLandlord[i] + " ,");
            }

            //get data from nonexisting user
            object[] list = new object[18];
            client.GetData("*****@*****.**").CopyTo(list, 0);
            Console.Write("\n\nFetching user data from database: \n");
            for (int i = 0; i < list.Length; i++)
            {
                Console.Write(list[i] + " ,");
            }

            Console.WriteLine();
            Console.WriteLine();

            //CHANGE FLAT ID

            //add to wish list
            bool AddToWishlist = false;
            AddToWishlist = client.AddToWishlist(360, "*****@*****.**", 1065);
            Console.WriteLine("add to wishlist           | result: " + AddToWishlist);

            //add to wishlist existing application
            bool AddToWishlistExistingApplication = false;
            AddToWishlistExistingApplication = client.AddToWishlist(360, "*****@*****.**", 1065);
            Console.WriteLine("add to wishlist (fail APP)| result: " + AddToWishlistExistingApplication);

            //add to wish list non existing student
            bool AddToWishlistNonExistingStudent = false;
            AddToWishlistNonExistingStudent = client.AddToWishlist(5000, "*****@*****.**", 1065);
            Console.WriteLine("add to wishlist (fail ST) | result: " + AddToWishlistNonExistingStudent);

            //add to wish list non existing flat
            bool AddToWishlistNonExistingFlat = false;
            AddToWishlistNonExistingStudent = client.AddToWishlist(360, "*****@*****.**", 5000);
            Console.WriteLine("add to wishlist (fail FL) | result: " + AddToWishlistNonExistingFlat);

            //remove from wish list
            bool removeFromWishlist = false;
            removeFromWishlist = client.RemoveFromWishlist(360, 1065);
            Console.WriteLine("remove from wishlist     | result: " + removeFromWishlist);

            //calculate score (3, 1, 0)
            int score = 0;
            score = client.CalculateProfileScore(500, "*****@*****.**");
            Console.WriteLine("calculate profile score    | result: " + score );

            int score = -1;
            score = client.CalculateApplicationScore(400, "*****@*****.**", 60);
            Console.WriteLine("Calculate application score() | result: " + score);

            */
            Console.ReadLine();

            for(int i = 0; i< 100; i++)
            {
                bool registerStudentTest = false;
                registerStudentTest = client.AddStudent("m"+i, "mypassword", false, false, 0, 0, false, 0, false, DateTime.Now, null, null, null, null, null, null, null);
                Console.WriteLine("register student          | result: " + registerStudentTest.ToString());
            }

            Console.ReadLine();
        }