示例#1
0
        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());
            }
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#7
0
        private void BtnSalvar_Click(object sender, RoutedEventArgs e)
        {
            context.SaveChangesAsync();

            MessageBox.Show("Itens salvos com sucesso");
        }