Ejemplo n.º 1
0
 public IActionResult Create([Bind("Id,Name,Address,PhoneNumber,OwnerFirstName,OwnerLastName,Description,Published")] Building building)
 {
     if (ModelState.IsValid)
     {
         try{
             _repo.Add(building);
             return(RedirectToAction(nameof(Index)));
         }catch (BuildingRepoException e) {
             this.ModelState.AddModelError(e.Property, e.Message);
         }
     }
     return(View(building));
 }
 public IActionResult Create([Bind("Id,LotNumber,Price,Terms,LeaseLength,NumberOfRooms,RentingLotType,BuildingId")] RentingLot rentingLot)
 {
     if (ModelState.IsValid)
     {
         try{
             var r = _repo.Add(rentingLot);
             return(RedirectToAction(nameof(Details), new { Id = r.Id }));
         }catch (BuildingRepoException e) {
             this.ModelState.AddModelError(e.Property, e.Message);
         }
     }
     ViewData["BuildingId"] = new SelectList(_repo.GetAllBuildings(), "Id", "Name", rentingLot.BuildingId);
     return(View(rentingLot));
 }