示例#1
0
        public void DbRecieveListOfFlatTest()
        {
            ServerDatabase.DbFlat dbFlatObj = new ServerDatabase.DbFlat();
            List<MdlFlat> applicationList = dbFlatObj.GetFlats();

            Assert.IsNotNull(applicationList[applicationList.Count - 1].Id);
        }
示例#2
0
 public string AddFlat(string landLordEmail, string type, string address,
     string postCode, string city, double rent, double
     deposit, string availableFrom, string description)
 {
     DbFlat dbFlatObj = new DbFlat();
     MdlFlat mdlFlatObj = CreateFlatObj(landLordEmail, type, address, postCode, city, rent, deposit, availableFrom, description);
     return dbFlatObj.AddFlat(mdlFlatObj);
 }
示例#3
0
        public void AddNewFlatDb()
        {
            bool actualResult = false;
            bool expectedResult = true;

            DbFlat dbFlatObj = new DbFlat();
            MdlFlat mdlFlatObj = new MdlFlat("*****@*****.**", "flat", DateTime.Now, DateTime.Now, 2000.0, 6000.0, "address", "zipCode", "Flat description");
            actualResult = dbFlatObj.Add(mdlFlatObj);

            Assert.AreEqual(expectedResult, actualResult);
        }
示例#4
0
        public bool UpdateFlatStatus(int fId, string status, string dateOfOffer, string availableFrom)
        {
            DbFlat dbFlatObj = new DbFlat();
            MdlFlat mdlFlatObj = new MdlFlat();

            mdlFlatObj.Id = fId;
            mdlFlatObj.Status = status;
            mdlFlatObj.DateOfOffer = dateOfOffer;
            mdlFlatObj.AvailableFrom = availableFrom;

            return dbFlatObj.UpdateFlatsStatus(mdlFlatObj);
        }
示例#5
0
        public bool UpdateFlat(int flatId, double rent, double deposit, string description)
        {
            DbFlat dbFlatObj = new DbFlat();
            MdlFlat mdlFlatObj = new MdlFlat();

            mdlFlatObj.Id = flatId;
            mdlFlatObj.Rent = rent;
            mdlFlatObj.Deposit = deposit;
            mdlFlatObj.Description = description;

            return dbFlatObj.UpdateFlat(mdlFlatObj);
        }
示例#6
0
        public int GetLastQueueNumber(int flatId)
        {
            ServerDatabase.DbStudent dbStudentObj = new ServerDatabase.DbStudent();
            ServerDatabase.DbFlat dbFlatObj = new ServerDatabase.DbFlat();
            //check if FlatId exists
            if(dbFlatObj.CheckFlatExists(flatId))
                //return biggest queue number
                return dbStudentObj.GetLastQueueNumber(flatId);

            Console.WriteLine("Add to wishlist() has failed due to the non existing flat");
            Console.WriteLine("Thread: " + Thread.CurrentThread.ManagedThreadId.ToString() + " Time: " + DateTime.Now.ToString());
            return -2;
        }
示例#7
0
        public static void Update()
        {
            DateTime MyDateTime = DateTime.ParseExact("00:22", "HH:mm", null);
            DbFlat dbFlatObj = new DbFlat();

            Thread.Sleep(5000);
            Console.WriteLine("Update has started @ time: " + DateTime.Now.ToString());

            while (true)
            {
                if (DateTime.Now >= MyDateTime && DateTime.Now <= MyDateTime.AddSeconds(10)) //from x to x + 10sec
                //if(true)
                {
                    DateTime startTime;
                    DateTime finishTime;

                    startTime = DateTime.Now;
                    Console.WriteLine("START Time: " + startTime.ToString("hh.mm.ss.ffffff"));
                    Thread updateScoresThread = new Thread(() => UpdateScores(DbApplications.GetAllApplications()));
                    Thread updateQueueThread = new Thread(() => UpdateQueue(dbFlatObj.GetAllFlats()));

                    updateScoresThread.Start();
                    //update score
                    while (updateScoresThread.IsAlive)
                    {
                    }
                    updateQueueThread.Start();
                    while (updateQueueThread.IsAlive)
                    {
                    }

                    finishTime = DateTime.Now;
                    Console.WriteLine("FINISH Time: " + finishTime.ToString("hh.mm.ss.ffffff"));
                    TimeSpan totalTime = finishTime - startTime;
                    Console.WriteLine("TOTAL Time: " + totalTime);
                    Thread.Sleep(20000); //20
                }
                Thread.Sleep(2000); //2
            }
        }
示例#8
0
        public DataSet searchFlats(int minPrice, int maxPrice, string city, int minDeposit, int maxDeposit)
        {
            List<string[]> flatsList = new List<string[]>();
            DbFlat dbFlat = new DbFlat();
            DataSet fds = dbFlat.GetAllFlats();
            DataTable flatsDT = fds.Tables[0];

            //rewrite for each to while loop
            foreach (DataRow row in flatsDT.Rows)
            {
                if (minPrice <= int.Parse(row["Rent"].ToString()) &&
                   maxPrice >= int.Parse(row["Rent"].ToString()) &&
                   minDeposit <= int.Parse(row["Deposit"].ToString()) &&
                   maxDeposit >= int.Parse(row["Deposit"].ToString()))
                {
                    if (city.Equals(row["City"].ToString().Trim()) || city.Equals(""))
                        flatsList.Add(createArray(row));
                }
            }
            DataTable flatsTable = createDataTable(flatsList);
            DataSet ds = new DataSet();
            ds.Tables.Add(flatsTable);
            return ds;
        }
示例#9
0
 public DataSet GetAllFlats()
 {
     DbFlat dbFlatObj = new DbFlat();
     return dbFlatObj.GetAllFlats();
 }