public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CountryId,ContartPerson,Phone")] Landlords landlords)
        {
            if (id != landlords.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(landlords);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LandlordsExists(landlords.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "Country", landlords.CountryId);
            return(View(landlords));
        }
Ejemplo n.º 2
0
        private void UpdateWordDock(House home)
        {
            var landlord        = Landlords.SingleOrDefault(l => l.Id == home.LandlordId);
            var displayContract = CopyHomeAndLandlord(home, landlord);

            Globals.ThisDocument.displayContractBindingSource.DataSource = displayContract;
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            DataService = dataService;

            var landLoards = dataService.GetAllLandlords();

            foreach (var landlord in landLoards)
            {
                Landlords.Add(landlord);
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Name,CountryId,ContartPerson,Phone")] Landlords landlords)
        {
            if (ModelState.IsValid)
            {
                _context.Add(landlords);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "Country", landlords.CountryId);
            return(View(landlords));
        }