public ActionResult ListRoomDetail(string roomstyleID) { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var result = dbSA.Room.Where(r => r.RoomStyleID.ToString() == roomstyleID); List <CRoomViewModel> rooom_VM_lt = new List <CRoomViewModel>(); var test = result.ToList(); foreach (var item in result) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item }; rooom_VM_lt.Add(room_VM); } abtRoom_VM.roomViewModels = rooom_VM_lt; ViewData.Model = abtRoom_VM; ViewBag.roomstyleid = roomstyleID; return(View(abtRoom_VM)); }
public ActionResult PartialResult(string buildcaseID, string roomstyleID, string peoplecount, string amountrent) { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var result = from t in dbSA.BuildCase join r in dbSA.Room on t.ID equals r.BuildCaseID join rms in dbSA.RoomStyle on r.RoomStyleID equals rms.ID where t.ID == buildcaseID && r.RoomStyleID.ToString() == roomstyleID && rms.MaxNumberOfPeople.ToString() == peoplecount //rms.Rent.ToString() == amountrent select new { b = t, r = r, rms = rms }; List <CRoomStyleViewModel> roomstyle_VM_lt = new List <CRoomStyleViewModel>(); List <CBuildCaseViewModel> buildcase_VM_lt = new List <CBuildCaseViewModel>(); List <CRoomViewModel> room_VM_lt = new List <CRoomViewModel>(); var test = result.ToList(); foreach (var item in result) { CRoomStyleViewModel roomstyle_VM = new CRoomStyleViewModel() { entity_roomstyle = item.rms }; roomstyle_VM_lt.Add(roomstyle_VM); CBuildCaseViewModel buildcase_VM = new CBuildCaseViewModel() { entity_buildcase = item.b }; buildcase_VM_lt.Add(buildcase_VM); CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_VM_lt.Add(room_VM); } abtRoom_VM.buildcaseViewModels = buildcase_VM_lt; abtRoom_VM.roomStyleViewModels = roomstyle_VM_lt; abtRoom_VM.roomViewModels = room_VM_lt; ViewData.Model = abtRoom_VM; return(PartialView("_PartialSearchResult")); }
public ActionResult MyRoom() { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var user = Session[CDictionary.welcome] as CMember; if (user == null) { return(RedirectToAction("Login", "Member")); } CMember member = Session[CDictionary.welcome] as CMember; int memberID = member.fMemberId; var result = from L in dbSA.Lease join R in dbSA.Room on L.RoomID equals R.ID where L.MemberID == memberID select new { L, R }; List <CRoomViewModel> List_Room = new List <CRoomViewModel>(); List <CLeaseViewModel> List_Lease = new List <CLeaseViewModel>(); var test = result.ToList(); foreach (var item in result) { CRoomViewModel ViewM_Room = new CRoomViewModel() { entity_room = item.R }; List_Room.Add(ViewM_Room); CLeaseViewModel ViewM_Lease = new CLeaseViewModel() { entity_lease = item.L }; List_Lease.Add(ViewM_Lease); } abtRoom_VM.roomViewModels = List_Room; abtRoom_VM.leaseViewModels = List_Lease; ViewData.Model = abtRoom_VM; return(View(abtRoom_VM)); }
public ActionResult ListAllRooms( string buildcaseID, string roomname, string roomstyleID, string area) { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var result = from b in dbSA.BuildCase join r in dbSA.Room on b.ID equals r.BuildCaseID join rms in dbSA.RoomStyle on r.RoomStyleID equals rms.ID where b.ID == buildcaseID && rms.ID.ToString() == roomstyleID select new { b = b, r = r, rms = rms }; List <CBuildCaseViewModel> buildcase_VM_lt = new List <CBuildCaseViewModel>(); List <CRoomViewModel> rooom_VM_lt = new List <CRoomViewModel>(); List <CRoomStyleViewModel> roomstyle_VM_lt = new List <CRoomStyleViewModel>(); var test = result.ToList(); foreach (var item in result) { CBuildCaseViewModel buildcase_VM = new CBuildCaseViewModel() { entity_buildcase = item.b }; buildcase_VM_lt.Add(buildcase_VM); CRoomStyleViewModel roomstyle_VM = new CRoomStyleViewModel() { entity_roomstyle = item.rms }; roomstyle_VM_lt.Add(roomstyle_VM); CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; rooom_VM_lt.Add(room_VM); } abtRoom_VM.buildcaseViewModels = buildcase_VM_lt; abtRoom_VM.roomStyleViewModels = roomstyle_VM_lt; abtRoom_VM.roomViewModels = rooom_VM_lt; ViewData.Model = abtRoom_VM; return(View(abtRoom_VM)); }
//GET public ActionResult ListRoomDetail(int id) { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var result = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID join rf in dbSA.RoomFacilities on rs.ID equals rf.RoomStyleID join f in dbSA.Facility on rf.FacilityID equals f.ID where r.ID == id select new { r = r, b = b, rs = rs, rf = rf, f = f }; List <CBuildCaseViewModel> buildcase_VM_lt = new List <CBuildCaseViewModel>(); List <CRoomViewModel> rooom_VM_lt = new List <CRoomViewModel>(); List <CRoomStyleViewModel> roomstyle_VM_lt = new List <CRoomStyleViewModel>(); List <CRoomFacilityViewModel> roomfacility_VM_lt = new List <CRoomFacilityViewModel>(); List <CFacilityViewModel> facility_VM_lt = new List <CFacilityViewModel>(); var test = result.ToList(); //有4個 foreach (var item in result) { CBuildCaseViewModel buildcase_VM = new CBuildCaseViewModel() { entity_buildcase = item.b }; buildcase_VM_lt.Add(buildcase_VM); CRoomStyleViewModel roomstyle_VM = new CRoomStyleViewModel() { entity_roomstyle = item.rs }; roomstyle_VM_lt.Add(roomstyle_VM); CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; rooom_VM_lt.Add(room_VM); CRoomFacilityViewModel roomfacility_VM = new CRoomFacilityViewModel() { entity_roomfacilities = item.rf }; roomfacility_VM_lt.Add(roomfacility_VM); CFacilityViewModel facility_VM = new CFacilityViewModel() { entity_Facility = item.f }; facility_VM_lt.Add(facility_VM); } abtRoom_VM.buildcaseViewModels = buildcase_VM_lt; abtRoom_VM.roomfacilityViewModel = roomfacility_VM_lt; abtRoom_VM.roomStyleViewModels = roomstyle_VM_lt; abtRoom_VM.roomViewModels = rooom_VM_lt; abtRoom_VM.facilityViewModels = facility_VM_lt; ViewData.Model = abtRoom_VM; return(View(abtRoom_VM)); }
public ActionResult GetSearchData(string case1, string case2, int case3, int case4) { List <CRoomViewModel> room_list = new List <CRoomViewModel>(); if (case3 == 1) { var query = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID where r.BuildCaseID == case1 && r.RoomType == case2 && r.RoomStyleID == case4 && r.Rent <= 10000 select new { r }; foreach (var item in query) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_list.Add(room_VM); } } if (case3 == 2) { var query = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID where r.BuildCaseID == case1 && r.RoomType == case2 && r.RoomStyleID == case4 && r.Rent > 10000 && r.Rent <= 20000 select new { r }; foreach (var item in query) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_list.Add(room_VM); } } if (case3 == 3) { var query = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID where r.BuildCaseID == case1 && r.RoomType == case2 && r.RoomStyleID == case4 && r.Rent > 20000 && r.Rent <= 30000 select new { r }; foreach (var item in query) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_list.Add(room_VM); } } if (case3 == 4) { var query = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID where r.BuildCaseID == case1 && r.RoomType == case2 && r.RoomStyleID == case4 && r.Rent > 30000 && r.Rent <= 40000 select new { r }; foreach (var item in query) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_list.Add(room_VM); } } if (case3 == 5) { var query = from r in dbSA.Room join b in dbSA.BuildCase on r.BuildCaseID equals b.ID join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID where r.BuildCaseID == case1 && r.RoomType == case2 && r.RoomStyleID == case4 && r.Rent > 40000 select new { r }; foreach (var item in query) { CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; room_list.Add(room_VM); } } var html = RenderPartialToString("_box", room_list, ControllerContext); return(Json(new { html = html }));; }
//PartialRoomFavorite //public ActionResult PartialRoomFavorite(string MemberID, int page = 1, int pageSize = 6) //{ // SingleApartmentEntities db = new SingleApartmentEntities(); // var list = db.RoomFavorite.Where(r => r.MemberID.ToString() == MemberID); // int currentPage = page < 1 ? 1 : page; // List<CRoomFavorite> lt = new List<CRoomFavorite>(); // foreach (var item in list) // { // lt.Add(new CRoomFavorite { entity_RoomFavorite = item }); // } // var result = lt.ToPagedList(currentPage, pageSize); // ViewData.Model = result; // ViewBag.MemberID = MemberID; // return PartialView("_PartialRoomFavorite"); //} //GET public ActionResult ListRoomDetail(int id) { CAboutRoomViewModel abtRoom_VM = new CAboutRoomViewModel(); var result = from r in dbSA.Room join rs in dbSA.RoomStyle on r.RoomStyleID equals rs.ID join b in dbSA.BuildCase on r.BuildCaseID equals b.ID where r.ID == id select new { r = r, b = b, rs = rs, }; List <CBuildCaseViewModel> buildcase_VM_lt = new List <CBuildCaseViewModel>(); List <CRoomViewModel> rooom_VM_lt = new List <CRoomViewModel>(); List <CRoomStyleViewModel> roomstyle_VM_lt = new List <CRoomStyleViewModel>(); List <CRoomFacilityViewModel> roomfacility_VM_lt = new List <CRoomFacilityViewModel>(); List <CFacilityViewModel> facility_VM_lt = new List <CFacilityViewModel>(); var test = result.ToList(); //有4個 foreach (var item in result) { CBuildCaseViewModel buildcase_VM = new CBuildCaseViewModel() { entity_buildcase = item.b }; buildcase_VM_lt.Add(buildcase_VM); CRoomStyleViewModel roomstyle_VM = new CRoomStyleViewModel() { entity_roomstyle = item.rs }; roomstyle_VM_lt.Add(roomstyle_VM); CRoomViewModel room_VM = new CRoomViewModel() { entity_room = item.r }; rooom_VM_lt.Add(room_VM); } List <CLeaseViewModel> lease_VM_lt = new List <CLeaseViewModel>(); var l_result = from l in dbSA.Lease select l; foreach (var litem in l_result) { CLeaseViewModel lease_VM = new CLeaseViewModel() { entity_lease = litem }; lease_VM_lt.Add(lease_VM); } CMember member = Session[CDictionary.welcome] as CMember; abtRoom_VM.buildcaseViewModels = buildcase_VM_lt; abtRoom_VM.roomfacilityViewModel = roomfacility_VM_lt; abtRoom_VM.roomStyleViewModels = roomstyle_VM_lt; abtRoom_VM.roomViewModels = rooom_VM_lt; abtRoom_VM.facilityViewModels = facility_VM_lt; abtRoom_VM.leaseViewModels = lease_VM_lt; ViewData.Model = abtRoom_VM; return(View(abtRoom_VM)); }