public async Task <IActionResult> Edit(int id, [Bind("Id,IdField")] EntranceFormFields entranceFormFields) { if (id != entranceFormFields.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(entranceFormFields); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EntranceFormFieldsExists(entranceFormFields.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(entranceFormFields)); }
public async Task <IActionResult> Create([Bind("Id,Name,Type")] Field @field) { if (ModelState.IsValid) { _context.Add(@field); await _context.SaveChangesAsync(); Field current = _context.Field.Where(t => t == (@field)).ToList()[0]; var entrance_field = new EntranceFormFields(); entrance_field.IdField = current.Id; _context.Add(entrance_field); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(@field)); }