public async Task <IActionResult> CreateArea([Bind("Id,Codice")] Area area) { if (ModelState.IsValid) { _context.Add(area); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> AddOrEdit(int id, [Bind("Id,Codice,Descrizione,Note")] Componente componente) { if (ModelState.IsValid) { if (id == 0) { _context.Add(componente); await _context.SaveChangesAsync(); } else { try { _context.Update(componente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComponenteExists(componente.Id)) { return(NotFound()); } else { throw; } } } return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Componente.ToList()) })); } return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", componente) })); }
public async Task <IActionResult> Create([Bind("Id,Matricola")] Carello carello) { if (ModelState.IsValid) { _context.Add(carello); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(carello)); }
public async Task<IActionResult> Create([Bind("Qty,CarelloId,ComponenteId")] ComponenteDelCarello componenteDelCarello) { if (ModelState.IsValid) { _context.Add(componenteDelCarello); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } ViewData["CarelloId"] = new SelectList(_context.Carelli, "Id", "Matricola", componenteDelCarello.CarelloId); ViewData["ComponenteId"] = new SelectList(_context.Componente, "Id", "Codice", componenteDelCarello.ComponenteId); return View(componenteDelCarello); }