public async Task <IActionResult> Create([Bind("Id,County,Price,Bed,Bath,SquareFeet,Address,City,State,Zip")] House house, string date, string time) { if (ModelState.IsValid && USStreetSingleAddress.ValidateAddress(house.Address, house.City, house.State, house.Zip) == true) { //capitalize first letter of county string firstLetter = house.County.Substring(0, 1).ToUpper(); house.County = firstLetter + house.County.Substring(1); DateTime openHouseDate = Convert.ToDateTime(date + " " + time); house.NextOpenHouse = openHouseDate; //add house _context.Add(house); await _context.SaveChangesAsync(); //add images InsertImages(house); } else { TempData["ErrorMessage"] = "The property that you entered does not exist.\n" + "Please ensure that the street address, city, state, and zip code you enter are valid."; return(View(house)); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("Id,County,Price,Bed,Bath,SquareFeet,Address,City,State,Zip")] House house, string date, string time) { if (id != house.Id) { return(NotFound()); } if (ModelState.IsValid && USStreetSingleAddress.ValidateAddress(house.Address, house.City, house.State, house.Zip) == true) { try { //capitalize first letter of county string firstLetter = house.County.Substring(0, 1).ToUpper(); house.County = firstLetter + house.County.Substring(1); DateTime openHouseDate = Convert.ToDateTime(date + " " + time); house.NextOpenHouse = openHouseDate; //update house _context.Update(house); await _context.SaveChangesAsync(); //add images InsertImages(house); } catch (DbUpdateConcurrencyException) { if (!HouseExists(house.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } else { TempData["ErrorMessage"] = "The property that you entered does not exist.\n" + "Please ensure that the street address, city, state, and zip code you enter are valid."; return(View(await House.getHouse(_context, (int)id))); } }