public IActionResult Edit(int id, [Bind("Id,Name,ContactNumber")] Tenant tenant)
        {
            if (id != tenant.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tenant);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TenantExists(tenant.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tenant));
        }
Esempio n. 2
0
        public IActionResult Edit(int id, [Bind("Id,HouseOwnerId,HouseAddress")] House house)
        {
            if (id != house.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(house);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HouseExists(house.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HouseOwnerId"] = new SelectList(_context.Set <HouseOwner>(), "Id", "Id", house.HouseOwnerId);
            return(View(house));
        }
        public IActionResult Edit(int id, [Bind("Id,HouseId,TenantId,RentPerWeek")] Contract contract)
        {
            if (id != contract.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contract);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContractExists(contract.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HouseId"]  = new SelectList(_context.Set <House>(), "Id", "Id", contract.HouseId);
            ViewData["TenantId"] = new SelectList(_context.Set <Tenant>(), "Id", "Id", contract.TenantId);
            return(View(contract));
        }