public ActionResult Index() { IEnumerable <newPropModal> Prop; List <newPropModal> Prop1 = new List <newPropModal>(); Prop = (from rent in db.properties where rent.pActivationAdmin == true && rent.pActivationStatus == true orderby(rent.PropID) descending select new newPropModal { ProID = rent.PropID, propName = rent.pName, Price = rent.pPrice, PropCity = rent.city.cityName, Address = rent.pAddress, Status = rent.pActivationStatus, PropFor = rent.propFor }).Take(6); foreach (newPropModal data in Prop) { int bid = data.ProID; propImage image = db.propImages.FirstOrDefault(u => u.propID_FK == bid); data.imageProper = image.propImage1; Prop1.Add(data); } ViewBag.Data = Prop1; return(View()); }
public ActionResult Villa(int page = 1, int id = 0) { string reqType = ""; if (id == 1) { reqType = "Rent"; } else { reqType = "Sale"; } IEnumerable <viewModel> Prop; List <viewModel> Prop1 = new List <viewModel>(); Prop = (from rent in db.properties orderby rent.PropID descending join im in db.propImages on rent.PropID equals im.propID_FK into g where rent.propFor == reqType && rent.pType == 1 && rent.pActivationAdmin == true && rent.pActivationStatus == true select new viewModel { ProID = rent.PropID, propName = rent.pName, noofBed = rent.pNoofBeds, ProType = rent.pType, PropFor = rent.propFor, nooffloor = rent.pFloors, sizeSquare = rent.pSizeSquare, Price = rent.pPrice, totalImages = g.Count() }).Skip(0); foreach (viewModel data in Prop) { int bid = data.ProID; propImage image = db.propImages.FirstOrDefault(u => u.propID_FK == bid); data.imageProper = image.propImage1; Prop1.Add(data); } int pageSize = 10; return(View(Prop1.ToPagedList <viewModel>(page, pageSize))); }
public ActionResult New(FormCollection form, HttpPostedFileBase[] imagesProp, newPropModal modal) { if (ModelState.IsValid) { if (HttpContext.Session["UserID"] == "" || HttpContext.Session["UserID"] == null) { return(RedirectToAction("login")); } property rent = db.properties.Create(); rent.pName = modal.propName; rent.pPrice = modal.Price; rent.pType = Convert.ToInt16(form["propType"]); rent.propFor = Convert.ToString(form["propFor"]); rent.pFloors = Convert.ToInt16(form["noofFloors"]); rent.pNoofRooms = Convert.ToInt16(form["noofRooms"]); rent.pNoofBeds = Convert.ToInt32(form["noofBeds"]); rent.pSizeSquare = modal.SizeSquare; rent.pCityID_FK = modal.cities.cityID; rent.pAddress = modal.Address; rent.pPostCode = Convert.ToString(modal.Postcode); rent.pAvailableFrom = Convert.ToDateTime(modal.availablefrom); rent.pDescription = modal.description; rent.pAgentID_FK = Convert.ToInt32(HttpContext.Session["UserID"]); rent.pPublicationDate = DateTime.Now; rent.pActivationStatus = true; rent.pActivationAdmin = true; //var coverlet = "A"; db.properties.Add(rent); db.SaveChanges(); Int32 PropertyID = rent.PropID; propImage image = db.propImages.Create(); foreach (HttpPostedFileBase file in imagesProp) { if (file != null) { if (imagesProp.Count() >= 1) { System.IO.Stream fullstream; fullstream = file.InputStream; byte[] fullimage = dal.ResizeUplImage(fullstream); System.IO.Stream MyStream; MyStream = file.InputStream; byte[] newimage = dal.ResizeUploadedImage(MyStream); image.propImageThumb = newimage; image.propID_FK = PropertyID; image.propImage1 = fullimage; image.propAgentID_FK = Convert.ToInt32(HttpContext.Session["UserID"]); db.propImages.Add(image); db.SaveChanges(); } } } ViewBag.Message = "Property Added successfully"; ModelState.Clear(); } var citiesb = db.cities; ViewBag.Cities = new SelectList(citiesb, "cityID", "cityName"); return(View()); }
public ActionResult Results(int page = 1) { string type = Request.Form["sType"]; Int32 propTypee = Convert.ToInt32(Request.Form["propType"]); int MinPrice = Convert.ToInt16(Request.Form["minPrice"]); int MaxPrice = Convert.ToInt16(Request.Form["maxPrice"]); int citi = Convert.ToInt16(Request.Form["city"]); if (MinPrice == 0 && MaxPrice == 0) { MinPrice = 1000; MaxPrice = 10000; } else if (MinPrice == 0 && MaxPrice > 0) { MinPrice = 1000; } else if (MaxPrice == 0 && MinPrice > 0) { MaxPrice = 10000; } //IEnumerable<newPropModal> cand; //if (MinPrice =="0" || MaxPrice == "0") //{ //} //else //{ // cand = (from r in db.properties // orderby r.PropID descending // where r.propFor == type && r.pType == propTypee // select new newPropModal // { // ProID = r.PropID, // propName = r.pName, // Price = r.pPrice, // PropCity = r.city.cityName, // Address = r.pAddress, // Status = r.pActivationStatus, // PropFor = r.propFor, // CreatedDate = r.pPublicationDate, // }).Skip(0); //} IEnumerable <viewModel> Prop; List <viewModel> Prop1 = new List <viewModel>(); Prop = (from rent in db.properties orderby rent.PropID descending where rent.propFor == type && rent.pType == propTypee && rent.pCityID_FK == citi && (rent.pPrice >= MinPrice && rent.pPrice <= MaxPrice) && rent.pActivationAdmin == true && rent.pActivationStatus == true select new viewModel { ProID = rent.PropID, propName = rent.pName, noofBed = rent.pNoofBeds, ProType = rent.pType, PropFor = rent.propFor, nooffloor = rent.pFloors, sizeSquare = rent.pSizeSquare, //Address = rent.pAddress, //Postcode = rent.pPostCode, //PropCity = rent.city.cityName, //description = rent.pDescription, //agentPhone = t.user.uPhone, //availablefrom = rent.pAvailableFrom, //CreatedDate = rent.pPublicationDate, Price = rent.pPrice, }).Skip(0); foreach (viewModel data in Prop) { int bid = data.ProID; propImage image = db.propImages.FirstOrDefault(u => u.propID_FK == bid); data.imageProper = image.propImage1; Prop1.Add(data); } int pageSize = 10; return(View(Prop1.ToPagedList <viewModel>(page, pageSize))); //return View(); }
public ActionResult Edit(FormCollection form, HttpPostedFileBase[] imagProp, editModel modal) { int id = Convert.ToInt16(form["propid"]); //int id = modal.ProID; if (ModelState.IsValid) { if (HttpContext.Session["UserID"] == "" || HttpContext.Session["UserID"] == null) { return(RedirectToAction("login")); } property result = (from p in db.properties where p.PropID == id select p).SingleOrDefault(); result.pName = modal.propName; result.pPrice = modal.Price; result.pType = modal.ProType; result.propFor = modal.PropFor; result.pFloors = modal.nooffloor; result.pNoofRooms = modal.noofrooms; result.pNoofBeds = modal.noofBed; result.pSizeSquare = modal.SizeSquare; result.pCityID_FK = modal.CityID; result.pAddress = modal.Address; result.pPostCode = Convert.ToString(modal.Postcode); result.pAvailableFrom = Convert.ToDateTime(modal.availablefrom); result.pDescription = modal.description; //db.Entry(result).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); propImage image = db.propImages.Create(); foreach (HttpPostedFileBase file in imagProp) { if (file != null) { if (imagProp.Count() >= 1) { System.IO.Stream fullstream; fullstream = file.InputStream; byte[] fullimage = dal.ResizeUplImage(fullstream); System.IO.Stream MyStream; MyStream = file.InputStream; byte[] newimage = dal.ResizeUploadedImage(MyStream); image.propImageThumb = newimage; image.propID_FK = id; image.propImage1 = fullimage; image.propAgentID_FK = Convert.ToInt32(HttpContext.Session["UserID"]); db.propImages.Add(image); db.SaveChanges(); } } } ViewBag.Message = "Property Updated successfully"; ModelState.Clear(); } var resl = from empl in db.properties.AsEnumerable() where empl.PropID == id select empl; ViewBag.Proper = resl; Int32? cityid = 1; Int32? floor = 1; Int32? beds = 1; Int32? roomm = 1; Int32? ptype = 1; string pfor = ""; foreach (var t in resl) { cityid = t.pCityID_FK; floor = t.pFloors; beds = t.pNoofBeds; ptype = t.pType; pfor = t.propFor; } List <SelectListItem> pType = new List <SelectListItem>(); pType.Add(new SelectListItem() { Text = "Villa", Value = "1" }); pType.Add(new SelectListItem() { Text = "Student Apartment", Value = "2" }); pType.Add(new SelectListItem() { Text = "Family Apartment", Value = "3" }); this.ViewBag.pType = new SelectList(pType, "Value", "Text", ptype); List <SelectListItem> pFor = new List <SelectListItem>(); pFor.Add(new SelectListItem() { Text = "Rent", Value = "Rent" }); pFor.Add(new SelectListItem() { Text = "Sale", Value = "Sale" }); this.ViewBag.pFor = new SelectList(pFor, "Value", "Text", pfor); List <SelectListItem> bedd = new List <SelectListItem>(); bedd.Add(new SelectListItem() { Text = "1", Value = "1" }); bedd.Add(new SelectListItem() { Text = "2", Value = "2" }); bedd.Add(new SelectListItem() { Text = "3", Value = "3" }); bedd.Add(new SelectListItem() { Text = "4", Value = "4" }); bedd.Add(new SelectListItem() { Text = "5", Value = "5" }); bedd.Add(new SelectListItem() { Text = "6", Value = "6" }); bedd.Add(new SelectListItem() { Text = "7+", Value = "7" }); this.ViewBag.beds = new SelectList(bedd, "Value", "Text", beds); List <SelectListItem> rooms = new List <SelectListItem>(); rooms.Add(new SelectListItem() { Text = "1", Value = "1" }); rooms.Add(new SelectListItem() { Text = "2", Value = "2" }); rooms.Add(new SelectListItem() { Text = "3", Value = "3" }); rooms.Add(new SelectListItem() { Text = "4", Value = "4" }); rooms.Add(new SelectListItem() { Text = "5", Value = "5" }); rooms.Add(new SelectListItem() { Text = "6", Value = "6" }); rooms.Add(new SelectListItem() { Text = "7+", Value = "7" }); this.ViewBag.rooms = new SelectList(rooms, "Value", "Text", roomm); List <SelectListItem> floors = new List <SelectListItem>(); floors.Add(new SelectListItem() { Text = "1", Value = "1" }); floors.Add(new SelectListItem() { Text = "2", Value = "2" }); floors.Add(new SelectListItem() { Text = "3", Value = "3" }); floors.Add(new SelectListItem() { Text = "4", Value = "4" }); floors.Add(new SelectListItem() { Text = "5", Value = "5" }); floors.Add(new SelectListItem() { Text = "6", Value = "6" }); floors.Add(new SelectListItem() { Text = "7+", Value = "7" }); this.ViewBag.floors = new SelectList(floors, "Value", "Text", floor); var citiesb = db.cities; ViewBag.Cities = new SelectList(citiesb, "cityID", "cityName"); return(View(modal)); }