Exemplo n.º 1
0
        public void Prestar(string isbn, string nombreUsuario)
        {
            DateTime?fechaEntrega;
            var      prestado = prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn);

            if (prestado == null)
            {
                bool esPalindroma = Palindroma(isbn);
                if (esPalindroma)
                {
                    // devolver que no se puede prestar el libro
                }

                var libro = libroRepositorio.ObtenerPorIsbn(isbn);

                //calcular fecha de entrega
                int numeroISBN = CalcularNumeroISBN(isbn);
                if (numeroISBN < 30)
                {
                    fechaEntrega = null;
                }
                else
                {
                    fechaEntrega = CalcularFechaEntrega();
                }

                //Creo el objeto para prestar el libro
                Prestamo prestarLibro = new Prestamo(DateTime.Now, libro, fechaEntrega, nombreUsuario);
                prestamoRepositorio.Agregar(prestarLibro);
            }
        }
        public void Prestar(string isbn, string nombreUsuario)
        {
            Libro libroPrestado = prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn);

            if (libroPrestado != null)
            {
                throw new Exception(EL_LIBRO_NO_SE_ENCUENTRA_DISPONIBLE);
            }

            Libro libroEncontrado = libroRepositorio.ObtenerPorIsbn(isbn);

            if (libroEncontrado == null)
            {
                throw new Exception(EL_LIBRO_NO_SE_ENCUENTRA_EN_EL_RESPOSITORIO);
            }
            else
            {
                bool palindormo = libroEncontrado.ValidarPalindromo();

                if (palindormo)
                {
                    throw new Exception(EL_LIBRO_ES_PALINDROMO);
                }
                else
                {
                    int      suma        = libroEncontrado.SumarString();
                    DateTime?fechaMaxima = libroEncontrado.ValidarFechaMaxima(suma);

                    Prestamo prestamo = new Prestamo(DateTime.Now, libroEncontrado, fechaMaxima, nombreUsuario);
                    prestamoRepositorio.Agregar(prestamo);
                }
            }
        }
        /// <summary>
        /// Verifica si un libro se encuentra prestado o no
        /// </summary>
        /// <param name="isbn">Isbn Unico del libro</param>
        /// <returns></returns>
        public bool EsPrestado(string isbn)
        {
            //Se obtiene prestamo de libro por isbn
            var libroPrestado = prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn);

            //Devuelve respuesta de préstamo
            return(libroPrestado != null ? true : false);
        }
Exemplo n.º 4
0
        public bool EsPrestado(string isbn)
        {
            var libro = prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn);

            if (libro != null)
            {
                return(true);
            }

            return(false);
        }
        public void Prestar(string isbn, string nombreUsuario)
        {
            if (prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn) != null)
            {
                throw new ApplicationException(EL_LIBRO_NO_SE_ENCUENTRA_DISPONIBLE);
            }
            var libro = libroRepositorio.ObtenerPorIsbn(isbn);

            if (libro == null)
            {
                throw new ApplicationException(EL_LIBRO_NO_SE_ENCUENTRA_EN_EL_RESPOSITORIO);
            }
            if (libro.EsPalindromo())
            {
                throw new ApplicationException(EL_LIBRO_PALINDROMO_ERROR);
            }


            var      fechaMaximaEntrega = libro.AplicaFechaMaxima(libro.Isbn);
            Prestamo prestamo           = new Prestamo(DateTime.Now, libro, fechaMaximaEntrega, nombreUsuario);

            prestamoRepositorio.Agregar(prestamo);
        }
Exemplo n.º 6
0
        public bool EsPrestado(string isbn)
        {
            Libro libroEncontrado = prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn);

            return(libroEncontrado != null);
        }
Exemplo n.º 7
0
 public bool EsPrestado(string isbn)
 {
     return(prestamoRepositorio.ObtenerLibroPrestadoPorIsbn(isbn) != null);
 }