public async Task <IActionResult> Edit(int id, [Bind("Id,NameKyrg,NameRus,CreateDate,DictStatusId,DeactiveDate")] DictLegalForm dictLegalForm) { if (id != dictLegalForm.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dictLegalForm); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DictLegalFormExists(dictLegalForm.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DictStatusId"] = new SelectList(_context.Set <DictStatus>(), "Id", "Name", dictLegalForm.DictStatusId); return(View(dictLegalForm)); }
// GET: GlobalDicts/DictLegalForms/Create public IActionResult Create() { ViewData["DictStatusId"] = new SelectList(_context.Set <DictStatus>(), "Id", "Name"); DictLegalForm model = new DictLegalForm(); model.CreateDate = DateTime.Now; model.DeactiveDate = null; return(View(model)); }
public async Task <IActionResult> Create([Bind("Id,NameKyrg,NameRus,CreateDate,DictStatusId,DeactiveDate")] DictLegalForm dictLegalForm) { if (ModelState.IsValid) { _context.Add(dictLegalForm); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DictStatusId"] = new SelectList(_context.Set <DictStatus>(), "Id", "Name", dictLegalForm.DictStatusId); return(View(dictLegalForm)); }