示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("National_id,Full_names,Phone_number,Location")] Rental_Owners rental_Owners)
        {
            if (id != rental_Owners.National_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rental_Owners);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Rental_OwnersExists(rental_Owners.National_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rental_Owners));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("National_id,Full_names,Phone_number,Location")] Rental_Owners rental_Owners)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rental_Owners);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rental_Owners));
        }
示例#3
0
        // GET: Rentals_reg/Create
        public IActionResult Create(Rental_Owners rental_Owners)
        {
            int selectedValue           = rental_Owners.National_id;
            List <Rental_Owners> idList = new List <Models.Rental_Owners>();

            idList = (from product in _context.Rental_owners select product).ToList();
            //idList.Insert(0, new Rental_Owners { National_id=0,Full_names})

            idList.Insert(0, new Rental_Owners {
                National_id = 0, Full_names = "--Select National ID--"
            });
            ViewBag.IDlist = idList;
            return(View());
        }