-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplorePropertiesController.cs
200 lines (186 loc) · 10.9 KB
/
ExplorePropertiesController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
using StudentsRooms.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace StudentsRooms.Controllers
{
public class ExplorePropertiesController : BaseController
{
StudentsRoomsEntities db = new StudentsRoomsEntities();
// GET: ExploreProperties
public ActionResult Index(string SortBy, string DistrictId, string DistrictName, string property_purpose, string property_type, string property_room_no)
{
if (Request.QueryString.Count > 0 && Request.QueryString["DistrictId"] != null)
{
var PropertiesData = (from p in db.Property_Table
join o in db.Owner_Table on p.owner_id equals o.owner_id
join st in db.States on p.property_state equals st.StateId
join dt in db.Districts on p.property_district equals dt.DistrictId
join ct in db.Tehsiles on p.property_city equals ct.TehsilId
select new mix
{
StateName = st.StateName,
DistrictName = dt.DistrictName,
TehsilName = ct.TehsilName,
owner_name = o.owner_name,
owner_mobile1 = o.owner_mobile1,
owner_mobile2 = o.owner_mobile2,
owner_email = o.owner_email,
property_name = p.property_name,
property_purpose = p.property_purpose,
property_type = p.property_type,
property_price = p.property_price,
property_rent = p.property_rent,
property_size = p.property_size,
property_room_no = p.property_room_no,
property_bathroom_no = p.property_bathroom_no,
property_kitchen_no = p.property_kitchen_no,
property_balcony_no = p.property_balcony_no,
property_age = p.property_age,
property_image1 = p.property_image1,
property_image2 = p.property_image2,
property_image3 = p.property_image3,
property_image4 = p.property_image4,
property_image5 = p.property_image5,
property_address = p.property_address,
property_city = p.property_city,
property_district = p.property_district,
property_state = p.property_state,
property_postal_code = p.property_postal_code,
property_parking = p.property_parking,
property_wifi = p.property_wifi,
property_ac = p.property_ac,
property_water_supply = p.property_water_supply,
property_window = p.property_window,
property_video = p.property_video,
property_map = p.property_map
}).ToList();
ViewBag.PropertiesJoinData = PropertiesData;
var Properties = PropertiesData.Where(p => p.property_district.ToString() == DistrictId).ToList();
if (!string.IsNullOrEmpty(property_purpose))
{
if (property_purpose == "Sale")
{
Properties = Properties.Where(p => p.property_purpose == property_purpose).ToList();
}
if (property_purpose == "Rent")
{
Properties = Properties.Where(p => p.property_purpose == property_purpose).ToList();
}
}
if (!string.IsNullOrEmpty(property_type))
{
if (property_type == "1")
{
Properties = Properties.Where(p => p.property_type == property_type).ToList();
}
if (property_type == "2")
{
Properties = Properties.Where(p => p.property_type == property_type).ToList();
}
if (property_type == "3")
{
Properties = Properties.Where(p => p.property_type == property_type).ToList();
}
if (property_type == "4")
{
Properties = Properties.Where(p => p.property_type == property_type).ToList();
}
}
if (!string.IsNullOrEmpty(property_room_no))
{
if (property_room_no == "1")
{
Properties = Properties.Where(p => p.property_room_no.ToString() == property_room_no).ToList();
}
if (property_room_no == "2")
{
Properties = Properties.Where(p => p.property_room_no.ToString() == property_room_no).ToList();
}
if (property_room_no == "3")
{
Properties = Properties.Where(p => p.property_room_no.ToString() == property_room_no).ToList();
}
if (property_room_no == "4")
{
Properties = Properties.Where(p => p.property_room_no.ToString() == property_room_no).ToList();
}
if (property_room_no == "5")
{
Properties = Properties.Where(p => p.property_room_no.ToString() == property_room_no).ToList();
}
}
ViewBag.PropertiesJoinData = Properties;
return View();
}
else
{
var PropertiesData = (from p in db.Property_Table
join o in db.Owner_Table on p.owner_id equals o.owner_id
join st in db.States on p.property_state equals st.StateId
join dt in db.Districts on p.property_district equals dt.DistrictId
join ct in db.Tehsiles on p.property_city equals ct.TehsilId
select new mix
{
StateName = st.StateName,
DistrictName = dt.DistrictName,
TehsilName = ct.TehsilName,
owner_name = o.owner_name,
owner_mobile1 = o.owner_mobile1,
owner_mobile2 = o.owner_mobile2,
owner_email = o.owner_email,
property_name = p.property_name,
property_purpose = p.property_purpose,
property_type = p.property_type,
property_price = p.property_price,
property_rent = p.property_rent,
property_size = p.property_size,
property_room_no = p.property_room_no,
property_bathroom_no = p.property_bathroom_no,
property_kitchen_no = p.property_kitchen_no,
property_balcony_no = p.property_balcony_no,
property_age = p.property_age,
property_image1 = p.property_image1,
property_image2 = p.property_image2,
property_image3 = p.property_image3,
property_image4 = p.property_image4,
property_image5 = p.property_image5,
property_address = p.property_address,
property_city = p.property_city,
property_district = p.property_district,
property_state = p.property_state,
property_postal_code = p.property_postal_code,
property_parking = p.property_parking,
property_wifi = p.property_wifi,
property_ac = p.property_ac,
property_water_supply = p.property_water_supply,
property_window = p.property_window,
property_video = p.property_video,
property_map = p.property_map
}).ToList();
switch (SortBy)
{
case "Recent":
PropertiesData = PropertiesData.OrderBy(p => p.rts).ToList();
break;
case "Oldest":
PropertiesData = PropertiesData.OrderByDescending(p => p.rts).ToList();
break;
case "LowToHigh":
PropertiesData = PropertiesData.OrderBy(p => p.property_price).ToList();
break;
case "HighToLow":
PropertiesData = PropertiesData.OrderByDescending(p => p.property_name).ToList();
break;
default:
PropertiesData = PropertiesData.OrderBy(p => p.property_price).ToList();
break;
}
ViewBag.PropertiesJoinData = PropertiesData;
return View();
}
}
}
}