public async Task <ActionResult <Book> > CreateBook(Book book) { try { Libro libro = new Libro { id_libro = book.id_libro, titulo = book.titulo, autor = book.autor, anio = book.anio, multapordia = book.multapordia }; db.Libros.Add(libro); int filas = await db.SaveChangesAsync(); if (filas > 0) { return(CreatedAtAction("CreateBook", new { status = "Agregado exitosamente" })); } else { return(StatusCode(500)); } } catch (Exception ex) { return(Conflict()); } }
public async Task <IActionResult> Create([Bind("IdClient,Nume,Adresa,Contact")] Clienti clienti) { if (ModelState.IsValid) { _context.Add(clienti); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clienti)); }
public async Task <IActionResult> Create([Bind("IdCarte,Titlu,Cod,Autor,Editura")] Carti carti) { if (ModelState.IsValid) { _context.Add(carti); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(carti)); }
public async Task <IActionResult> Create([Bind("nombre,disponible,cate")] Libro libro) { if (ModelState.IsValid) { _context.Add(libro); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["cate"] = new SelectList(_context.categorias, "cate", "cate", libro.cate); return(View(libro)); }
public async Task <IActionResult> Create([Bind("IdAlquiler,Inicio,Fin,nombre,idUser")] Alquiler alquiler) { if (ModelState.IsValid) { _context.Add(alquiler); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["nombre"] = new SelectList(_context.libros, "nombre", "nombre", alquiler.nombre); ViewData["idUser"] = new SelectList(_context.usuarios, "IdUser", "IdUser", alquiler.idUser); return(View(alquiler)); }
public async Task <IActionResult> Create([Bind("IdImprumut,IdCarte,IdClient,DataImprumut,DataReturnare")] ImprumuturiCarti imprumuturiCarti) { if (ModelState.IsValid) { _context.Add(imprumuturiCarti); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.IdClient = new SelectList(_context.Clienti, "IdClient", "Nume", imprumuturiCarti.IdClient); imprumuturiCarti.Carti = _context.Carti.Find(imprumuturiCarti.IdCarte); return(View(imprumuturiCarti)); }
private void BtnSalvar_Click(object sender, RoutedEventArgs e) { context.SaveChangesAsync(); MessageBox.Show("Itens salvos com sucesso"); }