Esempio n. 1
0
        public void GetHolidayhomesTest()
        {
            IHolidayhomeRepository    target   = CreateIHolidayhomeRepository(); // TODO: Initialize to an appropriate value
            IEnumerable <Holidayhome> expected = null;                           // TODO: Initialize to an appropriate value
            IEnumerable <Holidayhome> actual;

            actual = target.GetHolidayhomes();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 2
0
        //Used to display holiday homes. Checks to see if a search enquiry
        //and if there is respond to user search enquiry
        public ViewResult Index(string sortOrder, string searchString)
        {
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "Price" : "";



            var holidayhomes = from hse in HolidayhomeRepository.GetHolidayhomes()
                               select hse;


            if (!String.IsNullOrEmpty(searchString))
            {
                holidayhomes = holidayhomes.Where(hse => hse.holidayhomeno.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.address1.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.address2.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.country.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.email.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.contactno.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.amenities.ToUpper().Contains(searchString.ToUpper()) ||
                                                  hse.price.ToUpper().Contains(searchString.ToUpper()));
            }



            switch (sortOrder)
            {
            case "Holidayhomeno":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.holidayhomeno);
                break;

            case "Address1":
                holidayhomes = holidayhomes.OrderBy(hse => hse.address1);
                break;

            case "Address2":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.address2);
                break;

            case "Country":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.country);
                break;

            case "Email":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.email);
                break;

            case "Contactno":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.contactno);
                break;

            case "Amenities":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.amenities);
                break;

            case "Price":
                holidayhomes = holidayhomes.OrderByDescending(hse => hse.price);
                break;

            //If no sort prefernece given sort by email
            default:
                holidayhomes = holidayhomes.OrderBy(hse => hse.email);
                break;
            }

            return(View(holidayhomes.ToList()));
        }