public async Task <IActionResult> Index(string searchText, int page = 1)
 {
     if (string.IsNullOrWhiteSpace(searchText))
     {
         return(this.View(new ListWorkoutModel
         {
             Workout = await this.workouts.AllAsync(page),
             CurrentPage = page,
             TotalWorkoutCount = await this.workouts.TotalAsync()
         }));
     }
     ViewData.AddSearchMessage(string.Format(WebConstants.ViewDataSearchResultMessage, searchText));
     return(this.View(new ListWorkoutModel
     {
         Workout = await this.workouts.AllResult(searchText)
     }));
 }
Exemple #2
0
        public async Task <IActionResult> Index(string searchText, int page = 1)
        {
            if (string.IsNullOrWhiteSpace(searchText))
            {
                return(this.View(new ListFoodViewModel
                {
                    Food = await this.food.AllAsync(page),
                    TotalFoodCount = await this.food.TotalAsync(),
                    CurrentPage = page
                }));
            }

            ViewData.AddSearchMessage(string.Format(WebConstants.ViewDataSearchResultMessage, searchText));

            return(this.View(new ListFoodViewModel
            {
                Food = await this.food.ResultAsync(searchText),
                CurrentPage = page
            }));
        }