Exemple #1
0
        public List <long> getRentsByDate(FlatSearchCriteria criteria)
        {
            List <long> rents = new List <long>();

            using (var context = new RoomRentEntities())
            {
                rents = context.Rents
                        .Where(c => (c.startDate <= criteria.startDate && c.endDate >= criteria.startDate) || (c.startDate <= criteria.endDate && c.endDate >= criteria.endDate) || (c.startDate >= criteria.startDate && c.endDate <= criteria.endDate))
                        .Select(c => c.address_id)
                        .ToList();
            }

            return(rents);
        }
Exemple #2
0
        public List <WSAddresses> getAvailableRooms(FlatSearchCriteria criteria)
        {
            List <WSAddresses> ws         = new List <WSAddresses>();
            List <long>        rentIds    = dbGetters.getRentsByDate(criteria);
            List <Addresses>   addresses  = dbGetters.getFreeAddresses(rentIds, criteria);
            List <long>        addressIds = new List <long>();

            for (int i = 0; i < addresses.Count; i++)
            {
                addressIds.Add(addresses[i].id);
            }

            List <UserAddresses> userAddresses = dbGetters.getUserAddressList(addressIds, criteria);

            for (int j = 0; j < userAddresses.Count; j++)
            {
                WSAddresses temp = new WSAddresses();
                temp.address_id = addresses[j].id;
                temp.address    = addresses[j].country + ", " + addresses[j].city + ", " + addresses[j].street + " " + addresses[j].house;
                temp.bed_count  = userAddresses[j].bed_count;
                temp.price      = userAddresses[j].price;
                if (userAddresses[j].rate == null)
                {
                    temp.rating = 0;
                }
                else
                {
                    temp.rating = userAddresses[j].rate;
                }
                if (userAddresses[j].rateCount == null)
                {
                    temp.rateCount = 0;
                }
                else
                {
                    temp.rateCount = userAddresses[j].rateCount;
                }

                ws.Add(temp);
            }

            return(ws);
        }
Exemple #3
0
        public List <Addresses> getFreeAddresses(List <long> rentIds, FlatSearchCriteria criteria)
        {
            List <Addresses> addresses = new List <Addresses>();

            using (var context = new RoomRentEntities())
            {
                var temp = context.Addresses
                           .Where(c => !rentIds.Contains(c.id));

                if (!criteria.city.Equals(""))
                {
                    temp = temp.Where(c => c.city.Contains(criteria.city));
                }

                addresses = temp.ToList();
            }

            return(addresses);
        }
Exemple #4
0
        public List <UserAddresses> getUserAddressList(List <long> addressIds, FlatSearchCriteria criteria)
        {
            List <UserAddresses> addresses = new List <UserAddresses>();

            using (var context = new RoomRentEntities())
            {
                var temp = context.UserAddresses
                           .Where(c => addressIds.Contains(c.addr_id));

                if (criteria.kitchen)
                {
                    temp = temp.Where(c => c.kitchen == true);
                }
                if (criteria.parking)
                {
                    temp = temp.Where(c => c.parking == true);
                }
                if (criteria.animals)
                {
                    temp = temp.Where(c => c.animals == true);
                }
                if (criteria.bedCount != null)
                {
                    temp = temp.Where(c => c.bed_count >= criteria.bedCount);
                }
                if (criteria.price != null)
                {
                    if (criteria.over)
                    {
                        temp = temp.Where(c => c.price >= criteria.price);
                    }
                    else
                    {
                        temp = temp.Where(c => c.price <= criteria.price);
                    }
                }

                addresses = temp.ToList();
            }

            return(addresses);
        }