public async Task <IActionResult> PutNonResidentialPremise(int id, NonResidentialPremiseRequest nonResidentialPremiseRequest) { NonResidentialPremise nonResidentialPremise = nonResidentialPremiseRequest.NonResidentialPremise; string token = nonResidentialPremiseRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } if (id != nonResidentialPremise.Id) { return(BadRequest()); } _context.Entry(nonResidentialPremise).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NonResidentialPremiseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutApartment(int id, ApartmentRequest apartmentRequest) { Apartment apartment = apartmentRequest.Apartment; string token = apartmentRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } if (id != apartment.Id) { return(BadRequest()); } _context.Entry(apartment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ApartmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("ID,ImageData, PropertyId")] Photo photo) { if (ModelState.IsValid) { _context.Add(photo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(photo)); }
public async Task <IActionResult> Create([Bind("ID,Street1,Street2,City,State,ZipCode,Neighborhood,SalesPrice,DateListed,Bedrooms,Bathrooms,GarageSize,SquareFeet,LotSize,Description")] Property @property) { if (ModelState.IsValid) { property.OwnerId = _userManager.GetUserId(User); _context.Add(@property); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(@property)); }