public async Task <IActionResult> Edit(int id, [Bind("BuildingId,Title,City,ZipCode,BedCount,Condition,PricePerDay,HasWlan,WlanPrice,HasParking,ParkingPrice,Space,HasBalkony,IsActive,BuildingTypeId,UserId")] Building building) { if (id != building.BuildingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(building); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildingExists(building.BuildingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BuildingTypeId"] = new SelectList(_context.Set <BuildingType>(), "BuildingTypeId", "BuildingTypeId", building.BuildingTypeId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "UserId", building.UserId); return(View(building)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,Email,Firstname,Lastname,Password, UserTypeId")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserTypeId"] = new SelectList(_context.Set <UserType>(), "UserTypeId", "UserTypeId", user.UserTypeId); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("RentId,BuildingId,UserId,From,To,PricePerDays,GuestWasHere")] Rent rent) { rent.GuestWasHere = true; if (rent.From > rent.To) { DateTime temp = rent.From; rent.From = rent.To; rent.To = temp; } rent.BuildingId = id; if (ModelState.IsValid) { try { _context.Update(rent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentExists(rent.RentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BuildingId"] = new SelectList(_context.Building, "BuildingId", "BuildingId", rent.BuildingId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "UserId", rent.UserId); return(View("Views/Buildings/Index.cshtml")); }