public FormCattery(string title, FormMain.FormCatInfoModes mode, Cattery cattery) { InitializeComponent(); this.mode = mode; this.Text = title; this.cattery = cattery; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Adress,CityId,Capacity")] Cattery cattery) { if (id != cattery.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cattery); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatteryExists(cattery.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.City, "Id", "Name", cattery.CityId); return(View(cattery)); }
public async Task <IActionResult> Create([Bind("Id,Name,Adress,CityId,Capacity")] Cattery cattery) { if (ModelState.IsValid) { _context.Add(cattery); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.City, "Id", "Name", cattery.CityId); return(View(cattery)); }