示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CLienteId,LibroId")] ClienteLibro clienteLibro)
        {
            if (id != clienteLibro.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clienteLibro);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteLibroExists(clienteLibro.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LibroId"] = new SelectList(_context.Libro, "Id", "Id", clienteLibro.LibroId);
            return(View(clienteLibro));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,CLienteId,LibroId")] ClienteLibro clienteLibro)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clienteLibro);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LibroId"] = new SelectList(_context.Libro, "Id", "Id", clienteLibro.LibroId);
            return(View(clienteLibro));
        }
示例#3
0
        //RegresarLibro
        public IActionResult RegresarLibro(int Id)
        {
            HttpClient   client = _apiC.Initial();
            ClienteLibro cl     = new ClienteLibro();

            cl.Id = Id;
            //HTTP PUT
            //var postask = client.PostAsJsonAsync<Clientes>("api/clientes", clientes);
            var postask = client.PutAsJsonAsync <ClienteLibro>("api/clienteLibros", cl);

            postask.Wait();

            var result = postask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index", "Home"));
            }
            //ModelState.AddModelError("Id", "Llene todo los datos obligatorios");
            return(View());
        }
示例#4
0
        public IActionResult Prestar(int Cliente, int IdLibro)
        {
            HttpClient   client = _apiC.Initial();
            ClienteLibro cl     = new ClienteLibro();

            cl.IdLibro   = IdLibro;
            cl.IdCliente = Cliente;
            //HTTP POST
            var postask = client.PostAsJsonAsync <ClienteLibro>("api/clienteLibros", cl);

            postask.Wait();

            var result = postask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details"));
            }
            ModelState.AddModelError("Id", "Error");
            return(View());
        }