Esempio n. 1
0
        //Este metodo es utilizado para cuando haces una petición get
        public async Task <IActionResult> OnGet()
        {
            if (!string.IsNullOrWhiteSpace(Search))
            {
                //Búsqueda
                var results = await coursesProvider.SearchAsync(Search);

                if (results != null)
                {
                    Courses = new List <Course>(results);
                }
            }
            else
            {
                var results = await coursesProvider.GetAllAsync();

                //Si el resultado es diferente null lo asignamos a a courses
                if (results != null)
                {
                    Courses = new List <Course>(results);
                }
            }



            //Page es un metodo que retorna un obejto de tipo pageResult  que implemente a IActionResult
            return(Page());
        }
Esempio n. 2
0
        public async Task <IActionResult> OnGet()
        {
            // Validate than Search isn't null or empty
            if (!string.IsNullOrWhiteSpace(Search))
            {
                // Getting searches by name
                var results = await coursesProvider.SearchAsync(Search);

                if (results != null)
                {
                    Courses = new List <Course>(results);
                }
            }
            else
            {
                // Getting all courses on the list
                var results = await coursesProvider.GetAllAsync();

                if (results != null)
                {
                    Courses = new List <Course>(results);
                }
            }

            return(Page());
        }
Esempio n. 3
0
        public async Task <IActionResult> SearchAsync(string search)
        {
            var result = await coursesProviders.SearchAsync(search);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound(search));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnGet()
        {
            if (!string.IsNullOrEmpty(Search))
            {
                var result = await coursesProvider.SearchAsync(Search);

                if (result != null)
                {
                    Courses = new List <Course>(result);
                }
            }
            else
            {
                var result = await coursesProvider.GetAllAsync();

                if (result != null)
                {
                    Courses = new List <Course>(result);
                }
            }
            return(Page());
        }