public async Task<ActionResult> Index(int? pageIndex, int? pageSize, string taskId) { SpTaskRepository repository = new SpTaskRepository(); if (Request.HttpMethod == "POST" && taskId != null) { await repository.Delete(taskId); return Redirect("/"); } SpTaskViewModel model = new SpTaskViewModel(); if (pageIndex == null) { model.PageIndex = 0; } else { model.PageIndex = (int)pageIndex; } if (pageSize == null) { model.PageSize = 10; } else { model.PageSize = (int)pageSize; } model.SpTasks = await repository.GetTasks(model.PageIndex, model.PageSize); return View(model); }