public IActionResult DeleteHouse(int houseId) { //Delete house from database List <House> Properties; using (IPropertyRepository propRep = new PropertyRepository()) { propRep.DeleteHouse(houseId); Properties = propRep.PopulateHouses(); } return(View("~/Views/Property/Houses.cshtml", Properties)); }
public IActionResult EditProperty(House house, IFormFile fileSelect) { //Edit house in database using (var target = new MemoryStream()) { fileSelect.CopyTo(target); house.PhotoData = target.ToArray(); } List <House> Properties; using (IPropertyRepository propRep = new PropertyRepository()) { propRep.EditHouse(house); Properties = propRep.PopulateHouses(); } return(View("~/Views/Property/Houses.cshtml", Properties)); }
public IActionResult SearchHouses(string searchTerm) { //Search house functionality, onkeyup of search box List <House> Properties; using (IPropertyRepository propRep = new PropertyRepository()) { Properties = propRep.PopulateHouses(); } if (searchTerm != "" && searchTerm != null) { //Select all houses where the search term exists in the correct fields Properties = Properties.Where(p => p.MLSNum.ToString().Contains(searchTerm) || p.City.Contains(searchTerm) || p.State.Contains(searchTerm) || p.ZipCode.ToString().Contains(searchTerm) || p.Bedrooms.ToString().Contains(searchTerm) || p.Bathrooms.ToString().Contains(searchTerm) || p.SquareFeet.ToString().Contains(searchTerm)).ToList(); } return(PartialView("_HousesList", Properties)); }
public IActionResult Home(Realtor realtor) { //TODO: Prevent user access into system without authentication //Authenticate User bool authed = false; using (IUserRepository userRep = new UserRepository()) { //If email is null, then user is an existing user if (realtor.email == null) { //Auth existing user authed = userRep.AuthenticateUser(realtor); } else { //Create new user userRep.CreateUser(realtor); authed = true; } } List <House> Properties; //Retrieve all properties using (IPropertyRepository propRep = new PropertyRepository()) { Properties = propRep.PopulateHouses(); } //Display houses if authenticated if (authed == true) { return(View("~/Views/Property/Houses.cshtml", Properties)); } else { return(View("~/Views/Home/Login.cshtml")); } }